aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2022-03-13 11:40:09 -0300
committerSean Whitton <spwhitton@spwhitton.name>2022-03-22 11:14:08 -0700
commit293e1b299445e73f9149b6e6950dcefdd3c9c299 (patch)
tree14693790a877dfa81d3d26ce975d0c1332b381b8 /tests
parent0550b8faf77b056e383ad332abbb4304acb8c512 (diff)
downloadconsfigurator-293e1b299445e73f9149b6e6950dcefdd3c9c299.tar.gz
add VALID-HOSTNAME-P
Initial intended application is checking data source IDEN1. This could be done as a one-liner with a more complex regex, but that seems harder to debug. Signed-off-by: David Bremner <david@tethera.net>
Diffstat (limited to 'tests')
-rw-r--r--tests/util.lisp30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/util.lisp b/tests/util.lisp
index bffda68..fd310a7 100644
--- a/tests/util.lisp
+++ b/tests/util.lisp
@@ -17,3 +17,33 @@
(deftest version<.4 (version< "1.a.1" "1.1") t)
(deftest version<.5 (version< "1..1" "1.1") t)
+
+;; without domain
+(deftest valid-hostname-p.1 (valid-hostname-p "localhost") t)
+
+(deftest valid-hostname-p.2 (valid-hostname-p "host.example.com") t)
+
+;; case insensitive check
+(deftest valid-hostname-p.3 (valid-hostname-p "host.Example.Com") t)
+
+;; total length too long
+(deftest valid-hostname-p.4
+ (valid-hostname-p (format nil "~127@{a.~}a" nil))
+ nil)
+
+;; label too long
+(deftest valid-hostname-p.5
+ (valid-hostname-p (format nil "~64@{a~}a" nil))
+ nil)
+
+;; valid use of `-'
+(deftest valid-hostname-p.6 (valid-hostname-p "host-name.example.com") t)
+
+;; invalid use of `-'
+(deftest valid-hostname-p.7 (valid-hostname-p "-hostname.example.com") nil)
+
+;; invalid character
+(deftest valid-hostname-p.8 (valid-hostname-p "_hostname.example.com") nil)
+
+;; invalid character 2
+(deftest valid-hostname-p.9 (valid-hostname-p "foo/bar") nil)