Add and use keyfile_to_key_id() helper function

When trying to extract the key ID from a key file name, some test code
incorrectly attempts to strip all leading zeros.  This breaks tests when
keys with ID 0 are generated.  Add a new helper shell function,
keyfile_to_key_id(), which properly handles keys with ID 0 and use it in
test code whenever a key ID needs to be extracted from a key file name.
This commit is contained in:
Michał Kępień
2019-06-28 13:11:26 +02:00
parent f895e4aaf2
commit 7d6eaad1bd
13 changed files with 56 additions and 49 deletions

View File

@@ -69,19 +69,19 @@ czoneout=`$SIGNER -Sg -e now+1d -X now+2d -o $czone $cfile 2>&1`
echo_i "signing parent zone"
pzoneout=`$SIGNER -Sg -o $pzone $pfile 2>&1`
czactive=`echo $czsk1 | sed 's/^K.*+005+0*\([0-9]\)/\1/'`
czgenerated=`echo $czsk2 | sed 's/^K.*+005+0*\([0-9]\)/\1/'`
czpublished=`echo $czsk3 | sed 's/^K.*+005+0*\([0-9]\)/\1/'`
czinactive=`echo $czsk4 | sed 's/^K.*+005+0*\([0-9]\)/\1/'`
czpredecessor=`echo $czsk5 | sed 's/^K.*+005+0*\([0-9]\)/\1/'`
czsuccessor=`echo $czsk6 | sed 's/^K.*+005+0*\([0-9]\)/\1/'`
ckactive=`echo $cksk1 | sed 's/^K.*+005+0*\([0-9]\)/\1/'`
ckpublished=`echo $cksk2 | sed 's/^K.*+005+0*\([0-9]\)/\1/'`
ckprerevoke=`echo $cksk3 | sed 's/^K.*+005+0*\([0-9]\)/\1/'`
ckrevoked=`echo $cksk4 | sed 's/.*+005+0*\([0-9]*\)$/\1/'`
czactive=$(keyfile_to_key_id $czsk1)
czgenerated=$(keyfile_to_key_id $czsk2)
czpublished=$(keyfile_to_key_id $czsk3)
czinactive=$(keyfile_to_key_id $czsk4)
czpredecessor=$(keyfile_to_key_id $czsk5)
czsuccessor=$(keyfile_to_key_id $czsk6)
ckactive=$(keyfile_to_key_id $cksk1)
ckpublished=$(keyfile_to_key_id $cksk2)
ckprerevoke=$(keyfile_to_key_id $cksk3)
ckrevoked=$(keyfile_to_key_id $cksk4)
pzid=`echo $pzsk | sed 's/^K.*+005+0*\([0-9]\)/\1/'`
pkid=`echo $pksk | sed 's/^K.*+005+0*\([0-9]\)/\1/'`
pzid=$(keyfile_to_key_id $pzsk)
pkid=$(keyfile_to_key_id $pksk)
echo_i "checking dnssec-signzone output matches expectations"
ret=0