[glib-networking] gnutls: Add test for g_tls_certificate_is_same()
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib-networking] gnutls: Add test for g_tls_certificate_is_same()
- Date: Fri, 3 Aug 2012 17:02:36 +0000 (UTC)
commit 32dab4d68a9f166dda54305e590b6429aa5f5fd7
Author: Stef Walter <stefw gnome org>
Date: Fri Aug 3 18:46:36 2012 +0200
gnutls: Add test for g_tls_certificate_is_same()
* The test can't live in glib since there's no implementation of
GTlsCertificate there.
https://bugzilla.gnome.org/show_bug.cgi?id=681154
tls/tests/certificate.c | 31 +++++++++++++++++++++++++++++++
tls/tests/file-database.c | 2 +-
2 files changed, 32 insertions(+), 1 deletions(-)
---
diff --git a/tls/tests/certificate.c b/tls/tests/certificate.c
index eb1217d..2598ff1 100644
--- a/tls/tests/certificate.c
+++ b/tls/tests/certificate.c
@@ -320,6 +320,35 @@ test_verify_certificate_bad_combo (TestVerify *test,
g_object_unref (identity);
}
+static void
+test_certificate_is_same (void)
+{
+ GTlsCertificate *one;
+ GTlsCertificate *two;
+ GTlsCertificate *three;
+ GError *error = NULL;
+
+ one = g_tls_certificate_new_from_file (TEST_FILE ("client.pem"), &error);
+ g_assert_no_error (error);
+
+ two = g_tls_certificate_new_from_file (TEST_FILE ("client-and-key.pem"), &error);
+ g_assert_no_error (error);
+
+ three = g_tls_certificate_new_from_file (TEST_FILE ("server.pem"), &error);
+ g_assert_no_error (error);
+
+ g_assert (g_tls_certificate_is_same (one, two) == TRUE);
+ g_assert (g_tls_certificate_is_same (two, one) == TRUE);
+ g_assert (g_tls_certificate_is_same (three, one) == FALSE);
+ g_assert (g_tls_certificate_is_same (one, three) == FALSE);
+ g_assert (g_tls_certificate_is_same (two, three) == FALSE);
+ g_assert (g_tls_certificate_is_same (three, two) == FALSE);
+
+ g_object_unref (one);
+ g_object_unref (two);
+ g_object_unref (three);
+}
+
int
main (int argc,
char *argv[])
@@ -351,5 +380,7 @@ main (int argc,
g_test_add ("/tls/certificate/verify-bad-combo", TestVerify, NULL,
setup_verify, test_verify_certificate_bad_combo, teardown_verify);
+ g_test_add_func ("/tls/certificate/is-same", test_certificate_is_same);
+
return g_test_run();
}
diff --git a/tls/tests/file-database.c b/tls/tests/file-database.c
index 69ba0a2..a7ef16e 100644
--- a/tls/tests/file-database.c
+++ b/tls/tests/file-database.c
@@ -324,7 +324,7 @@ certificate_is_in_list (GList *certificates,
for (l = certificates; l != NULL; l = g_list_next (l))
{
- if (g_tls_certificate_equal (l->data, cert))
+ if (g_tls_certificate_is_same (l->data, cert))
break;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]