From 7fc0ecd1ca7840e71958e62163b27d645c936c25 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Fri, 15 Mar 2013 08:23:43 +0100 Subject: 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 --- tools/tests/test-extract.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'tools/tests') 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); -- cgit v1.1