Improved unit tests coverage
This commit is contained in:
parent
b5ca6cc946
commit
d02d4b2378
11 changed files with 107 additions and 15 deletions
|
@ -3,6 +3,8 @@
|
|||
# exp_internal 1
|
||||
# log_file -noappend ~/expect.log
|
||||
|
||||
# Use `send_log` to print to log file
|
||||
|
||||
set timeout 30
|
||||
|
||||
set bold [exec tput bold]
|
||||
|
|
|
@ -6,6 +6,8 @@ set -o pipefail
|
|||
bold=$(tput bold)
|
||||
normal=$(tput sgr0)
|
||||
|
||||
mkdir -p /tmp/pi
|
||||
|
||||
printf "$bold%s$normal\n" "Please type root password and press enter"
|
||||
read -rs password
|
||||
|
||||
|
@ -22,3 +24,4 @@ expect ./tests/clone.exp
|
|||
expect ./tests/convert-default-to-shamir-2-of-3.exp
|
||||
expect ./tests/convert-shamir-2-of-3-to-default.exp
|
||||
expect ./tests/duplicate.exp
|
||||
expect ./tests/secure-erase.exp
|
||||
|
|
|
@ -5,13 +5,13 @@ source ./test.exp
|
|||
set bip39_mnemonic "online pipe enough dutch decorate want moment scheme rigid enlist blast boat purse sick chalk shop brush all return betray jacket salon abandon retire"
|
||||
set electrum_mnemonic "month pet slice know amused leave now vague palm guess cattle element cross truly auto put among craft repeat van sample nephew sad family"
|
||||
|
||||
test_label "Should create BIP39 mnemonic"
|
||||
test_label "Should format flash drive and create BIP39 mnemonic"
|
||||
|
||||
spawn qr-backup.sh --create-bip39-mnemonic
|
||||
|
||||
expect {
|
||||
-re {Format USB flash drive \(y or n\)\?} {
|
||||
test_send "n\r"
|
||||
test_send "y\r"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,10 @@ expect {
|
|||
}
|
||||
}
|
||||
|
||||
expect {
|
||||
-re {mkfs\.fat 4\.1 \(2017-01-24\)}
|
||||
}
|
||||
|
||||
expect {
|
||||
-re {Creating BIP39 mnemonic…}
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ set short_hash "$new_short_hash"
|
|||
|
||||
source ./tests/helpers/restore.exp
|
||||
|
||||
regsub -all {(\e\(B)?\e\[[0-9]*?m} $restored_secret {} restored_secret
|
||||
regsub -all {\033\[[0-9]*m(\017)?} $restored_secret {} restored_secret
|
||||
regsub -all {\r} $restored_secret {} restored_secret
|
||||
|
||||
if { "$restored_secret" != "$secret" } {
|
||||
|
|
|
@ -119,7 +119,7 @@ expect {
|
|||
|
||||
source ./tests/helpers/shamir-2-of-3-restore.exp
|
||||
|
||||
regsub -all {(\e\(B)?\e\[[0-9]*?m} $restored_secret {} restored_secret
|
||||
regsub -all {\033\[[0-9]*m(\017)?} $restored_secret {} restored_secret
|
||||
regsub -all {\r} $restored_secret {} restored_secret
|
||||
|
||||
if { "$restored_secret" != "$secret" } {
|
||||
|
|
|
@ -83,7 +83,7 @@ expect {
|
|||
|
||||
source ./tests/helpers/restore.exp
|
||||
|
||||
regsub -all {(\e\(B)?\e\[[0-9]*?m} $restored_secret {} restored_secret
|
||||
regsub -all {\033\[[0-9]*m(\017)?} $restored_secret {} restored_secret
|
||||
regsub -all {\r} $restored_secret {} restored_secret
|
||||
|
||||
if { "$restored_secret" != "$secret" } {
|
||||
|
|
|
@ -89,13 +89,13 @@ expect {
|
|||
}
|
||||
}
|
||||
|
||||
test_label "Should format USB flash drive and backup secret showing passphrase"
|
||||
test_label "Should backup secret showing passphrase"
|
||||
|
||||
spawn qr-backup.sh
|
||||
|
||||
expect {
|
||||
-re {Format USB flash drive \(y or n\)\?} {
|
||||
test_send "y\r"
|
||||
test_send "n\r"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,10 +105,6 @@ expect {
|
|||
}
|
||||
}
|
||||
|
||||
expect {
|
||||
-re {mkfs\.fat 4\.1 \(2017-01-24\)}
|
||||
}
|
||||
|
||||
expect {
|
||||
-re {Please type secret and press enter, then ctrl\+d} {
|
||||
test_send "$secret\r"
|
||||
|
@ -191,7 +187,7 @@ expect {
|
|||
}
|
||||
}
|
||||
|
||||
regsub -all {(\e\(B)?\e\[[0-9]*?m} $restored_secret {} restored_secret
|
||||
regsub -all {\033\[[0-9]*m(\017)?} $restored_secret {} restored_secret
|
||||
regsub -all {\r} $restored_secret {} restored_secret
|
||||
|
||||
if { "$restored_secret" != "$secret" } {
|
||||
|
|
|
@ -59,7 +59,7 @@ set short_hash "$new_short_hash"
|
|||
|
||||
source ./tests/helpers/restore.exp
|
||||
|
||||
regsub -all {(\e\(B)?\e\[[0-9]*?m} $restored_secret {} restored_secret
|
||||
regsub -all {\033\[[0-9]*m(\017)?} $restored_secret {} restored_secret
|
||||
regsub -all {\r} $restored_secret {} restored_secret
|
||||
|
||||
if { "$restored_secret" != "$secret" } {
|
||||
|
|
87
how-to-create-encrypted-paper-backup/tests/secure-erase.exp
Normal file
87
how-to-create-encrypted-paper-backup/tests/secure-erase.exp
Normal file
|
@ -0,0 +1,87 @@
|
|||
#!/usr/bin/expect
|
||||
|
||||
source ./test.exp
|
||||
|
||||
test_label "Should secure erase USB flash drive"
|
||||
|
||||
spawn secure-erase.sh
|
||||
|
||||
expect {
|
||||
-re {Secure erase USB flash drive \(y or n\)\?} {
|
||||
test_send "y\r"
|
||||
}
|
||||
}
|
||||
|
||||
expect {
|
||||
-re {Overwriting with random data… \(round 1 of 3\)}
|
||||
}
|
||||
|
||||
expect {
|
||||
-re {\[sudo\] password for pi:} {
|
||||
test_send "$env(password)\r"
|
||||
}
|
||||
}
|
||||
|
||||
expect {
|
||||
-re {dd: error writing '\/dev\/sda1': No space left on device}
|
||||
}
|
||||
|
||||
expect {
|
||||
-re {Overwriting with random data… \(round 2 of 3\)}
|
||||
}
|
||||
|
||||
expect {
|
||||
-re {dd: error writing '\/dev\/sda1': No space left on device}
|
||||
}
|
||||
|
||||
expect {
|
||||
-re {Overwriting with random data… \(round 3 of 3\)}
|
||||
}
|
||||
|
||||
expect {
|
||||
-re {dd: error writing '\/dev\/sda1': No space left on device}
|
||||
}
|
||||
|
||||
expect {
|
||||
-re {Done} {
|
||||
test_ok
|
||||
}
|
||||
}
|
||||
|
||||
test_label "Should secure erase flash drive using single round random overwrite and zero overwrite"
|
||||
|
||||
spawn secure-erase.sh --rounds 1 --zero
|
||||
|
||||
expect {
|
||||
-re {Secure erase USB flash drive \(y or n\)\?} {
|
||||
test_send "y\r"
|
||||
}
|
||||
}
|
||||
|
||||
expect {
|
||||
-re {Overwriting with random data… \(round 1 of 1\)}
|
||||
}
|
||||
|
||||
expect {
|
||||
-re {\[sudo\] password for pi:} {
|
||||
test_send "$env(password)\r"
|
||||
}
|
||||
}
|
||||
|
||||
expect {
|
||||
-re {dd: error writing '\/dev\/sda1': No space left on device}
|
||||
}
|
||||
|
||||
expect {
|
||||
-re {Overwriting with zeros…}
|
||||
}
|
||||
|
||||
expect {
|
||||
-re {dd: error writing '\/dev\/sda1': No space left on device}
|
||||
}
|
||||
|
||||
expect {
|
||||
-re {Done} {
|
||||
test_ok
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@ test_label "Should restore secret using 2-of-3 Shamir Secret Sharing"
|
|||
|
||||
source ./tests/helpers/shamir-2-of-3-restore.exp
|
||||
|
||||
regsub -all {(\e\(B)?\e\[[0-9]*?m} $restored_secret {} restored_secret
|
||||
regsub -all {\033\[[0-9]*m(\017)?} $restored_secret {} restored_secret
|
||||
regsub -all {\r} $restored_secret {} restored_secret
|
||||
|
||||
if { "$restored_secret" != "$secret" } {
|
||||
|
|
|
@ -167,7 +167,7 @@ expect {
|
|||
}
|
||||
}
|
||||
|
||||
regsub -all {(\e\(B)?\e\[[0-9]*?m} $restored_secret {} restored_secret
|
||||
regsub -all {\033\[[0-9]*m(\017)?} $restored_secret {} restored_secret
|
||||
regsub -all {\r} $restored_secret {} restored_secret
|
||||
|
||||
if { "$restored_secret" != "$secret" } {
|
||||
|
|
Loading…
Add table
Reference in a new issue