/src/scripts/extract-debuginfo
/src/systemd/*.service
/tests/.data
+/tests/libpakfire/key
/tests/libpakfire/main
/tmp
*.py[co]
src/libpakfire/libpakfire.sym
check_PROGRAMS += \
- tests/libpakfire/main
+ tests/libpakfire/main \
+ tests/libpakfire/key
dist_tests_libpakfire_main_SOURCES = \
tests/libpakfire/main.c
$(TESTSUITE_LDADD) \
$(PAKFIRE_LIBS)
+tests_libpakfire_key_SOURCES = \
+ tests/libpakfire/key.c \
+ tests/libpakfire/key.h
+
+tests_libpakfire_key_CPPFLAGS = \
+ $(TESTSUITE_CPPFLAGS)
+
+tests_libpakfire_key_LDADD = \
+ $(TESTSUITE_LDADD) \
+ $(PAKFIRE_LIBS)
+
# ------------------------------------------------------------------------------
lib_LTLIBRARIES += \
--- /dev/null
+/*#############################################################################
+# #
+# Pakfire - The IPFire package management system #
+# Copyright (C) 2017 Pakfire development team #
+# #
+# 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 3 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 "../testsuite.h"
+
+#include <pakfire/key.h>
+
+#include "key.h"
+#include "pakfire.h"
+
+int test_init(const test_t* t) {
+ Pakfire pakfire = init_pakfire();
+ if (!pakfire)
+ return EXIT_FAILURE;
+
+ // Try loading any keys & delete them all
+ PakfireKey* keys = pakfire_key_list(pakfire);
+ while (keys && *keys) {
+ PakfireKey key = *keys++;
+
+ pakfire_key_delete(key);
+ pakfire_key_unref(key);
+ }
+
+ // Load list of keys again
+ keys = pakfire_key_list(pakfire);
+
+ // Must be empty now
+ assert_return(keys == NULL, EXIT_FAILURE);
+
+ return EXIT_SUCCESS;
+}
+
+int test_import(const test_t* t) {
+ Pakfire pakfire = init_pakfire();
+ if (!pakfire)
+ return EXIT_FAILURE;
+
+ // Try to delete the key just in case it
+ // has been imported before
+ PakfireKey key = pakfire_key_get(pakfire, TEST_KEY_FINGERPRINT);
+ if (key) {
+ pakfire_key_delete(key);
+ pakfire_key_unref(key);
+ }
+
+ // Import a key
+ PakfireKey* keys = pakfire_key_import(pakfire, TEST_KEY_DATA);
+
+ // We should have a list with precisely one key object
+ assert_return(keys, EXIT_FAILURE);
+ assert_return(keys[0] != NULL, EXIT_FAILURE);
+ assert_return(keys[1] == NULL, EXIT_FAILURE);
+
+ return EXIT_SUCCESS;
+}
+
+int main(int argc, char** argv) {
+ testsuite_init();
+
+ testsuite_t* ts = testsuite_create(2);
+
+ testsuite_add_test(ts, "test_init", test_init);
+ testsuite_add_test(ts, "test_import", test_import);
+
+ return testsuite_run(ts);
+}
--- /dev/null
+/*#############################################################################
+# #
+# Pakfire - The IPFire package management system #
+# Copyright (C) 2017 Pakfire development team #
+# #
+# 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 3 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/>. #
+# #
+#############################################################################*/
+
+const char* TEST_KEY_FINGERPRINT = "E63B4976A575A3B2544AC15E726D8B0B0889B04E";
+
+const char* TEST_KEY_DATA = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\n"
+"mQINBE/ndRQBEAC5ykX6wgPdR42ZkTdrcVS9fIACn/n/ed7K/dWlUtANnAtoH27Qp+I/vKy9\n"
+"DwGUjDe5ST8l4td+gzZNwWowTnLr6zULG+dBDPNL1SZrL7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