# #
#############################################################################*/
-#include "../testsuite.h"
+#include <string.h>
#include <pakfire/key.h>
+#include <pakfire/util.h>
+#include "../testsuite.h"
#include "key.h"
#include "pakfire.h"
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);
}