Skip to content

Commit

Permalink
gocryptfs -passwd: fix the tests I just broke
Browse files Browse the repository at this point in the history
Turns out at least the tests depended on the old
behavoir.

Fixes d5bd98e
  • Loading branch information
rfjakob committed Dec 4, 2024
1 parent d5bd98e commit 82dac42
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions tests/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 82dac42

Please sign in to comment.