2021-04-18 10:06:04 -04:00
|
|
|
#!/usr/bin/expect
|
|
|
|
|
|
|
|
source ./test.exp
|
|
|
|
|
|
|
|
set secret "foo\nbar"
|
|
|
|
set passphrase "asdasd"
|
|
|
|
|
|
|
|
test_label "Should duplicate backup"
|
|
|
|
|
|
|
|
source ./tests/helpers/backup.exp
|
|
|
|
|
|
|
|
spawn qr-clone.sh --duplicate --qr-restore-options "--images $short_hash.jpg"
|
|
|
|
|
|
|
|
expect {
|
|
|
|
-re {Restoring…}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect {
|
|
|
|
-re {\[sudo\] password for pi:} {
|
|
|
|
test_send "$env(password)\r"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect {
|
|
|
|
-re {Done}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect {
|
|
|
|
-re {Backing up…}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect {
|
|
|
|
-re {Format USB flash drive \(y or n\)\?} {
|
|
|
|
test_send "n\r"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect {
|
|
|
|
-re {SHA512 short hash: .+?([a-f0-9]{8})} {
|
|
|
|
set new_short_hash $expect_out(1,string)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect {
|
|
|
|
-re {Show SHA512 hash as QR code \(y or n\)\?} {
|
|
|
|
test_send "n\r"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect {
|
|
|
|
-re {Done}
|
|
|
|
}
|
|
|
|
|
|
|
|
if { "$new_short_hash" != "$short_hash" } {
|
|
|
|
test_failed
|
|
|
|
}
|
|
|
|
|
|
|
|
set short_hash "$new_short_hash"
|
|
|
|
|
|
|
|
source ./tests/helpers/restore.exp
|
|
|
|
|
2021-04-19 13:43:55 -04:00
|
|
|
regsub -all {\033\[[0-9]*m(\017)?} $restored_secret {} restored_secret
|
2021-04-18 10:06:04 -04:00
|
|
|
regsub -all {\r} $restored_secret {} restored_secret
|
|
|
|
|
|
|
|
if { "$restored_secret" != "$secret" } {
|
|
|
|
test_failed
|
|
|
|
} else {
|
|
|
|
test_ok
|
|
|
|
}
|