aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/unit1397.c
diff options
context:
space:
mode:
authorRichard J. Moore <rich@kde.org>2014-02-22 15:52:58 +0000
committerDaniel Stenberg <daniel@haxx.se>2014-03-25 23:01:37 +0100
commit4d06b27921bde6d0caba0c84c1e50f8495ed48ee (patch)
treeb32341015ed88b5f8da8ccbb7b81fb0e3ad93937 /tests/unit/unit1397.c
parent965690f67e190b5069cb0b16eef6917cb0d8ae18 (diff)
test1397: unit test for certificate name wildcard handling
Diffstat (limited to 'tests/unit/unit1397.c')
-rw-r--r--tests/unit/unit1397.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/unit/unit1397.c b/tests/unit/unit1397.c
new file mode 100644
index 000000000..7e508a840
--- /dev/null
+++ b/tests/unit/unit1397.c
@@ -0,0 +1,46 @@
+#include "curlcheck.h"
+
+#include "hostcheck.h" /* from the lib dir */
+
+static CURLcode unit_setup(void)
+{
+ return CURLE_OK;
+}
+
+static void unit_stop( void )
+{
+ /* done before shutting down and exiting */
+}
+
+UNITTEST_START
+
+ /* here you start doing things and checking that the results are good */
+
+fail_unless( Curl_cert_hostcheck("www.example.com", "www.example.com"), "good 1" );
+fail_unless( Curl_cert_hostcheck("*.example.com", "www.example.com"), "good 2" );
+fail_unless( Curl_cert_hostcheck("xxx*.example.com", "xxxwww.example.com"), "good 3" );
+fail_unless( Curl_cert_hostcheck("f*.example.com", "foo.example.com"), "good 4" );
+fail_unless( Curl_cert_hostcheck("192.168.0.0", "192.168.0.0"), "good 5" );
+
+fail_if( Curl_cert_hostcheck("xxx.example.com", "www.example.com"), "bad 1" );
+fail_if( Curl_cert_hostcheck("*", "www.example.com"), "bad 2" );
+fail_if( Curl_cert_hostcheck("*.*.com", "www.example.com"), "bad 3" );
+fail_if( Curl_cert_hostcheck("*.example.com", "baa.foo.example.com"), "bad 4" );
+fail_if( Curl_cert_hostcheck("f*.example.com", "baa.example.com"), "bad 5" );
+fail_if( Curl_cert_hostcheck("*.com", "example.com"), "bad 6" );
+fail_if( Curl_cert_hostcheck("*fail.com", "example.com"), "bad 7" );
+fail_if( Curl_cert_hostcheck("*.example.", "www.example."), "bad 8" );
+fail_if( Curl_cert_hostcheck("*.example.", "www.example"), "bad 9" );
+fail_if( Curl_cert_hostcheck("", "www"), "bad 10" );
+fail_if( Curl_cert_hostcheck("*", "www"), "bad 11" );
+fail_if( Curl_cert_hostcheck("*.168.0.0", "192.168.0.0"), "bad 12" );
+fail_if( Curl_cert_hostcheck("www.example.com", "192.168.0.0"), "bad 13" );
+
+#ifdef ENABLE_IPV6
+fail_if( Curl_cert_hostcheck("*::3285:a9ff:fe46:b619", "fe80::3285:a9ff:fe46:b619"), "bad 14" );
+fail_unless( Curl_cert_hostcheck("fe80::3285:a9ff:fe46:b619", "fe80::3285:a9ff:fe46:b619"), "good 6" );
+#endif
+
+ /* you end the test code like this: */
+
+UNITTEST_STOP