-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add list-profiles sub-command to p11-kit cmd tool #500
Add list-profiles sub-command to p11-kit cmd tool #500
Conversation
0d463c2
to
4d65473
Compare
4d65473
to
21a59d8
Compare
9d222e8
to
4c411fa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this PR really deserves a test case. The below is what I used for testing it locally, but ideally there should be a test integrated into the test suite:
- Modify p11-kit/mock-module-ep.c
diff --git a/p11-kit/mock-module-ep.c b/p11-kit/mock-module-ep.c
index 4324433..4845dcd 100644
--- a/p11-kit/mock-module-ep.c
+++ b/p11-kit/mock-module-ep.c
@@ -39,6 +39,14 @@
#include "mock.h"
+static CK_RV
+override_initialize (CK_VOID_PTR init_args)
+{
+ CK_RV rv = mock_C_Initialize (init_args);
+ mock_module_add_profile (MOCK_SLOT_ONE_ID, CKP_PUBLIC_CERTIFICATES_TOKEN);
+ return rv;
+}
+
#ifdef OS_WIN32
__declspec(dllexport)
#endif
@@ -47,6 +55,7 @@ C_GetFunctionList (CK_FUNCTION_LIST_PTR_PTR list)
{
mock_module_init ();
mock_module.C_GetFunctionList = C_GetFunctionList;
+ mock_module.C_Initialize = override_initialize;
if (list == NULL)
return CKR_ARGUMENTS_BAD;
*list = &mock_module;
- Build
meson setup _build -Dprefix=/usr
meson compile -C _build
- Copy
mock-one.so
andone.module
cp _build/p11-kit/mock-one.so /usr/lib64/pkcs11
cp p11-kit/fixtures/system-modules/one.module /usr/share/p11-kit/modules
- Run
p11-kit list-profiles
_build/p11-kit/p11-kit list-profiles 'pkcs11:model=TEST%20MODEL;manufacturer=TEST%20MANUFACTURER;serial=TEST%20SERIAL;token=TEST%20LABEL'
4c411fa
to
0bcaf0c
Compare
One way to test this would be to create a separate |
I thought that I might do it similar to test-iter where I would include the list-profiles.c and supply my own argv argc to the p11_kit_list_profiles, then I would redirect the stdout through pipe and read whether it contains correct profiles. |
I'm not sure if it makes sense to test commands in C rather than simple shell scripts, given we intend to add more subcommands (e.g., #394). With shell script, you can simply diff the output against the expected one. |
c33bfb9
to
f22d207
Compare
7b4dcde
to
1a77393
Compare
Signed-off-by: Zoltan Fridrich <[email protected]>
Signed-off-by: Zoltan Fridrich <[email protected]>
1a77393
to
877dadc
Compare
Adds list-profiles command for listing profiles that are supported by a token
usage: p11-kit list-profiles pkcs11:token