aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJakob Unterwurzacher2016-06-15 22:43:31 +0200
committerJakob Unterwurzacher2016-06-15 22:44:24 +0200
commitc89455063cfd9c531c0a671251ccfcd46f09403d (patch)
tree1bd5330aad0ac7b16ecb5b35150a304e56271be3 /tests
parent218bf83ce399832a0eccfbd025e5dd0399db6bed (diff)
readpassword: create internal package for password reading
* Supports stdin * Add tests for extpass and stdin As per user request at https://github.com/rfjakob/gocryptfs/issues/30
Diffstat (limited to 'tests')
-rw-r--r--tests/integration_tests/cli_test.go30
1 files changed, 25 insertions, 5 deletions
diff --git a/tests/integration_tests/cli_test.go b/tests/integration_tests/cli_test.go
index bc604bd..0e88581 100644
--- a/tests/integration_tests/cli_test.go
+++ b/tests/integration_tests/cli_test.go
@@ -49,14 +49,34 @@ func TestPasswd(t *testing.T) {
t.Fatal(err)
}
// Change password using "-extpass"
- cmd2 := exec.Command(test_helpers.GocryptfsBinary, "-q", "-passwd", "-extpass", "echo test", dir)
- cmd2.Stdout = os.Stdout
- cmd2.Stderr = os.Stderr
- err = cmd2.Run()
+ cmd = exec.Command(test_helpers.GocryptfsBinary, "-q", "-passwd", "-extpass", "echo test", dir)
+ cmd.Stdout = os.Stdout
+ cmd.Stderr = os.Stderr
+ err = cmd.Run()
+ if err != nil {
+ t.Error(err)
+ }
+ // Change password using stdin
+ cmd = exec.Command(test_helpers.GocryptfsBinary, "-q", "-passwd", dir)
+ cmd.Stdout = os.Stdout
+ cmd.Stderr = os.Stderr
+ p, err := cmd.StdinPipe()
+ if err != nil {
+ t.Fatal(err)
+ }
+ err = cmd.Start()
+ if err != nil {
+ t.Error(err)
+ }
+ // Old password
+ p.Write([]byte("test\n"))
+ // New password
+ p.Write([]byte("newpasswd\n"))
+ p.Close()
+ err = cmd.Wait()
if err != nil {
t.Error(err)
}
-
}
// Test -init & -config flag