Annotation of embedaddon/curl/tests/unit/unit1397.c, revision 1.1
1.1 ! misho 1: /***************************************************************************
! 2: * _ _ ____ _
! 3: * Project ___| | | | _ \| |
! 4: * / __| | | | |_) | |
! 5: * | (__| |_| | _ <| |___
! 6: * \___|\___/|_| \_\_____|
! 7: *
! 8: * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
! 9: *
! 10: * This software is licensed as described in the file COPYING, which
! 11: * you should have received as part of this distribution. The terms
! 12: * are also available at https://curl.haxx.se/docs/copyright.html.
! 13: *
! 14: * You may opt to use, copy, modify, merge, publish, distribute and/or sell
! 15: * copies of the Software, and permit persons to whom the Software is
! 16: * furnished to do so, under the terms of the COPYING file.
! 17: *
! 18: * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
! 19: * KIND, either express or implied.
! 20: *
! 21: ***************************************************************************/
! 22: #include "curlcheck.h"
! 23:
! 24: #include "hostcheck.h" /* from the lib dir */
! 25:
! 26: static CURLcode unit_setup(void)
! 27: {
! 28: return CURLE_OK;
! 29: }
! 30:
! 31: static void unit_stop(void)
! 32: {
! 33: /* done before shutting down and exiting */
! 34: }
! 35:
! 36: UNITTEST_START
! 37:
! 38: /* only these backends define the tested functions */
! 39: #if defined(USE_OPENSSL) || defined(USE_GSKIT)
! 40:
! 41: /* here you start doing things and checking that the results are good */
! 42:
! 43: fail_unless(Curl_cert_hostcheck("www.example.com", "www.example.com"),
! 44: "good 1");
! 45: fail_unless(Curl_cert_hostcheck("*.example.com", "www.example.com"),
! 46: "good 2");
! 47: fail_unless(Curl_cert_hostcheck("xxx*.example.com", "xxxwww.example.com"),
! 48: "good 3");
! 49: fail_unless(Curl_cert_hostcheck("f*.example.com", "foo.example.com"),
! 50: "good 4");
! 51: fail_unless(Curl_cert_hostcheck("192.168.0.0", "192.168.0.0"),
! 52: "good 5");
! 53:
! 54: fail_if(Curl_cert_hostcheck("xxx.example.com", "www.example.com"), "bad 1");
! 55: fail_if(Curl_cert_hostcheck("*", "www.example.com"), "bad 2");
! 56: fail_if(Curl_cert_hostcheck("*.*.com", "www.example.com"), "bad 3");
! 57: fail_if(Curl_cert_hostcheck("*.example.com", "baa.foo.example.com"), "bad 4");
! 58: fail_if(Curl_cert_hostcheck("f*.example.com", "baa.example.com"), "bad 5");
! 59: fail_if(Curl_cert_hostcheck("*.com", "example.com"), "bad 6");
! 60: fail_if(Curl_cert_hostcheck("*fail.com", "example.com"), "bad 7");
! 61: fail_if(Curl_cert_hostcheck("*.example.", "www.example."), "bad 8");
! 62: fail_if(Curl_cert_hostcheck("*.example.", "www.example"), "bad 9");
! 63: fail_if(Curl_cert_hostcheck("", "www"), "bad 10");
! 64: fail_if(Curl_cert_hostcheck("*", "www"), "bad 11");
! 65: fail_if(Curl_cert_hostcheck("*.168.0.0", "192.168.0.0"), "bad 12");
! 66: fail_if(Curl_cert_hostcheck("www.example.com", "192.168.0.0"), "bad 13");
! 67:
! 68: #ifdef ENABLE_IPV6
! 69: fail_if(Curl_cert_hostcheck("*::3285:a9ff:fe46:b619",
! 70: "fe80::3285:a9ff:fe46:b619"), "bad 14");
! 71: fail_unless(Curl_cert_hostcheck("fe80::3285:a9ff:fe46:b619",
! 72: "fe80::3285:a9ff:fe46:b619"), "good 6");
! 73: #endif
! 74:
! 75: #endif
! 76:
! 77: /* you end the test code like this: */
! 78:
! 79: UNITTEST_STOP
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>