[windows] skip # no pty support

# controlling terminal is used instead of stdin/stderr
pty terminal
age -p -o test.age input
! stderr .

# autogenerated passphrase is printed to terminal
pty empty
age -p -o test.age input
ptyout '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
# age -p -o test.age input
# ! stderr .

# no terminal causes an error
## TODO: enable once https://golang.org/issue/53601 is fixed
## and Noctty is added to testscript.
# noctty
# ! age -p -o test.age input
# stderr 'standard input is not a terminal'

# prompt for password before plaintext if stdin is the terminal
exec cat terminal input # concatenated password + input
pty -stdin stdout
age -p -a -o test.age
ptyout 'Enter passphrase'
! stderr .
# check the file was encrypted correctly
pty terminal
age -d test.age
cmp stdout input

# buffer armored ciphertext before prompting if stdin is the terminal
pty terminal
age -p -a -o test.age input
exec cat test.age terminal # concatenated ciphertext + password
pty -stdin stdout
age -d
ptyout 'Enter passphrase'
! stderr .
cmp stdout input

-- input --
test
-- terminal --
password
password
-- empty --

