From: Michael Tremer Date: Thu, 30 Nov 2017 11:59:07 +0000 (+0100) Subject: testsuite: Add tests to verify imported key and export a key X-Git-Tag: 0.9.28~1285^2~1238 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=18557c084167da8800c10b52b1be661690d71606;p=pakfire.git testsuite: Add tests to verify imported key and export a key Signed-off-by: Michael Tremer --- diff --git a/tests/libpakfire/key.c b/tests/libpakfire/key.c index 274796594..6ee8ef3df 100644 --- a/tests/libpakfire/key.c +++ b/tests/libpakfire/key.c @@ -18,10 +18,12 @@ # # #############################################################################*/ -#include "../testsuite.h" +#include #include +#include +#include "../testsuite.h" #include "key.h" #include "pakfire.h" @@ -69,16 +71,43 @@ int test_import(const test_t* t) { assert_return(keys[0] != NULL, EXIT_FAILURE); assert_return(keys[1] == NULL, EXIT_FAILURE); + // Get the imported key + key = *keys; + + // Check the fingerprint + const char* fingerprint = pakfire_key_get_fingerprint(key); + assert_return(strcmp(fingerprint, TEST_KEY_FINGERPRINT) == 0, EXIT_FAILURE); + + pakfire_unref(pakfire); + + return EXIT_SUCCESS; +} + +int test_export(const test_t* t) { + Pakfire pakfire = init_pakfire(); + if (!pakfire) + return EXIT_FAILURE; + + PakfireKey key = pakfire_key_get(pakfire, TEST_KEY_FINGERPRINT); + assert_return(key, EXIT_FAILURE); + + char* data = pakfire_key_export(key, 0); + assert_return(data, EXIT_FAILURE); + pakfire_free(data); + + pakfire_unref(pakfire); + return EXIT_SUCCESS; } int main(int argc, char** argv) { testsuite_init(); - testsuite_t* ts = testsuite_create(2); + testsuite_t* ts = testsuite_create(3); testsuite_add_test(ts, "test_init", test_init); testsuite_add_test(ts, "test_import", test_import); + testsuite_add_test(ts, "test_export", test_export); return testsuite_run(ts); }