[glib/tls-database] Add test for GTlsCertificate::issuer



commit 805638504e6266a4d8f936d7e06867d0b45d4677
Author: Stef Walter <stefw collabora co uk>
Date:   Tue Jan 18 11:56:54 2011 -0600

    Add test for GTlsCertificate::issuer

 gio/tests/tls.c |   37 +++++++++++++++++++++++++++++++++++++
 1 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/gio/tests/tls.c b/gio/tests/tls.c
index b65a180..610c8f5 100644
--- a/gio/tests/tls.c
+++ b/gio/tests/tls.c
@@ -405,6 +405,41 @@ test_create_destroy_certificate_der (TestCertificate *test, gconstpointer data)
   g_assert (!G_IS_TLS_CERTIFICATE (cert));
 }
 
+static void
+test_create_certificate_with_issuer (TestCertificate   *test,
+                                     gconstpointer      data)
+{
+  GTlsCertificate *cert, *issuer, *check;
+  GError *error = NULL;
+  GTlsBackend *backend;
+  gchar *path;
+
+  path = g_build_filename (SRCDIR, "tls-tests", "ca.pem", NULL);
+  issuer = g_tls_certificate_new_from_file (path, &error);
+  g_assert_no_error (error);
+  g_assert (G_IS_TLS_CERTIFICATE (issuer));
+  g_free (path);
+
+  backend = g_tls_backend_get_default ();
+  cert = g_initable_new (g_tls_backend_get_certificate_type (backend),
+                         NULL, &error,
+                         "certificate-pem", test->pem,
+                         "issuer", issuer,
+                         NULL);
+  g_assert_no_error (error);
+  g_assert (G_IS_TLS_CERTIFICATE (cert));
+
+  g_object_unref (issuer);
+  g_assert (G_IS_TLS_CERTIFICATE (issuer));
+
+  check = g_tls_certificate_get_issuer (cert);
+  g_assert (check == issuer);
+
+  g_object_unref (cert);
+  g_assert (!G_IS_TLS_CERTIFICATE (cert));
+  g_assert (!G_IS_TLS_CERTIFICATE (issuer));
+}
+
 /* -----------------------------------------------------------------------------
  * CERTIFICATE VERIFY
  */
@@ -621,6 +656,8 @@ main (int   argc,
               setup_certificate, test_create_destroy_certificate_pem, teardown_certificate);
   g_test_add ("/tls/certificate/create-destroy-der", TestCertificate, NULL,
               setup_certificate, test_create_destroy_certificate_der, teardown_certificate);
+  g_test_add ("/tls/certificate/create-with-issuer", TestCertificate, NULL,
+              setup_certificate, test_create_certificate_with_issuer, teardown_certificate);
 
   g_test_add ("/tls/certificate/verify-good", TestCertificateVerify, NULL,
               setup_certificate_verify, test_verify_certificate_good, teardown_certificate_verify);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]