From e76f1e0e1ed03be4849f917129acfab08bb544f4 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Sat, 4 Feb 2017 14:01:36 +0100 Subject: tests: enable all IDNA tests when compiled with libidn2 Keep IDNA2003-only tests on the ifdef HAVE_LIBIDN. Signed-off-by: Nikos Mavrogiannopoulos --- tests/cert_verify_inv_utf8.c | 2 +- tests/crq_apis.c | 9 +++++++-- tests/crt_apis.c | 8 ++++++-- tests/hostname-check-utf8.c | 8 +++++--- tests/mini-server-name.c | 2 +- tests/set_key_utf8.c | 4 +++- tests/set_x509_key_utf8.c | 4 +++- 7 files changed, 26 insertions(+), 11 deletions(-) diff --git a/tests/cert_verify_inv_utf8.c b/tests/cert_verify_inv_utf8.c index d43dfe80cc..a2b1e5b965 100644 --- a/tests/cert_verify_inv_utf8.c +++ b/tests/cert_verify_inv_utf8.c @@ -150,7 +150,7 @@ static void auto_parse(void) void doit(void) { -#ifndef HAVE_LIBIDN +#if !defined(HAVE_LIBIDN) && !defined(HAVE_LIBIDN2) exit(77); #endif auto_parse(); diff --git a/tests/crq_apis.c b/tests/crq_apis.c index 7ad717ff13..a4ff7c3816 100644 --- a/tests/crq_apis.c +++ b/tests/crq_apis.c @@ -184,8 +184,13 @@ static gnutls_x509_crq_t generate_crq(void) ret = gnutls_x509_crq_set_subject_alt_name(crq, GNUTLS_SAN_DNSNAME, "νίκο.com", strlen("νίκο.com"), GNUTLS_FSAN_APPEND); +#if defined(HAVE_LIBIDN) || defined(HAVE_LIBIDN2) if (ret != 0) - fail("gnutls_x509_crq_set_subject_alt_name\n"); + fail("gnutls_x509_crt_set_subject_alt_name: %s\n", gnutls_strerror(ret)); +#else + if (ret != GNUTLS_E_UNIMPLEMENTED_FEATURE) + fail("gnutls_x509_crt_set_subject_alt_name: %s\n", gnutls_strerror(ret)); +#endif s = 0; ret = gnutls_x509_crq_get_key_purpose_oid(crq, 0, NULL, &s, NULL); @@ -448,7 +453,7 @@ void doit(void) assert(gnutls_x509_crq_export2(crq, GNUTLS_X509_FMT_PEM, &out) >= 0); -#ifdef HAVE_LIBIDN +#if defined(HAVE_LIBIDN) || defined(HAVE_LIBIDN2) assert(out.size == saved_crq.size); assert(memcmp(out.data, saved_crq.data, out.size)==0); #endif diff --git a/tests/crt_apis.c b/tests/crt_apis.c index ed31640823..ccc0ab5200 100644 --- a/tests/crt_apis.c +++ b/tests/crt_apis.c @@ -180,8 +180,13 @@ void doit(void) ret = gnutls_x509_crt_set_subject_alt_name(crt, GNUTLS_SAN_DNSNAME, "απαλό.com", strlen("απαλό.com"), 1); +#if defined(HAVE_LIBIDN) || defined(HAVE_LIBIDN2) if (ret != 0) - fail("gnutls_x509_crt_set_subject_alt_name\n"); + fail("gnutls_x509_crt_set_subject_alt_name: %s\n", gnutls_strerror(ret)); +#else + if (ret != GNUTLS_E_UNIMPLEMENTED_FEATURE) + fail("gnutls_x509_crt_set_subject_alt_name: %s\n", gnutls_strerror(ret)); +#endif #ifdef HAVE_LIBIDN ret = gnutls_x509_crt_set_subject_alt_name(crt, GNUTLS_SAN_RFC822NAME, @@ -189,7 +194,6 @@ void doit(void) if (ret != 0) fail("gnutls_x509_crt_set_subject_alt_name\n"); #endif - s = 0; ret = gnutls_x509_crt_get_key_purpose_oid(crt, 0, NULL, &s, NULL); if (ret != GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) diff --git a/tests/hostname-check-utf8.c b/tests/hostname-check-utf8.c index 4f521c5690..10128bc774 100644 --- a/tests/hostname-check-utf8.c +++ b/tests/hostname-check-utf8.c @@ -188,7 +188,7 @@ void doit(void) if (ret) fail("%d: Hostname incorrectly matches (%d)\n", __LINE__, ret); -#ifdef HAVE_LIBIDN +#if defined(HAVE_LIBIDN) || defined(HAVE_LIBIDN2) ret = gnutls_x509_crt_check_hostname(x509, "www.teχ.gr"); if (!ret) fail("%d: Hostname incorrectly does not match (%d)\n", __LINE__, ret); @@ -197,17 +197,19 @@ void doit(void) if (!ret) fail("%d: Hostname incorrectly does not match (%d)\n", __LINE__, ret); - ret = gnutls_x509_crt_check_hostname(x509, "γΓγ.τόΣτ.gr"); + ret = gnutls_x509_crt_check_hostname(x509, "τέστ.gr"); if (!ret) fail("%d: Hostname incorrectly does not match (%d)\n", __LINE__, ret); - ret = gnutls_x509_crt_check_hostname(x509, "τέστ.gr"); +#if defined(HAVE_LIBIDN) /* There are IDNA2003 */ + ret = gnutls_x509_crt_check_hostname(x509, "γΓγ.τόΣτ.gr"); if (!ret) fail("%d: Hostname incorrectly does not match (%d)\n", __LINE__, ret); ret = gnutls_x509_crt_check_hostname(x509, "ΤΈΣΤ.gr"); if (!ret) fail("%d: Hostname incorrectly does not match (%d)\n", __LINE__, ret); +#endif #endif gnutls_x509_crt_deinit(x509); diff --git a/tests/mini-server-name.c b/tests/mini-server-name.c index 8f8ed0b905..ae7bb185a5 100644 --- a/tests/mini-server-name.c +++ b/tests/mini-server-name.c @@ -341,7 +341,7 @@ void doit(void) start("empty", 0, "", 0, "", 0); start("test.example.com", 0, "test.example.com", strlen("test.example.com"), "test.example.com", strlen("test.example.com")); start("longtest.example.com", 0, "longtest.example.com.", strlen("longtest.example.com"), "longtest.example.com.", strlen("longtest.example.com")); -#ifdef HAVE_LIBIDN +#if defined(HAVE_LIBIDN) || defined(HAVE_LIBIDN2) /* test invalid UTF8 */ start("invalid-utf8", 1, "invalid\xff.example.com.", sizeof("invalid\xff.example.com")-1, NULL, 0); #endif diff --git a/tests/set_key_utf8.c b/tests/set_key_utf8.c index adbb16aeaf..17d031d67d 100644 --- a/tests/set_key_utf8.c +++ b/tests/set_key_utf8.c @@ -135,9 +135,11 @@ static void auto_parse(void) } test_cli_serv(x509_cred, clicred, "NORMAL", "localhost", NULL, NULL, NULL); /* the DNS name of the first cert */ +#ifdef HAVE_LIBIDN /* IDNA2003-only */ test_cli_serv(x509_cred, clicred, "NORMAL", "www.νίκος.com", NULL, NULL, NULL); /* the DNS name of second cert */ test_cli_serv(x509_cred, clicred, "NORMAL", "raw:www.νίκος.com", NULL, NULL, NULL); /* the DNS name of second cert */ test_cli_serv(x509_cred, clicred, "NORMAL", "www.xn--kxawhku.com", NULL, NULL, NULL); /* the previous name in IDNA format */ +#endif test_cli_serv(x509_cred, clicred, "NORMAL", "简体中文.εξτρα.com", NULL, NULL, NULL); /* the second DNS name of cert */ test_cli_serv(x509_cred, clicred, "NORMAL", "raw:简体中文.εξτρα.com", NULL, NULL, NULL); /* the second DNS name of cert */ test_cli_serv(x509_cred, clicred, "NORMAL", "xn--fiqu1az03c18t.xn--mxah1amo.com", NULL, NULL, NULL); /* its IDNA equivalent */ @@ -153,7 +155,7 @@ static void auto_parse(void) void doit(void) { -#ifndef HAVE_LIBIDN +#if !defined(HAVE_LIBIDN) && !defined(HAVE_LIBIDN2) exit(77); #endif auto_parse(); diff --git a/tests/set_x509_key_utf8.c b/tests/set_x509_key_utf8.c index 838ec84028..d67747732a 100644 --- a/tests/set_x509_key_utf8.c +++ b/tests/set_x509_key_utf8.c @@ -143,7 +143,7 @@ void doit(void) int ret; unsigned idx; -#ifndef HAVE_LIBIDN +#if !defined(HAVE_LIBIDN) && !defined(HAVE_LIBIDN2) exit(77); #endif @@ -173,8 +173,10 @@ void doit(void) assert(idx == 1); test_cli_serv(x509_cred, clicred, "NORMAL", "localhost", NULL, NULL, NULL); +#if defined(HAVE_LIBIDN) /* IDNA2003 */ test_cli_serv(x509_cred, clicred, "NORMAL", "www.νίκος.com", NULL, NULL, NULL); /* the DNS name of second cert */ test_cli_serv(x509_cred, clicred, "NORMAL", "raw:www.νίκος.com", NULL, NULL, NULL); /* the DNS name of second cert */ +#endif test_cli_serv(x509_cred, clicred, "NORMAL", "www.xn--kxawhku.com", NULL, NULL, NULL); /* the previous name in IDNA format */ test_cli_serv(x509_cred, clicred, "NORMAL", "简体中文.εξτρα.com", NULL, NULL, NULL); /* the second DNS name of cert */ test_cli_serv(x509_cred, clicred, "NORMAL", "raw:简体中文.εξτρα.com", NULL, NULL, NULL); /* the second DNS name of cert */ -- cgit v1.2.1