Skip to content

Commit

Permalink
enhance test-real
Browse files Browse the repository at this point in the history
  • Loading branch information
z4yx committed Oct 30, 2023
1 parent e90f851 commit a4bba30
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
7 changes: 5 additions & 2 deletions test-real/test-gpg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ test_ImportedKeys() {
"10 9,12 9" #secp256k1
"10 1,12 1" #25519
"4 2048,6 2048" #RSA2048
"4 3072,6 3072" #RSA3072
"4 4096,6 4096" #RSA4096
)
for ((i = 0; i < ${#ALGO_PAIRS[@]}; i++)); do
Expand All @@ -188,10 +189,12 @@ test_ImportedKeys() {
}

test_GeneratedKeys() {
ALGO_PAIRS=("2 3" #ECC p-256
ALGO_PAIRS=("1 2048" #RSA2048
"1 3072" #RSA3072
"1 4096" #RSA4096
"2 3" #ECC p-256
"2 4" #ECC p-384
"2 9" #secp256k1
"1 2048" #RSA2048
"2 1" #25519
)
for ((i = 0; i < ${#ALGO_PAIRS[@]}; i++)); do
Expand Down
11 changes: 6 additions & 5 deletions test-real/test-libfido2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export LANG=en_US.UTF8
export TEST_TMP_DIR=/tmp/canokey-libfido2
export USER=`id -nu`
PIN=123456
NUMBER_OF_KEYS=8
NON_TTY="setsid -w"

oneTimeSetUp() {
Expand Down Expand Up @@ -235,7 +236,7 @@ test_DelAllRk() {
test_MC() {
echo $'RelyingPartyID UserID UserName CredID'
>"$TEST_TMP_DIR/rks"
for((i=1;i<=64;i++)); do
for((i=1;i<=$NUMBER_OF_KEYS;i++)); do
local rpid=$(makeRPID $i)
local uname=$(makeUserName $i)
makeCredAndStore "$rpid" "$uname" || return 1
Expand All @@ -244,7 +245,7 @@ test_MC() {
while IFS= read -r line
do
if [[ $nline == 0 ]]; then
assertEquals 'existing rk(s): 64' "$line"
assertEquals "existing rk(s): $NUMBER_OF_KEYS" "$line"
else
local fields=($line)
rpid=$(makeRPID $nline)
Expand All @@ -255,7 +256,7 @@ test_MC() {
}

test_DispName() {
local randSeq=$(seq 1 64 | shuf)
local randSeq=$(seq 1 $NUMBER_OF_KEYS | shuf)
for i in $randSeq; do
local rpid=$(makeRPID $i)
local fields=($(grep $rpid "$TEST_TMP_DIR/rks"))
Expand Down Expand Up @@ -311,7 +312,7 @@ test_LargeBlob() {
}

test_DelRk() {
local randSeq=$(seq 1 64 | shuf)
local randSeq=$(seq 1 $NUMBER_OF_KEYS | shuf)
local nrDel=0
for i in $randSeq; do
local rpid=$(makeRPID $i)
Expand All @@ -324,7 +325,7 @@ test_DelRk() {
FIDO2DelRkByID $credid
sed -i "/$rpid/d" "$TEST_TMP_DIR/rks"
((nrDel++))
if [[ $nrDel == 1 || $nrDel == 2 || $nrDel == 10 || $nrDel == 64 ]];then
if [[ $nrDel == 1 || $nrDel == 2 || $nrDel == 10 || $nrDel == $NUMBER_OF_KEYS ]];then
compareAllRk || return 1
fi
done
Expand Down
2 changes: 1 addition & 1 deletion test-real/test-piv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ test_FactoryReset() {
test_FillData() {
openssl req -x509 -newkey rsa:2048 -keyout $TEST_TMP_DIR/key.pem -out $TEST_TMP_DIR/cert.pem -days 365 -nodes -subj "/CN=www.example.com"
assertEquals 'openssl gen key' 0 $?
for s in 9a 9c 9d 9e; do
for s in 9a 9c 9d 9e 82 83; do
PIVImportKeyCert $s $TEST_TMP_DIR/key.pem ../test-via-pcsc/long-cert.pem
assertEquals 'import-key' 0 $?
done
Expand Down

0 comments on commit a4bba30

Please sign in to comment.