]> git.ipfire.org Git - people/ms/pakfire.git/commitdiff
tests: keys are anchored to the context and no longer Pakfire
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 1 Nov 2023 14:33:50 +0000 (14:33 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 1 Nov 2023 14:33:50 +0000 (14:33 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
tests/libpakfire/key.c

index 54b309c83305b507ad2775c22e0c8e46093797a2..c6ea5134ae82f34451b019c68525aed12029d9cf 100644 (file)
@@ -34,11 +34,11 @@ static int test_generate(const struct test* t) {
        int r = EXIT_FAILURE;
 
        // Try to call pakfire_key_generate() with some invalid inputs
-       ASSERT_ERRNO(pakfire_key_generate(&key, t->pakfire,
+       ASSERT_ERRNO(pakfire_key_generate(&key, t->ctx,
                PAKFIRE_KEY_ALGO_NULL, "Key 1"), EINVAL);
 
        // Generate a new key using ed25519
-       ASSERT_SUCCESS(pakfire_key_generate(&key, t->pakfire,
+       ASSERT_SUCCESS(pakfire_key_generate(&key, t->ctx,
                PAKFIRE_KEY_ALGO_ED25519, "Key 2"));
 
        // Write the public key to the console
@@ -69,7 +69,7 @@ static int test_sign_and_verify(const struct test* t) {
        ASSERT(f = test_mktemp(NULL));
 
        // Generate a new key using ed25519
-       ASSERT_SUCCESS(pakfire_key_generate(&key, t->pakfire,
+       ASSERT_SUCCESS(pakfire_key_generate(&key, t->ctx,
                PAKFIRE_KEY_ALGO_ED25519, "Key 1"));
 
        // Write the public key to the console
@@ -108,7 +108,7 @@ static int test_import_public(const struct test* t) {
        ASSERT(f = fopen(TEST_DATA_DIR "/keys/key1.pub", "r"));
 
        // Try to import the key
-       ASSERT_SUCCESS(pakfire_key_import(&key, t->pakfire, f));
+       ASSERT_SUCCESS(pakfire_key_import(&key, t->ctx, f));
 
        // Write the imported key to the console
        ASSERT_SUCCESS(pakfire_key_export(key, stdout, PAKFIRE_KEY_EXPORT_MODE_PUBLIC));
@@ -134,7 +134,7 @@ static int test_import_secret(const struct test* t) {
        ASSERT(f = fopen(TEST_DATA_DIR "/keys/key1.sec", "r"));
 
        // Try to import the key
-       ASSERT_SUCCESS(pakfire_key_import(&key, t->pakfire, f));
+       ASSERT_SUCCESS(pakfire_key_import(&key, t->ctx, f));
 
        // Write the imported key to the console
        ASSERT_SUCCESS(pakfire_key_export(key, stdout, PAKFIRE_KEY_EXPORT_MODE_PRIVATE));
@@ -152,10 +152,10 @@ FAIL:
 }
 
 int main(int argc, const char* argv[]) {
-       testsuite_add_test(test_generate, TEST_WANTS_PAKFIRE);
-       testsuite_add_test(test_sign_and_verify, TEST_WANTS_PAKFIRE);
-       testsuite_add_test(test_import_public, TEST_WANTS_PAKFIRE);
-       testsuite_add_test(test_import_secret, TEST_WANTS_PAKFIRE);
+       testsuite_add_test(test_generate, 0);
+       testsuite_add_test(test_sign_and_verify, 0);
+       testsuite_add_test(test_import_public, 0);
+       testsuite_add_test(test_import_secret, 0);
 
        return testsuite_run(argc, argv);
 }