From c89455063cfd9c531c0a671251ccfcd46f09403d Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Wed, 15 Jun 2016 22:43:31 +0200 Subject: 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 --- tests/integration_tests/cli_test.go | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'tests') 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 -- cgit v1.2.3