Add store binary data tests.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos 2023-10-09 21:15:51 +02:00
parent 3057aba041
commit 2ecfff0ebb
No known key found for this signature in database
GPG Key ID: C0095B7870A4CCD3
2 changed files with 35 additions and 0 deletions

View File

@ -28,3 +28,10 @@ test $? -eq 0 || {
echo -e "\t${FAIL}"
exit 1
}
echo "==== Test binary storage ===="
./tests/scripts/store_binary.sh
test $? -eq 0 || {
echo -e "\t${FAIL}"
exit 1
}

28
tests/scripts/store_binary.sh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/bash
source ./tests/scripts/func.sh
reset
test $? -eq 0 || exit $?
TEST_DATA="Pico HSM is awesome!"
echo 'Pico HSM is awesome!' > data
echo -n " Test public binary storage..."
pkcs11-tool --pin 648219 --write-object test --type data --id 1 --label 'test1' > /dev/null 2>&1
test $? -eq 0 && echo -n "." || exit $?
e=$(pkcs11-tool --read-object --type data --label 'test1' 2>&1)
test $? -eq 0 && echo -n "." || exit $?
grep -q "${TEST_DATA}" <<< $e && echo -e ".\t${OK}" || exit $?
pkcs11-tool --pin 648219 --delete-object --type data --label 'test1' > /dev/null 2>&1
echo -n " Test private binary storage..."
pkcs11-tool --pin 648219 --write-object test --type data --id 1 --label 'test1' --private > /dev/null 2>&1
test $? -eq 0 && echo -n "." || exit $?
e=$(pkcs11-tool --read-object --type data --label 'test1' --pin 648219 2>&1)
test $? -eq 0 && echo -n "." || exit $?
grep -q "${TEST_DATA}" <<< $e && echo -n "." || exit $?
e=$(pkcs11-tool --read-object --type data --label 'test1' 2>&1)
test $? -eq 1 && echo -n "." || exit $?
grep -q "error: object not found" <<< $e && echo -e ".\t${OK}" || exit $?
pkcs11-tool --pin 648219 --delete-object --type data --label 'test1' > /dev/null 2>&1