diff options
author | Jakob Unterwurzacher | 2024-12-04 19:47:43 +0100 |
---|---|---|
committer | Jakob Unterwurzacher | 2024-12-04 19:47:43 +0100 |
commit | 82dac42e85f01b1ea3383470350aa837a19f0ac3 (patch) | |
tree | 2151e533c69801eed54efc8747f934658b2882a0 /tests | |
parent | d5bd98eb3f4cbfb8dd9d0b2eb64dbff69c3c88b1 (diff) |
gocryptfs -passwd: fix the tests I just broke
Turns out at least the tests depended on the old
behavoir.
Fixes d5bd98eb3f4cbfb8dd9d0b2eb64dbff69c3c88b1
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cli/cli_test.go | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/tests/cli/cli_test.go b/tests/cli/cli_test.go index b2f9f40..fb09338 100644 --- a/tests/cli/cli_test.go +++ b/tests/cli/cli_test.go @@ -117,25 +117,37 @@ func TestInitMasterkey(t *testing.T) { // the -extpass method, then from "test" to "newpasswd" using the // stdin method. func testPasswd(t *testing.T, dir string, extraArgs ...string) { - // Change password using "-extpass" + // Change password #1: old passwd via "-extpass", new one via stdin args := []string{"-q", "-passwd", "-extpass", "echo test"} args = append(args, extraArgs...) args = append(args, dir) cmd := exec.Command(test_helpers.GocryptfsBinary, args...) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr - err := cmd.Run() + p, err := cmd.StdinPipe() + if err != nil { + t.Fatal(err) + } + err = cmd.Start() if err != nil { t.Error(err) } - // Change password using stdin + // New password through stdin + p.Write([]byte("test\n")) + p.Close() + err = cmd.Wait() + if err != nil { + t.Error(err) + } + + // Change password #2: using stdin args = []string{"-q", "-passwd"} args = append(args, extraArgs...) args = append(args, dir) cmd = exec.Command(test_helpers.GocryptfsBinary, args...) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr - p, err := cmd.StdinPipe() + p, err = cmd.StdinPipe() if err != nil { t.Fatal(err) } @@ -336,10 +348,22 @@ func TestInitConfig(t *testing.T) { "-config", config, dir) cmd2.Stdout = os.Stdout cmd2.Stderr = os.Stderr - err = cmd2.Run() + p, err := cmd2.StdinPipe() + if err != nil { + t.Fatal(err) + } + err = cmd2.Start() if err != nil { t.Error(err) } + // New password + p.Write([]byte("passwd\n")) + p.Close() + err = cmd2.Wait() + if err != nil { + t.Error(err) + } + } // Test -ro |