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