aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/data/Makefile.am2
-rw-r--r--tests/data/test139727
-rw-r--r--tests/unit/Makefile.inc5
-rw-r--r--tests/unit/unit1397.c46
4 files changed, 78 insertions, 2 deletions
diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
index 9251d9be2..59ccdfd12 100644
--- a/tests/data/Makefile.am
+++ b/tests/data/Makefile.am
@@ -116,7 +116,7 @@ test1364 test1365 test1366 test1367 test1368 test1369 test1370 test1371 \
test1372 test1373 test1374 test1375 test1376 test1377 test1378 test1379 \
test1380 test1381 test1382 test1383 test1384 test1385 test1386 test1387 \
test1388 test1389 test1390 test1391 test1392 test1393 test1394 test1395 \
-test1396 \
+test1396 test1397 \
\
test1400 test1401 test1402 test1403 test1404 test1405 test1406 test1407 \
test1408 test1409 test1410 test1412 test1413 test1414 test1415 \
diff --git a/tests/data/test1397 b/tests/data/test1397
new file mode 100644
index 000000000..5f479b468
--- /dev/null
+++ b/tests/data/test1397
@@ -0,0 +1,27 @@
+<testcase>
+<info>
+<keywords>
+unittest
+ssl
+wildcard
+</keywords>
+</info>
+
+#
+# Client-side
+<client>
+<server>
+none
+</server>
+<features>
+unittest
+</features>
+ <name>
+Check wildcard certificate matching function Curl_cert_hostcheck
+ </name>
+<tool>
+unit1397
+</tool>
+</client>
+
+</testcase>
diff --git a/tests/unit/Makefile.inc b/tests/unit/Makefile.inc
index 4c06fcf86..75bf45abb 100644
--- a/tests/unit/Makefile.inc
+++ b/tests/unit/Makefile.inc
@@ -6,7 +6,7 @@ UNITFILES = curlcheck.h \
# These are all unit test programs
UNITPROGS = unit1300 unit1301 unit1302 unit1303 unit1304 unit1305 unit1307 \
- unit1308 unit1309 unit1330 unit1394 unit1395 unit1396
+ unit1308 unit1309 unit1330 unit1394 unit1395 unit1396 unit1397
unit1300_SOURCES = unit1300.c $(UNITFILES)
unit1300_CPPFLAGS = $(AM_CPPFLAGS)
@@ -49,3 +49,6 @@ unit1395_CPPFLAGS = $(AM_CPPFLAGS)
unit1396_SOURCES = unit1396.c $(UNITFILES)
unit1396_CPPFLAGS = $(AM_CPPFLAGS)
+
+unit1397_SOURCES = unit1397.c $(UNITFILES)
+unit1397_CPPFLAGS = $(AM_CPPFLAGS)
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