[seahorse/wip/hkp-test: 3/3] pgp: Add test for LDAP source
- From: Niels De Graef <nielsdg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seahorse/wip/hkp-test: 3/3] pgp: Add test for LDAP source
- Date: Sun, 21 Mar 2021 18:25:44 +0000 (UTC)
commit 9cd3015233324e23b50009629e166e7d0067d19d
Author: Niels De Graef <nielsdegraef gmail com>
Date: Sun Mar 21 19:24:52 2021 +0100
pgp: Add test for LDAP source
Let's start very basic, by just testing if the ..._valid_uri() function
works.
pgp/meson.build | 4 ++++
pgp/test-ldap-source.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+)
---
diff --git a/pgp/meson.build b/pgp/meson.build
index 752b2dfe..3576596d 100644
--- a/pgp/meson.build
+++ b/pgp/meson.build
@@ -105,6 +105,10 @@ if get_option('hkp-support')
test_names += 'hkp-source'
endif
+if get_option('ldap-support')
+ test_names += 'ldap-source'
+endif
+
foreach _test : test_names
test_bin = executable(_test,
files('test-@0@.c'.format(_test)),
diff --git a/pgp/test-ldap-source.c b/pgp/test-ldap-source.c
new file mode 100644
index 00000000..4aaa23b4
--- /dev/null
+++ b/pgp/test-ldap-source.c
@@ -0,0 +1,49 @@
+/*
+ * Seahorse
+ *
+ * Copyright (C) 2021 Niels De Graef
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#include "seahorse-ldap-source.h"
+#include "seahorse-pgp-key.h"
+#include "seahorse-pgp-uid.h"
+
+#include <glib.h>
+
+static void
+test_ldap_is_valid_uri (void)
+{
+ g_assert_true (seahorse_ldap_is_valid_uri ("ldap://keyserver.pgp.com"));
+
+ /* Invalid URL */
+ g_assert_false (seahorse_ldap_is_valid_uri ("test"));
+
+ /* Missing scheme */
+ g_assert_false (seahorse_ldap_is_valid_uri ("keyserver.pgp.com"));
+
+ /* Wrong scheme */
+ g_assert_false (seahorse_ldap_is_valid_uri ("hkp://keys.openpgp.org"));
+}
+
+int
+main (int argc, char **argv)
+{
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/ldap/valid-uri", test_ldap_is_valid_uri);
+
+ return g_test_run ();
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]