unit1397.c 2.0 KB

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