Refactor tests

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos
2023-10-09 00:34:50 +02:00
parent cb1bba4f13
commit c44d7db4e1
5 changed files with 102 additions and 97 deletions

View File

@@ -4,17 +4,20 @@ source ./tests/scripts/func.sh
reset
# Change SO-PIN
echo -n " Test SO-PIN change..."
pkcs11-tool --login --login-type so --so-pin 3537363231383830 --change-pin --new-pin 0123456789012345 > /dev/null 2>&1
test $? -eq 0 && echo -n "." || exit $?
pkcs11-tool --login --login-type so --so-pin 0123456789012345 --change-pin --new-pin 3537363231383830 > /dev/null 2>&1
test $? -eq 0 && echo -n "." || exit $?
test $? -eq 0 && echo -e ".\t${OK}" || exit $?
# Change PIN
echo -n " Test PIN change..."
pkcs11-tool --login --pin 648219 --change-pin --new-pin 123456 > /dev/null 2>&1
test $? -eq 0 && echo -n "." || exit $?
test $? -eq 0 && echo -e ".\t${OK}" || exit $?
# Reset PIN
echo -n " Test PIN reset..."
pkcs11-tool --login --login-type so --so-pin 3537363231383830 --init-pin --new-pin 648219 > /dev/null 2>&1
test $? -eq 0 && echo -n "." || exit $?
@@ -23,9 +26,10 @@ pkcs11-tool --login --pin 648219 --change-pin --new-pin 123456 > /dev/null 2>&1
test $? -eq 0 && echo -n "." || exit $?
pkcs11-tool --login --pin 123456 --change-pin --new-pin 648219 > /dev/null 2>&1
test $? -eq 0 && echo -n "." || exit $?
test $? -eq 0 && echo -e ".\t${OK}" || exit $?
# Wrong PIN (1st and 2nd PIN_INCORRECT, 3rd PIN_LOCKED)
echo -n " Test wrong PIN attempts..."
e=$(pkcs11-tool --login --pin 123456 -I 2>&1)
test $? -eq 1 && echo -n "." || exit $?
grep -q CKR_PIN_INCORRECT <<< $e && echo -n "." || exit $?
@@ -34,11 +38,12 @@ test $? -eq 1 && echo -n "." || exit $?
grep -q CKR_PIN_INCORRECT <<< $e && echo -n "." || exit $?
e=$(pkcs11-tool --login --pin 123456 -I 2>&1)
test $? -eq 1 && echo -n "." || exit $?
grep -q CKR_PIN_LOCKED <<< $e && echo -n "." || exit $?
grep -q CKR_PIN_LOCKED <<< $e && echo -e "\t${OK}" || exit $?
# Reset PIN
echo -n " Test restore PIN..."
pkcs11-tool --login --login-type so --so-pin 3537363231383830 --init-pin --new-pin 648219 > /dev/null 2>&1
test $? -eq 0 && echo -n "." || exit $?
pkcs11-tool --login --pin 648219 -I > /dev/null 2>&1
test $? -eq 0 && echo -n "." || exit $?
test $? -eq 0 && echo -e "\t${OK}" || exit $?