[network-manager-applet/lr/pkcs11: 21/22] XXX add a cert chooser test



commit cfa9c775fb553b472983fa4f38716e8a85f34af7
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Tue Mar 7 12:54:37 2017 +0100

    XXX add a cert chooser test

 Makefile.am                        |   18 +++++++++++
 src/libnma/nma-cert-chooser-test.c |   56 ++++++++++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+), 0 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 8d923c5..22c1739 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -517,6 +517,24 @@ src_libnma_libnmadir = $(includedir)/libnma
 src_libnma_libnma_HEADERS = \
        $(libnma_h_pub)
 
+noinst_PROGRAMS += src/libnma/nma-cert-chooser-test
+
+nma_cert_chooser_test_SOURCES =
+
+src_libnma_nma_cert_chooser_test_SOURCES = \
+       src/libnma/nma-cert-chooser-test.c
+
+src_libnma_nma_cert_chooser_test_CFLAGS = \
+       "-I$(srcdir)/src/libnma" \
+       "-I$(srcdir)/shared" \
+       $(LIBNM_CFLAGS) \
+       $(GTK_CFLAGS)
+
+src_libnma_nma_cert_chooser_test_LDADD = \
+       src/libnma/libnma.la \
+       $(LIBNM_LIBS) \
+       $(GTK_LIBS)
+
 lib_LTLIBRARIES += src/libnma/libnma.la
 
 src_libnma_libnma_la_SOURCES = \
diff --git a/src/libnma/nma-cert-chooser-test.c b/src/libnma/nma-cert-chooser-test.c
new file mode 100644
index 0000000..6681192
--- /dev/null
+++ b/src/libnma/nma-cert-chooser-test.c
@@ -0,0 +1,56 @@
+#include <gtk/gtk.h>
+
+#include "nm-default.h"
+#include "nma-cert-chooser.h"
+#include "nma-cert-chooser-button.h"
+
+int
+main (int argc, char *argv[])
+{
+       GtkWidget *dialog, *box;
+       GtkWidget *chooser1, *chooser2, *chooser3;
+
+       gtk_init (&argc, &argv);
+
+       dialog = gtk_dialog_new ();
+       g_object_ref_sink (dialog);
+
+       box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
+       gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), box);
+       gtk_widget_show (box);
+
+       chooser1 = nma_cert_chooser_new ("CA", NMA_CERT_CHOOSER_FLAG_CERT | NMA_CERT_CHOOSER_FLAG_PEM);
+       nma_cert_chooser_set_cert (NMA_CERT_CHOOSER (chooser1),
+                                  "/home/lkundrak/sample-keys/ca.crt",
+                                  NM_SETTING_802_1X_CK_SCHEME_PATH);
+       gtk_container_add (GTK_CONTAINER (box), chooser1);
+       gtk_widget_show (chooser1);
+
+       chooser2 = nma_cert_chooser_new ("User", 0);
+       nma_cert_chooser_set_cert (NMA_CERT_CHOOSER (chooser2),
+                                  "/home/lkundrak/sample-keys/client.crt",
+                                  NM_SETTING_802_1X_CK_SCHEME_PATH);
+       nma_cert_chooser_set_key (NMA_CERT_CHOOSER (chooser2),
+                                 "/home/lkundrak/sample-keys/client.key",
+                                 NM_SETTING_802_1X_CK_SCHEME_PATH);
+       nma_cert_chooser_set_key_password (NMA_CERT_CHOOSER (chooser2), "kvokot");
+       gtk_container_add (GTK_CONTAINER (box), chooser2);
+       gtk_widget_show (chooser2);
+
+       chooser3 = nma_cert_chooser_new ("User", NMA_CERT_CHOOSER_FLAG_PASSWORDS);
+       nma_cert_chooser_set_cert (NMA_CERT_CHOOSER (chooser3),
+                                  "/home/lkundrak/sample-keys/client.crt",
+                                  NM_SETTING_802_1X_CK_SCHEME_PATH);
+       nma_cert_chooser_set_key (NMA_CERT_CHOOSER (chooser3),
+                                 "/home/lkundrak/sample-keys/client.key",
+                                 NM_SETTING_802_1X_CK_SCHEME_PATH);
+       nma_cert_chooser_set_key_password (NMA_CERT_CHOOSER (chooser3), "kvokot");
+       gtk_container_add (GTK_CONTAINER (box), chooser3);
+       gtk_widget_show (chooser3);
+
+       gtk_dialog_run (GTK_DIALOG (dialog));
+       gtk_widget_destroy (GTK_WIDGET (dialog));
+       g_object_unref (dialog);
+
+       return 0;
+}


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