Revert "Update to 7.40.1"
[platform/upstream/curl.git] / tests / unit / unit1397.c
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_SSLEAY) || defined(USE_AXTLS) || defined(USE_QSOSSL) || \
19     defined(USE_GSKIT)
20
21   /* here you start doing things and checking that the results are good */
22
23 fail_unless( Curl_cert_hostcheck("www.example.com", "www.example.com"), "good 1" );
24 fail_unless( Curl_cert_hostcheck("*.example.com", "www.example.com"), "good 2" );
25 fail_unless( Curl_cert_hostcheck("xxx*.example.com", "xxxwww.example.com"), "good 3" );
26 fail_unless( Curl_cert_hostcheck("f*.example.com", "foo.example.com"), "good 4" );
27 fail_unless( Curl_cert_hostcheck("192.168.0.0", "192.168.0.0"), "good 5" );
28
29 fail_if( Curl_cert_hostcheck("xxx.example.com", "www.example.com"), "bad 1" );
30 fail_if( Curl_cert_hostcheck("*", "www.example.com"), "bad 2" );
31 fail_if( Curl_cert_hostcheck("*.*.com", "www.example.com"), "bad 3" );
32 fail_if( Curl_cert_hostcheck("*.example.com", "baa.foo.example.com"), "bad 4" );
33 fail_if( Curl_cert_hostcheck("f*.example.com", "baa.example.com"), "bad 5" );
34 fail_if( Curl_cert_hostcheck("*.com", "example.com"), "bad 6" );
35 fail_if( Curl_cert_hostcheck("*fail.com", "example.com"), "bad 7" );
36 fail_if( Curl_cert_hostcheck("*.example.", "www.example."), "bad 8" );
37 fail_if( Curl_cert_hostcheck("*.example.", "www.example"), "bad 9" );
38 fail_if( Curl_cert_hostcheck("", "www"), "bad 10" );
39 fail_if( Curl_cert_hostcheck("*", "www"), "bad 11" );
40 fail_if( Curl_cert_hostcheck("*.168.0.0", "192.168.0.0"), "bad 12" );
41 fail_if( Curl_cert_hostcheck("www.example.com", "192.168.0.0"), "bad 13" );
42
43 #ifdef ENABLE_IPV6
44 fail_if( Curl_cert_hostcheck("*::3285:a9ff:fe46:b619", "fe80::3285:a9ff:fe46:b619"), "bad 14" );
45 fail_unless( Curl_cert_hostcheck("fe80::3285:a9ff:fe46:b619", "fe80::3285:a9ff:fe46:b619"), "good 6" );
46 #endif
47
48 #endif
49
50   /* you end the test code like this: */
51
52 UNITTEST_STOP