aboutsummaryrefslogtreecommitdiff
path: root/internal/readpassword/extpass_test.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2019-03-03 13:25:30 +0100
committerJakob Unterwurzacher2019-03-03 13:25:30 +0100
commitcf27037f20723e934320edeff7f8aa356bdca467 (patch)
treeb12428d172325fcfb517af26f7985651ef70e902 /internal/readpassword/extpass_test.go
parent61940a9c0666eba8be21de4f1cd182912f74f929 (diff)
Allow multiple -extpass arguments
To support arguments containing spaces, -extpass can now be passed multiple times. https://github.com/rfjakob/gocryptfs/issues/289
Diffstat (limited to 'internal/readpassword/extpass_test.go')
-rw-r--r--internal/readpassword/extpass_test.go34
1 files changed, 30 insertions, 4 deletions
diff --git a/internal/readpassword/extpass_test.go b/internal/readpassword/extpass_test.go
index 037d111..b4ca8fa 100644
--- a/internal/readpassword/extpass_test.go
+++ b/internal/readpassword/extpass_test.go
@@ -18,7 +18,7 @@ func TestMain(m *testing.M) {
func TestExtpass(t *testing.T) {
p1 := "ads2q4tw41reg52"
- p2 := string(readPasswordExtpass("echo " + p1))
+ p2 := string(readPasswordExtpass([]string{"echo " + p1}))
if p1 != p2 {
t.Errorf("p1=%q != p2=%q", p1, p2)
}
@@ -26,7 +26,33 @@ func TestExtpass(t *testing.T) {
func TestOnceExtpass(t *testing.T) {
p1 := "lkadsf0923rdfi48rqwhdsf"
- p2 := string(Once("echo "+p1, "", ""))
+ p2 := string(Once([]string{"echo " + p1}, "", ""))
+ if p1 != p2 {
+ t.Errorf("p1=%q != p2=%q", p1, p2)
+ }
+}
+
+// extpass with two arguments
+func TestOnceExtpass2(t *testing.T) {
+ p1 := "foo"
+ p2 := string(Once([]string{"echo", p1}, "", ""))
+ if p1 != p2 {
+ t.Errorf("p1=%q != p2=%q", p1, p2)
+ }
+}
+
+// extpass with three arguments
+func TestOnceExtpass3(t *testing.T) {
+ p1 := "foo bar baz"
+ p2 := string(Once([]string{"echo", "foo", "bar", "baz"}, "", ""))
+ if p1 != p2 {
+ t.Errorf("p1=%q != p2=%q", p1, p2)
+ }
+}
+
+func TestOnceExtpassSpaces(t *testing.T) {
+ p1 := "mypassword"
+ p2 := string(Once([]string{"cat", "passfile_test_files/file with spaces.txt"}, "", ""))
if p1 != p2 {
t.Errorf("p1=%q != p2=%q", p1, p2)
}
@@ -34,7 +60,7 @@ func TestOnceExtpass(t *testing.T) {
func TestTwiceExtpass(t *testing.T) {
p1 := "w5w44t3wfe45srz434"
- p2 := string(Once("echo "+p1, "", ""))
+ p2 := string(Once([]string{"echo " + p1}, "", ""))
if p1 != p2 {
t.Errorf("p1=%q != p2=%q", p1, p2)
}
@@ -46,7 +72,7 @@ func TestTwiceExtpass(t *testing.T) {
// https://talks.golang.org/2014/testing.slide#23 .
func TestExtpassEmpty(t *testing.T) {
if os.Getenv("TEST_SLAVE") == "1" {
- readPasswordExtpass("echo")
+ readPasswordExtpass([]string{"echo"})
return
}
cmd := exec.Command(os.Args[0], "-test.run=TestExtpassEmpty$")