From 293e1b299445e73f9149b6e6950dcefdd3c9c299 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sun, 13 Mar 2022 11:40:09 -0300 Subject: 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 --- tests/util.lisp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'tests') 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) -- cgit v1.2.3