From 2862a8a5b78e03c772946a50e05e9ad00f627184 Mon Sep 17 00:00:00 2001 From: Nickolay Olshevsky Date: Fri, 2 Feb 2024 13:44:03 +0200 Subject: [PATCH] Update test for rnp_locate_key() with some edge cases. --- src/tests/ffi.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/tests/ffi.cpp b/src/tests/ffi.cpp index 0eee2f6e8..214faf2b6 100644 --- a/src/tests/ffi.cpp +++ b/src/tests/ffi.cpp @@ -1457,6 +1457,21 @@ TEST_F(rnp_tests, test_ffi_locate_key) // load our keyrings assert_true(load_keys_gpg(ffi, "data/keyrings/1/pubring.gpg")); + // edge cases + { + rnp_key_handle_t key = NULL; + assert_rnp_failure(rnp_locate_key(NULL, "keyid", "7BC6709B15C23A4A", &key)); + assert_rnp_failure(rnp_locate_key(ffi, NULL, "7BC6709B15C23A4A", &key)); + assert_rnp_failure(rnp_locate_key(ffi, "keyid", NULL, &key)); + assert_rnp_failure(rnp_locate_key(ffi, "keyid", "7BC6709B15C23A4A", NULL)); + assert_rnp_failure(rnp_locate_key(ffi, "wrong", "7BC6709B15C23A4A", &key)); + assert_rnp_failure(rnp_locate_key(ffi, "keyid", "BC6709B15C23A4A", &key)); + assert_rnp_failure(rnp_locate_key(ffi, "keyid", "C6709B15C23A4A", &key)); + assert_rnp_failure( + rnp_locate_key(ffi, "fingerprint", "5A3CBF583AA80A2CCC53AA7BC6709B15C23A4A", &key)); + assert_rnp_failure( + rnp_locate_key(ffi, "grip", "D6A0800A3FACDE0C0EB60B16B3669ED380FDFA", &key)); + } // keyid { static const char *ids[] = {"7BC6709B15C23A4A",