From 93055632adee9025d196e483d8e2ac43ff9a3fdc Mon Sep 17 00:00:00 2001 From: Filippo Valsorda Date: Sun, 6 Aug 2023 19:28:49 +0200 Subject: [PATCH] cmd/age: fix FreeBSD tests --- cmd/age/testdata/encrypted_keys.txt | 20 ++++++++++---------- cmd/age/testdata/scrypt.txt | 22 +++++++++++----------- cmd/age/testdata/terminal.txt | 24 ++++++++++++------------ go.mod | 4 ++-- go.sum | 8 ++++---- 5 files changed, 39 insertions(+), 39 deletions(-) diff --git a/cmd/age/testdata/encrypted_keys.txt b/cmd/age/testdata/encrypted_keys.txt index 7b4f716..050bf13 100644 --- a/cmd/age/testdata/encrypted_keys.txt +++ b/cmd/age/testdata/encrypted_keys.txt @@ -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 diff --git a/cmd/age/testdata/scrypt.txt b/cmd/age/testdata/scrypt.txt index 8a1b684..9329885 100644 --- a/cmd/age/testdata/scrypt.txt +++ b/cmd/age/testdata/scrypt.txt @@ -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 diff --git a/cmd/age/testdata/terminal.txt b/cmd/age/testdata/terminal.txt index 849e772..b2cf007 100644 --- a/cmd/age/testdata/terminal.txt +++ b/cmd/age/testdata/terminal.txt @@ -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 diff --git a/go.mod b/go.mod index d382a0c..4c0eed9 100644 --- a/go.mod +++ b/go.mod @@ -12,9 +12,9 @@ require ( // Test dependencies. require ( c2sp.org/CCTV/age v0.0.0-20221230231406-5ea85644bd03 - github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e // indirect github.com/rogpeppe/go-internal v1.8.1 + golang.org/x/tools v0.1.12 // indirect ) // https://github.com/rogpeppe/go-internal/pull/172 -replace github.com/rogpeppe/go-internal => github.com/FiloSottile/go-internal v1.8.2-0.20230102123319-d43ebe7f1660 +replace github.com/rogpeppe/go-internal => github.com/FiloSottile/go-internal v1.8.2-0.20230806172430-94b0f0dc0b1e diff --git a/go.sum b/go.sum index 98da6be..a71308c 100644 --- a/go.sum +++ b/go.sum @@ -2,13 +2,13 @@ c2sp.org/CCTV/age v0.0.0-20221230231406-5ea85644bd03 h1:0e2QjhWG02SgzlUOvNYaFraf c2sp.org/CCTV/age v0.0.0-20221230231406-5ea85644bd03/go.mod h1:FomMrUJ2Lxt5jCLmZkG3FHa72zUprnhd3v/Z18Snm4w= filippo.io/edwards25519 v1.0.0 h1:0wAIcmJUqRdI8IJ/3eGi5/HwXZWPujYXXlkrQogz0Ek= filippo.io/edwards25519 v1.0.0/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= -github.com/FiloSottile/go-internal v1.8.2-0.20230102123319-d43ebe7f1660 h1:o9Uw6fW8MF/K9RlbCO5e/5e6uXPdwND1NyRnn1NHjgE= -github.com/FiloSottile/go-internal v1.8.2-0.20230102123319-d43ebe7f1660/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e h1:aoZm08cpOy4WuID//EZDgcC4zIxODThtZNPirFr42+A= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= +github.com/FiloSottile/go-internal v1.8.2-0.20230806172430-94b0f0dc0b1e h1:1pkMKBSmMMOXQT5lFTmciWn86GGymBssr1bOOOoo2GI= +github.com/FiloSottile/go-internal v1.8.2-0.20230806172430-94b0f0dc0b1e/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= golang.org/x/crypto v0.4.0 h1:UVQgzMY87xqpKNgb+kDsll2Igd33HszWHFLmpaRMq/8= golang.org/x/crypto v0.4.0/go.mod h1:3quD/ATkf6oY+rnes5c3ExXTbLc8mueNue5/DoinL80= golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.3.0 h1:qoo4akIqOcDME5bhc/NgxUdovd6BSS2uMsVjB56q1xI= golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= +golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=