Skip to content

Commit

Permalink
FFI: Update tests for better coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
ni4 committed Sep 10, 2024
1 parent 2346488 commit a1c65ea
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/tests/ffi-key-sig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2110,8 +2110,10 @@ TEST_F(rnp_tests, test_ffi_create_key_certification_signature)
rnp_signature_handle_destroy(newsig);
assert_rnp_success(rnp_uid_get_signature_at(uid, 2, &newsig));
assert_rnp_success(rnp_signature_is_valid(newsig, 0));
assert_rnp_failure(rnp_key_signature_set_hash(newsig, hash));
assert_true(check_sig_hash(newsig, hash2));
assert_true(check_sig_type(newsig, "certification (casual)"));
assert_rnp_failure(rnp_key_signature_set_trust_level(newsig, 1, 60));
assert_rnp_success(rnp_signature_get_trust_level(newsig, &level, &amount));
assert_int_equal(level, 1);
assert_int_equal(amount, 120);
Expand Down Expand Up @@ -2308,50 +2310,61 @@ TEST_F(rnp_tests, test_ffi_key_self_certification_features)
uint32_t now = ::time(NULL);
assert_rnp_failure(rnp_signature_get_creation(NULL, &check));
assert_rnp_failure(rnp_signature_get_creation(newsig, NULL));
assert_rnp_failure(rnp_key_signature_set_creation(newsig, 0));
assert_rnp_success(rnp_signature_get_creation(newsig, &check));
assert_true(check >= now - 10);
assert_rnp_failure(rnp_signature_get_key_expiration(NULL, &check));
assert_rnp_failure(rnp_signature_get_key_expiration(newsig, NULL));
assert_rnp_failure(rnp_key_signature_set_key_expiration(newsig, 10000));
assert_rnp_success(rnp_signature_get_key_expiration(newsig, &check));
assert_int_equal(check, 0);
assert_rnp_failure(rnp_signature_get_primary_uid(NULL, &primary));
assert_rnp_failure(rnp_signature_get_primary_uid(newsig, NULL));
assert_rnp_failure(rnp_key_signature_set_primary_uid(newsig, true));
assert_rnp_success(rnp_signature_get_primary_uid(newsig, &primary));
assert_false(primary);
char *strcheck = NULL;
assert_rnp_failure(rnp_signature_get_key_server(NULL, &strcheck));
assert_rnp_failure(rnp_signature_get_key_server(newsig, NULL));
assert_rnp_failure(rnp_key_signature_set_key_server(newsig, "server"));
assert_rnp_success(rnp_signature_get_key_server(newsig, &strcheck));
assert_string_equal(strcheck, "");
rnp_buffer_destroy(strcheck);
assert_rnp_failure(rnp_signature_get_features(NULL, &check));
assert_rnp_failure(rnp_signature_get_features(newsig, NULL));
assert_rnp_failure(rnp_key_signature_set_features(newsig, features));
assert_rnp_success(rnp_signature_get_features(newsig, &check));
assert_int_equal(check, 0);
assert_rnp_failure(rnp_signature_get_key_flags(NULL, &check));
assert_rnp_failure(rnp_signature_get_key_flags(newsig, NULL));
assert_rnp_failure(rnp_key_signature_set_key_flags(newsig, RNP_KEY_USAGE_CERTIFY));
assert_rnp_success(rnp_signature_get_features(newsig, &check));
assert_int_equal(check, 0);
assert_rnp_failure(rnp_signature_get_key_server_prefs(NULL, &check));
assert_rnp_failure(rnp_signature_get_key_server_prefs(newsig, NULL));
assert_rnp_failure(
rnp_key_signature_set_key_server_prefs(newsig, RNP_KEY_SERVER_NO_MODIFY));
assert_rnp_success(rnp_signature_get_key_server_prefs(newsig, &check));
assert_int_equal(check, 0);
assert_rnp_failure(rnp_signature_get_preferred_alg_count(NULL, &count));
assert_rnp_failure(rnp_signature_get_preferred_alg_count(newsig, NULL));
assert_rnp_failure(rnp_key_signature_add_preferred_alg(newsig, RNP_ALGNAME_AES_256));
assert_rnp_success(rnp_signature_get_preferred_alg_count(newsig, &count));
assert_int_equal(count, 0);
assert_rnp_failure(rnp_signature_get_preferred_alg(NULL, 0, &alg));
assert_rnp_failure(rnp_signature_get_preferred_alg(newsig, 0, NULL));
assert_rnp_failure(rnp_signature_get_preferred_alg(newsig, 0, &alg));
assert_rnp_failure(rnp_signature_get_preferred_hash_count(NULL, &count));
assert_rnp_failure(rnp_signature_get_preferred_hash_count(newsig, NULL));
assert_rnp_failure(rnp_key_signature_add_preferred_hash(newsig, RNP_ALGNAME_SHA512));
assert_rnp_success(rnp_signature_get_preferred_hash_count(newsig, &count));
assert_int_equal(count, 0);
assert_rnp_failure(rnp_signature_get_preferred_hash(NULL, 0, &alg));
assert_rnp_failure(rnp_signature_get_preferred_hash(newsig, 0, NULL));
assert_rnp_failure(rnp_signature_get_preferred_hash(newsig, 0, &alg));
assert_rnp_failure(rnp_signature_get_preferred_zalg_count(NULL, &count));
assert_rnp_failure(rnp_signature_get_preferred_zalg_count(newsig, NULL));
assert_rnp_failure(rnp_key_signature_add_preferred_zalg(newsig, RNP_ALGNAME_BZIP2));
assert_rnp_success(rnp_signature_get_preferred_zalg_count(newsig, &count));
assert_int_equal(count, 0);
assert_rnp_failure(rnp_signature_get_preferred_zalg(NULL, 0, &alg));
Expand Down

0 comments on commit a1c65ea

Please sign in to comment.