From 480cf9fe29861ca45d37450c243be4cd586830f9 Mon Sep 17 00:00:00 2001 From: Patrick Uiterwijk Date: Thu, 3 Dec 2020 16:45:18 +0000 Subject: [PATCH] Add test that no use_policy is not fatal yet Signed-off-by: Patrick Uiterwijk --- tests/test_policy | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_policy b/tests/test_policy index 6d42e41..97591b9 100755 --- a/tests/test_policy +++ b/tests/test_policy @@ -10,9 +10,10 @@ cargo build || (echo "Failed to build"; exit 1) ../../clevis-pin-tpm2-signtool/clevis-pin-tpm2-signtool policy_working.json ../../clevis-pin-tpm2-signtool/clevis-pin-tpm2-signtool policy_broken.json ) -echo "Working: with Policy" | ./target/debug/clevis-pin-tpm2 encrypt '{"policy_pubkey_path":"./tests/publickey.json", "policy_ref": "", "policy_path": "./tests/policy_working.json"}' | ./target/debug/clevis-pin-tpm2 decrypt +echo "Working: with Policy" | ./target/debug/clevis-pin-tpm2 encrypt '{"use_policy": true, "policy_pubkey_path":"./tests/publickey.json", "policy_ref": "", "policy_path": "./tests/policy_working.json"}' | ./target/debug/clevis-pin-tpm2 decrypt +echo "Working: with Policy (no use_policy)" | ./target/debug/clevis-pin-tpm2 encrypt '{"policy_pubkey_path":"./tests/publickey.json", "policy_ref": "", "policy_path": "./tests/policy_working.json"}' | ./target/debug/clevis-pin-tpm2 decrypt # Negative test (non-valid policy) -token=$(echo Failed | ./target/debug/clevis-pin-tpm2 encrypt '{"policy_pubkey_path":"./tests/publickey.json", "policy_ref": "", "policy_path": "./tests/policy_broken.json"}') +token=$(echo Failed | ./target/debug/clevis-pin-tpm2 encrypt '{"use_policy": true, "policy_pubkey_path":"./tests/publickey.json", "policy_ref": "", "policy_path": "./tests/policy_broken.json"}') res=$(echo "$token" | ./target/debug/clevis-pin-tpm2 decrypt 2>&1) ret=$? if [ $ret == 0 -a "$res" == "Failed" ]