1 #include "curlcheck.h" 2 3 #include "hostcheck.h" /* from the lib dir */ 4 5 static CURLcode unit_setup(void) 6 { 7 return CURLE_OK; 8 } 9 10 static void unit_stop( void ) 11 { 12 /* done before shutting down and exiting */ 13 } 14 15 UNITTEST_START 16 17 /* only these backends define the tested functions */ 18 #if defined(USE_OPENSSL) || defined(USE_AXTLS) || defined(USE_GSKIT) 19 20 /* here you start doing things and checking that the results are good */ 21 22 fail_unless( Curl_cert_hostcheck("www.example.com", "www.example.com"), "good 1" ); 23 fail_unless( Curl_cert_hostcheck("*.example.com", "www.example.com"), "good 2" ); 24 fail_unless( Curl_cert_hostcheck("xxx*.example.com", "xxxwww.example.com"), "good 3" ); 25 fail_unless( Curl_cert_hostcheck("f*.example.com", "foo.example.com"), "good 4" ); 26 fail_unless( Curl_cert_hostcheck("192.168.0.0", "192.168.0.0"), "good 5" ); 27 28 fail_if( Curl_cert_hostcheck("xxx.example.com", "www.example.com"), "bad 1" ); 29 fail_if( Curl_cert_hostcheck("*", "www.example.com"), "bad 2" ); 30 fail_if( Curl_cert_hostcheck("*.*.com", "www.example.com"), "bad 3" ); 31 fail_if( Curl_cert_hostcheck("*.example.com", "baa.foo.example.com"), "bad 4" ); 32 fail_if( Curl_cert_hostcheck("f*.example.com", "baa.example.com"), "bad 5" ); 33 fail_if( Curl_cert_hostcheck("*.com", "example.com"), "bad 6" ); 34 fail_if( Curl_cert_hostcheck("*fail.com", "example.com"), "bad 7" ); 35 fail_if( Curl_cert_hostcheck("*.example.", "www.example."), "bad 8" ); 36 fail_if( Curl_cert_hostcheck("*.example.", "www.example"), "bad 9" ); 37 fail_if( Curl_cert_hostcheck("", "www"), "bad 10" ); 38 fail_if( Curl_cert_hostcheck("*", "www"), "bad 11" ); 39 fail_if( Curl_cert_hostcheck("*.168.0.0", "192.168.0.0"), "bad 12" ); 40 fail_if( Curl_cert_hostcheck("www.example.com", "192.168.0.0"), "bad 13" ); 41 42 #ifdef ENABLE_IPV6 43 fail_if( Curl_cert_hostcheck("*::3285:a9ff:fe46:b619", "fe80::3285:a9ff:fe46:b619"), "bad 14" ); 44 fail_unless( Curl_cert_hostcheck("fe80::3285:a9ff:fe46:b619", "fe80::3285:a9ff:fe46:b619"), "good 6" ); 45 #endif 46 47 #endif 48 49 /* you end the test code like this: */ 50 51 UNITTEST_STOP 52