aboutsummaryrefslogtreecommitdiff
path: root/tests/agent-pkcs11.testscript
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-10-15 21:08:04 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-10-17 15:02:42 +0300
commitde91921561092689369b56c54950474e0a86e66f (patch)
treea9949058021d911db1106b1a2e4d9e0e9281de16 /tests/agent-pkcs11.testscript
parentfb65c93daaf369157bd712f2c4c20161c4840b94 (diff)
Add implementation
Diffstat (limited to 'tests/agent-pkcs11.testscript')
-rw-r--r--tests/agent-pkcs11.testscript71
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/agent-pkcs11.testscript b/tests/agent-pkcs11.testscript
new file mode 100644
index 0000000..de7ecf2
--- /dev/null
+++ b/tests/agent-pkcs11.testscript
@@ -0,0 +1,71 @@
+# file : tests/agent-pkcs11.testscript
+# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
+: args
+:
+{
+ : none
+ :
+ $* 2>'error: private key URL argument expected' != 0
+
+ : invalid-url
+ :
+ $* 'http://key' 2>'error: invalid PKCS#11 URL: invalid scheme' != 0
+}
+
+: existent-module
+:
+{
+ url = 'pkcs11:?pin-value=123123'
+
+ : failure
+ :
+ $* --simulate failure "$url" 2>>EOE != 0
+ error: no matching private key found
+ EOE
+
+ : success
+ :
+ {
+ $* --simulate success "$url" | set script;
+
+ sed -n -e 's/^OPENSSL_AGENT_PKCS11_PID=(.+);.+;$/\1/p' <"$script" | \
+ set pid;
+
+ echo "$script" >>~"%EOO%";
+ %OPENSSL_AGENT_PKCS11_SOCK=.+; export OPENSSL_AGENT_PKCS11_SOCK;%
+ OPENSSL_AGENT_PKCS11_PID=$pid; export OPENSSL_AGENT_PKCS11_PID;
+ echo Agent pid $pid
+ EOO
+
+ kill -0 "$pid"; # Make sure the agent is running.
+ kill "$pid"; # Signal the agent to terminate.
+ sleep 2; # Wait a bit while the agent is terminating.
+ kill -0 "$pid" 2>! != 0 # Make sure the agent is not running.
+ }
+}
+
+: non-existent-module
+:
+{
+ url = 'pkcs11:?pin-value=123123&module-name=non-existing-pkcs11-module'
+
+ : failure
+ :
+ $* --simulate failure "$url" 2>>EOE != 0
+ error: no matching private key found
+ EOE
+
+ : success
+ :
+ {
+ $* --simulate success "$url" | set script;
+
+ sed -n -e 's/^OPENSSL_AGENT_PKCS11_PID=(.+);.+;$/\1/p' <"$script" | \
+ set pid;
+
+ kill -0 "$pid"; # Make sure the agent is running.
+ kill "$pid" # Signal the agent to terminate.
+ }
+}