mirror of
https://github.com/FiloSottile/age.git
synced 2026-01-05 11:44:52 +00:00
cmd/age: fix FreeBSD tests
This commit is contained in:
20
cmd/age/testdata/encrypted_keys.txt
vendored
20
cmd/age/testdata/encrypted_keys.txt
vendored
@@ -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
|
||||
|
||||
|
||||
22
cmd/age/testdata/scrypt.txt
vendored
22
cmd/age/testdata/scrypt.txt
vendored
@@ -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
|
||||
|
||||
24
cmd/age/testdata/terminal.txt
vendored
24
cmd/age/testdata/terminal.txt
vendored
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user