mirror of
https://github.com/FiloSottile/age.git
synced 2026-09-25 17:34:32 +00:00
plugin: allow empty prompt responses
Reported by Joe Doyle of Trail of Bits.
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
package plugin
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"errors"
|
||||
"io"
|
||||
@@ -19,6 +20,7 @@ import (
|
||||
|
||||
"filippo.io/age"
|
||||
"filippo.io/age/internal/bech32"
|
||||
"filippo.io/age/internal/format"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
@@ -104,6 +106,22 @@ func TestPluginNameCase(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRequestValueEmpty(t *testing.T) {
|
||||
p, err := New("test")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
p.SetIO(nil, io.Discard, io.Discard)
|
||||
p.sr = format.NewStanzaReader(bufio.NewReader(strings.NewReader("-> ok\n\n")))
|
||||
value, err := p.RequestValue("prompt", true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if value != "" {
|
||||
t.Errorf("value = %q", value)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLabels(t *testing.T) {
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("Windows support is TODO")
|
||||
|
||||
Reference in New Issue
Block a user