diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2014-07-04 15:40:58 +0200 |
---|---|---|
committer | Stef Walter <stef@thewalter.net> | 2014-07-04 15:51:59 +0200 |
commit | 840ec0f54daeb7c3bc37e22b6ec09ea7cfede868 (patch) | |
tree | fdfa86b776a5b2f8fd2de84bc26cf70736de3a86 | |
parent | d8c064dff11af8537d1c228927c9da82cb6b60e4 (diff) |
Added test for non-null values in empty ID and label URI parts
-rw-r--r-- | p11-kit/tests/test-uri.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/p11-kit/tests/test-uri.c b/p11-kit/tests/test-uri.c index f514f7a..b6de7ad 100644 --- a/p11-kit/tests/test-uri.c +++ b/p11-kit/tests/test-uri.c @@ -159,6 +159,70 @@ test_uri_parse_with_label_and_klass (void) } static void +test_uri_parse_with_empty_label (void) +{ + CK_ATTRIBUTE_PTR attr; + P11KitUri *uri; + int ret; + + uri = p11_kit_uri_new (); + assert_ptr_not_null (uri); + + ret = p11_kit_uri_parse ("pkcs11:object=;object-type=cert", P11_KIT_URI_FOR_ANY, uri); + assert_num_eq (P11_KIT_URI_OK, ret); + + attr = p11_kit_uri_get_attribute (uri, CKA_LABEL); + assert_ptr_not_null (attr); + + p11_kit_uri_free (uri); + + /* really empty */ + + uri = p11_kit_uri_new (); + assert_ptr_not_null (uri); + + ret = p11_kit_uri_parse ("pkcs11:object-type=cert", P11_KIT_URI_FOR_ANY, uri); + assert_num_eq (P11_KIT_URI_OK, ret); + + attr = p11_kit_uri_get_attribute (uri, CKA_LABEL); + assert (attr == NULL); + + p11_kit_uri_free (uri); +} + +static void +test_uri_parse_with_empty_id (void) +{ + CK_ATTRIBUTE_PTR attr; + P11KitUri *uri; + int ret; + + uri = p11_kit_uri_new (); + assert_ptr_not_null (uri); + + ret = p11_kit_uri_parse ("pkcs11:id=;object-type=cert", P11_KIT_URI_FOR_ANY, uri); + assert_num_eq (P11_KIT_URI_OK, ret); + + attr = p11_kit_uri_get_attribute (uri, CKA_ID); + assert_ptr_not_null (attr); + + p11_kit_uri_free (uri); + + /* really empty */ + + uri = p11_kit_uri_new (); + assert_ptr_not_null (uri); + + ret = p11_kit_uri_parse ("pkcs11:object-type=cert", P11_KIT_URI_FOR_ANY, uri); + assert_num_eq (P11_KIT_URI_OK, ret); + + attr = p11_kit_uri_get_attribute (uri, CKA_ID); + assert (attr == NULL); + + p11_kit_uri_free (uri); +} + +static void test_uri_parse_with_id (void) { CK_ATTRIBUTE_PTR attr; @@ -1203,6 +1267,8 @@ main (int argc, p11_test (test_uri_parse, "/uri/test_uri_parse"); p11_test (test_uri_parse_bad_scheme, "/uri/test_uri_parse_bad_scheme"); p11_test (test_uri_parse_with_label, "/uri/test_uri_parse_with_label"); + p11_test (test_uri_parse_with_empty_label, "/uri/test_uri_parse_with_empty_label"); + p11_test (test_uri_parse_with_empty_id, "/uri/test_uri_parse_with_empty_id"); p11_test (test_uri_parse_with_label_and_klass, "/uri/test_uri_parse_with_label_and_klass"); p11_test (test_uri_parse_with_id, "/uri/test_uri_parse_with_id"); p11_test (test_uri_parse_with_bad_string_encoding, "/uri/test_uri_parse_with_bad_string_encoding"); |