diff options
author | Stef Walter <stefw@gnome.org> | 2013-03-15 08:23:43 +0100 |
---|---|---|
committer | Stef Walter <stefw@gnome.org> | 2013-03-15 17:34:00 +0100 |
commit | 7fc0ecd1ca7840e71958e62163b27d645c936c25 (patch) | |
tree | 21721a33b2a3ed88daad4a18cbf5d0d130217e94 /tools/tests | |
parent | 58e1e3764250fbda96c5ef7244e891a6be04d4cb (diff) |
extract: --comment option adds comments to PEM bundles
* Placed before the certificate, simple one liner
* No need to put comments in PEM files extracted into
directories, as the file names are already descriptive.
https://bugs.freedesktop.org/show_bug.cgi?id=62029
Diffstat (limited to 'tools/tests')
-rw-r--r-- | tools/tests/test-extract.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tools/tests/test-extract.c b/tools/tests/test-extract.c index 5e2f6fe..69ba764 100644 --- a/tools/tests/test-extract.c +++ b/tools/tests/test-extract.c @@ -91,6 +91,49 @@ test_file_name_for_class (CuTest *tc) p11_extract_info_cleanup (&ex); } +static void +test_comment_for_label (CuTest *tc) +{ + CK_ATTRIBUTE label = { CKA_LABEL, "The Label!", 10 }; + p11_extract_info ex; + char *comment; + + p11_extract_info_init (&ex); + + ex.flags = P11_EXTRACT_COMMENT; + ex.attrs = p11_attrs_build (NULL, &label, NULL); + + comment = p11_extract_info_comment (&ex, true); + CuAssertStrEquals (tc, "# The Label!\n", comment); + free (comment); + + comment = p11_extract_info_comment (&ex, false); + CuAssertStrEquals (tc, "\n# The Label!\n", comment); + free (comment); + + p11_extract_info_cleanup (&ex); +} + +static void +test_comment_not_enabled (CuTest *tc) +{ + CK_ATTRIBUTE label = { CKA_LABEL, "The Label!", 10 }; + p11_extract_info ex; + char *comment; + + p11_extract_info_init (&ex); + + ex.attrs = p11_attrs_build (NULL, &label, NULL); + + comment = p11_extract_info_comment (&ex, true); + CuAssertPtrEquals (tc, NULL, comment); + + comment = p11_extract_info_comment (&ex, false); + CuAssertPtrEquals (tc, NULL, comment); + + p11_extract_info_cleanup (&ex); +} + struct { CK_FUNCTION_LIST module; P11KitIter *iter; @@ -334,6 +377,8 @@ main (void) SUITE_ADD_TEST (suite, test_file_name_for_label); SUITE_ADD_TEST (suite, test_file_name_for_class); + SUITE_ADD_TEST (suite, test_comment_for_label); + SUITE_ADD_TEST (suite, test_comment_not_enabled); SUITE_ADD_TEST (suite, test_info_simple_certificate); SUITE_ADD_TEST (suite, test_info_limit_purposes); SUITE_ADD_TEST (suite, test_info_invalid_purposes); |