summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2017-02-04 14:01:36 +0100
committerNikos Mavrogiannopoulos <nmav@redhat.com>2017-02-04 23:48:37 +0100
commit90deae35fed78b5c617489e1dfc9506181b27d4b (patch)
tree88750027aa72838547b34076cb30d1b512f0eb26
parent35bb9d4bc9f66293cd75cb405d5af3b291054e1f (diff)
downloadgnutls-90deae35fed78b5c617489e1dfc9506181b27d4b.tar.gz
tests: enable all IDNA tests when compiled with libidn2
Keep IDNA2003-only tests on the ifdef HAVE_LIBIDN. Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
-rw-r--r--tests/cert_verify_inv_utf8.c2
-rw-r--r--tests/crq_apis.c9
-rw-r--r--tests/crt_apis.c8
-rw-r--r--tests/hostname-check-utf8.c8
-rw-r--r--tests/mini-server-name.c2
-rw-r--r--tests/set_key_utf8.c4
-rw-r--r--tests/set_x509_key_utf8.c4
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,11 +197,12 @@ 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);
@@ -209,6 +210,7 @@ void doit(void)
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 */