Refactored unit tests

This commit is contained in:
Sun Knudsen 2021-04-18 10:06:04 -04:00
parent aaccc14e76
commit 4980788afc
No known key found for this signature in database
GPG key ID: 1FA767862BBD1305
20 changed files with 876 additions and 769 deletions

View file

@ -0,0 +1,63 @@
#!/usr/bin/expect
spawn qr-backup.sh
expect {
-re {Format USB flash drive \(y or n\)\?} {
test_send "n\r"
}
}
expect {
-re {\[sudo\] password for pi:} {
test_send "$env(password)\r"
}
}
expect {
-re {Please type secret and press enter, then ctrl\+d} {
test_send "$secret\r"
test_send "\x04"
}
}
expect {
-re {Please type secret and press enter, then ctrl\+d \(again\)} {
test_send "$secret\r"
test_send "\x04"
}
}
expect {
-re {Please type passphrase and press enter} {
test_send "$passphrase\r"
}
}
expect {
-re {Please type passphrase and press enter \(again\)} {
test_send "$passphrase\r"
}
}
expect {
-re {Show passphrase \(y or n\)\?} {
test_send "n\r"
}
}
expect {
-re {SHA512 short hash: .+?([a-f0-9]{8})} {
set short_hash $expect_out(1,string)
}
}
expect {
-re {Show SHA512 hash as QR code \(y or n\)\?} {
test_send "n\r"
}
}
expect {
-re {Done}
}

View file

@ -0,0 +1,27 @@
#!/usr/bin/expect
spawn qr-restore.sh --images $short_hash.jpg
expect {
-re {\[sudo\] password for pi:} {
test_send "$env(password)\r"
}
}
expect {
-re {Please type passphrase and press enter} {
test_send "$passphrase\r"
}
}
expect {
-re {Show secret \(y or n\)\?} {
test_send "y\r"
}
}
expect {
-re {Secret:\r\n((.|\r\n)+?)\r\nDone} {
set restored_secret $expect_out(1,string)
}
}

View file

@ -0,0 +1,99 @@
#!/usr/bin/expect
spawn qr-backup.sh --shamir-secret-sharing --number-of-shares 3 --share-threshold 2
expect {
-re {Format USB flash drive \(y or n\)\?} {
test_send "n\r"
}
}
expect {
-re {\[sudo\] password for pi:} {
test_send "$env(password)\r"
}
}
expect {
-re {Please type secret and press enter, then ctrl\+d} {
test_send "$secret\r"
test_send "\x04"
}
}
expect {
-re {Please type secret and press enter, then ctrl\+d \(again\)} {
test_send "$secret\r"
test_send "\x04"
}
}
expect {
-re {Please type passphrase and press enter} {
test_send "$passphrase\r"
}
}
expect {
-re {Please type passphrase and press enter \(again\)} {
test_send "$passphrase\r"
}
}
expect {
-re {Show passphrase \(y or n\)\?} {
test_send "n\r"
}
}
expect {
-re {Encrypting secret share 1 of 3…}
}
expect {
-re {SHA512 short hash: .+?([a-f0-9]{8})} {
set short_hash_1 $expect_out(1,string)
}
}
expect {
-re {Show SHA512 hash as QR code \(y or n\)\?} {
test_send "n\r"
}
}
expect {
-re {Encrypting secret share 2 of 3…}
}
expect {
-re {SHA512 short hash: .+?([a-f0-9]{8})} {
set short_hash_2 $expect_out(1,string)
}
}
expect {
-re {Show SHA512 hash as QR code \(y or n\)\?} {
test_send "n\r"
}
}
expect {
-re {Encrypting secret share 3 of 3…}
}
expect {
-re {SHA512 short hash: .+?([a-f0-9]{8})} {
set short_hash_3 $expect_out(1,string)
}
}
expect {
-re {Show SHA512 hash as QR code \(y or n\)\?} {
test_send "n\r"
}
}
expect {
-re {Done}
}

View file

@ -0,0 +1,31 @@
#!/usr/bin/expect
spawn qr-restore.sh --images "$short_hash_1.jpg,$short_hash_2.jpg" --shamir-secret-sharing --share-threshold 2
expect {
-re {\[sudo\] password for pi:} {
test_send "$env(password)\r"
}
}
expect {
-re {Please type passphrase and press enter} {
test_send "$passphrase\r"
}
}
expect {
-re {Show secret \(y or n\)\?} {
test_send "y\r"
}
}
expect {
-re {Secret:\r\n((.|\r\n)+?)\r\nDone} {
set restored_secret $expect_out(1,string)
}
}
expect {
-re {Done}
}