aboutsummaryrefslogtreecommitdiffstats
path: root/src/charon/plugins/unit_tester
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2008-04-02 12:25:14 +0000
committerMartin Willi <martin@strongswan.org>2008-04-02 12:25:14 +0000
commit489e3da0eab6c0fb829b2954c01a3300399c4346 (patch)
treed34d0ab91ccb0c34a3e2f1f23bde490c8733fd19 /src/charon/plugins/unit_tester
parente29ebcb1afee8acb3ae593d99f0323c2d9ee9b4b (diff)
downloadstrongswan-489e3da0eab6c0fb829b2954c01a3300399c4346.tar.bz2
strongswan-489e3da0eab6c0fb829b2954c01a3300399c4346.tar.xz
updated mediation database to public key authentication
added mysql table definition, test data testcase
Diffstat (limited to 'src/charon/plugins/unit_tester')
-rw-r--r--src/charon/plugins/unit_tester/Makefile.am3
-rw-r--r--src/charon/plugins/unit_tester/tests.h3
-rw-r--r--src/charon/plugins/unit_tester/tests/test_med_db.c52
3 files changed, 56 insertions, 2 deletions
diff --git a/src/charon/plugins/unit_tester/Makefile.am b/src/charon/plugins/unit_tester/Makefile.am
index 9d9f4d79a..8d0070ac9 100644
--- a/src/charon/plugins/unit_tester/Makefile.am
+++ b/src/charon/plugins/unit_tester/Makefile.am
@@ -13,6 +13,7 @@ libcharon_unit_tester_la_SOURCES = unit_tester.c unit_tester.h \
tests/test_mysql.c \
tests/test_sqlite.c \
tests/test_mutex.c \
- tests/test_rsa_gen.c
+ tests/test_rsa_gen.c \
+ tests/test_med_db.c
libcharon_unit_tester_la_LDFLAGS = -module
diff --git a/src/charon/plugins/unit_tester/tests.h b/src/charon/plugins/unit_tester/tests.h
index a14946a42..18bd58c83 100644
--- a/src/charon/plugins/unit_tester/tests.h
+++ b/src/charon/plugins/unit_tester/tests.h
@@ -31,4 +31,5 @@ DEFINE_TEST("MySQL operations", test_mysql, FALSE)
DEFINE_TEST("SQLite operations", test_sqlite, FALSE)
DEFINE_TEST("mutex primitive", test_mutex, FALSE)
DEFINE_TEST("RSA key generation", test_rsa_gen, FALSE)
-DEFINE_TEST("RSA subjectPublicKeyInfo loading", test_rsa_load_any, TRUE)
+DEFINE_TEST("RSA subjectPublicKeyInfo loading", test_rsa_load_any, FALSE)
+DEFINE_TEST("Mediation database key fetch", test_med_db, TRUE)
diff --git a/src/charon/plugins/unit_tester/tests/test_med_db.c b/src/charon/plugins/unit_tester/tests/test_med_db.c
new file mode 100644
index 000000000..7ce280861
--- /dev/null
+++ b/src/charon/plugins/unit_tester/tests/test_med_db.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2008 Martin Willi
+ * Hochschule fuer Technik Rapperswil
+ *
+ * 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. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * 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.
+ */
+
+#include <library.h>
+#include <daemon.h>
+#include <utils/enumerator.h>
+
+#include <unistd.h>
+
+/*******************************************************************************
+ * fetch public key from mediation database
+ ******************************************************************************/
+
+bool test_med_db()
+{
+ char keyid_buf[] = {
+ 0xed,0x90,0xe6,0x4f,0xec,0xa2,0x1f,0x4b,
+ 0x68,0x97,0x99,0x24,0x22,0xe0,0xde,0x21,
+ 0xb9,0xd6,0x26,0x29
+ };
+ chunk_t keyid = chunk_from_buf(keyid_buf);
+ identification_t *id, *found;
+ enumerator_t *enumerator;
+ auth_info_t *auth;
+ public_key_t *public;
+ bool good = FALSE;
+
+ id = identification_create_from_encoding(ID_KEY_ID, keyid);
+ enumerator = charon->credentials->create_public_enumerator(
+ charon->credentials, KEY_ANY, id, NULL);
+ while (enumerator->enumerate(enumerator, &public, &auth))
+ {
+ found = public->get_id(public, ID_PUBKEY_SHA1);
+ good = chunk_equals(id->get_encoding(id), found->get_encoding(found));
+ }
+ enumerator->destroy(enumerator);
+ id->destroy(id);
+ return TRUE;
+}
+