cmd/age: fix FreeBSD tests

This commit is contained in:
Filippo Valsorda
2023-08-06 19:28:49 +02:00
parent 294b0aa1e3
commit 93055632ad
5 changed files with 39 additions and 39 deletions

View File

@@ -1,20 +1,20 @@
# TODO: age-encrypted private keys, multiple identities, -i ordering, -e -i,
# age file password prompt during encryption
[windows] skip # no pty support
[go1.20] skip # https://go.dev/issue/61779
[!linux] [!darwin] skip # no pty support
[darwin] [go1.20] skip # https://go.dev/issue/61779
# use an encrypted OpenSSH private key without .pub file
age -R key_ed25519.pub -o ed25519.age input
rm key_ed25519.pub
pty terminal
ttyin terminal
age -d -i key_ed25519 ed25519.age
cmp stdout input
! stderr .
# -e -i with an encrypted OpenSSH private key
age -e -i key_ed25519 -o ed25519.age input
pty terminal
ttyin terminal
age -d -i key_ed25519 ed25519.age
cmp stdout input
@@ -25,7 +25,7 @@ stderr 'no identity matched any of the recipients'
# use an encrypted legacy PEM private key with a .pub file
age -R key_rsa_legacy.pub -o rsa_legacy.age input
pty terminal
ttyin terminal
age -d -i key_rsa_legacy rsa_legacy.age
cmp stdout input
! stderr .
@@ -35,7 +35,7 @@ stderr 'no identity matched any of the recipients'
# -e -i with an encrypted legacy PEM private key
age -e -i key_rsa_legacy -o rsa_legacy.age input
pty terminal
ttyin terminal
age -d -i key_rsa_legacy rsa_legacy.age
cmp stdout input
@@ -46,17 +46,17 @@ stderr 'key_rsa_legacy.pub'
# mismatched .pub file causes an error
cp key_rsa_legacy key_rsa_other
pty terminal
ttyin terminal
! age -d -i key_rsa_other rsa_other.age
stderr 'mismatched private and public SSH key'
# buffer armored ciphertext before prompting if stdin is the terminal
pty terminal
ttyin terminal
age -e -i key_ed25519 -a -o test.age input
exec cat test.age terminal # concatenated ciphertext + password
pty -stdin stdout
ttyin -stdin stdout
age -d -i key_ed25519
ptyout 'Enter passphrase'
ttyout 'Enter passphrase'
! stderr .
cmp stdout input

View File

@@ -1,43 +1,43 @@
[windows] skip # no pty support
[go1.20] skip # https://go.dev/issue/61779
[!linux] [!darwin] skip # no pty support
[darwin] [go1.20] skip # https://go.dev/issue/61779
# encrypt with a provided passphrase
stdin input
pty terminal
ttyin terminal
age -p -o test.age
ptyout 'Enter passphrase'
ttyout 'Enter passphrase'
! stderr .
! stdout .
# decrypt with a provided passphrase
pty terminal
ttyin terminal
age -d test.age
ptyout 'Enter passphrase'
ttyout 'Enter passphrase'
! stderr .
cmp stdout input
# decrypt with the wrong passphrase
pty wrong
ttyin wrong
! age -d test.age
stderr 'incorrect passphrase'
# encrypt with a generated passphrase
stdin input
pty empty
ttyin empty
age -p -o test.age
! stderr .
! stdout .
pty autogenerated
ttyin autogenerated
age -d test.age
cmp stdout input
# fail when -i is present
pty terminal
ttyin terminal
! age -d -i key.txt test.age
stderr 'file is passphrase-encrypted but identities were specified'
# fail when passphrases don't match
pty wrong
ttyin wrong
! age -p -o fail.age
stderr 'passphrases didn''t match'
! exists fail.age

View File

@@ -1,22 +1,22 @@
[windows] skip # no pty support
[go1.20] skip # https://go.dev/issue/61779
[!linux] [!darwin] skip # no pty support
[darwin] [go1.20] skip # https://go.dev/issue/61779
# controlling terminal is used instead of stdin/stderr
pty terminal
ttyin terminal
age -p -o test.age input
! stderr .
# autogenerated passphrase is printed to terminal
pty empty
ttyin empty
age -p -o test.age input
ptyout 'autogenerated passphrase'
ttyout 'autogenerated passphrase'
! stderr .
# with no controlling terminal, stdin terminal is used
## TODO: enable once https://golang.org/issue/53601 is fixed
## and Noctty is added to testscript.
# noctty
# pty -stdin terminal
# ttyin -stdin terminal
# age -p -o test.age input
# ! stderr .
@@ -29,22 +29,22 @@ ptyout 'autogenerated passphrase'
# prompt for password before plaintext if stdin is the terminal
exec cat terminal input # concatenated password + input
pty -stdin stdout
ttyin -stdin stdout
age -p -a -o test.age
ptyout 'Enter passphrase'
ttyout 'Enter passphrase'
! stderr .
# check the file was encrypted correctly
pty terminal
ttyin terminal
age -d test.age
cmp stdout input
# buffer armored ciphertext before prompting if stdin is the terminal
pty terminal
ttyin terminal
age -p -a -o test.age input
exec cat test.age terminal # concatenated ciphertext + password
pty -stdin stdout
ttyin -stdin stdout
age -d
ptyout 'Enter passphrase'
ttyout 'Enter passphrase'
! stderr .
cmp stdout input