From b02812f8b3609403e36c0c182fd2f01537dd6e82 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Mon, 23 Aug 2021 15:17:04 +0200 Subject: test/cli: actually run TestZerokey As the filename did not end in _test.go, TestZerokey was not actually run. Fix that. renamed: tests/cli/zerokey.go -> tests/cli/zerokey_test.go --- tests/cli/zerokey.go | 60 ----------------------------------------------- tests/cli/zerokey_test.go | 60 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 60 deletions(-) delete mode 100644 tests/cli/zerokey.go create mode 100644 tests/cli/zerokey_test.go diff --git a/tests/cli/zerokey.go b/tests/cli/zerokey.go deleted file mode 100644 index e9b9c50..0000000 --- a/tests/cli/zerokey.go +++ /dev/null @@ -1,60 +0,0 @@ -package cli - -import ( - "io/ioutil" - "os" - "os/exec" - "testing" - - "github.com/rfjakob/gocryptfs/v2/tests/test_helpers" -) - -// TestZerokey verifies that `gocryptfs -zerokey` uses the same options as -// `gocryptfs -init`. -func TestZerokey(t *testing.T) { - // Create FS - dir := test_helpers.InitFS(t) - - // Change masterkey to all-zero using password change - args := []string{"-q", "-passwd", "-masterkey", - "00000000-00000000-00000000-00000000-00000000-00000000-00000000-00000000"} - args = append(args, dir) - cmd := exec.Command(test_helpers.GocryptfsBinary, args...) - 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) - } - // New password = old password - p.Write([]byte("test\n")) - p.Close() - err = cmd.Wait() - if err != nil { - t.Error(err) - } - - // Add content - mnt := dir + ".mnt" - test_helpers.MountOrFatal(t, dir, mnt, "-extpass", "echo test") - file1 := mnt + "/file1" - err = ioutil.WriteFile(file1, []byte("somecontent"), 0600) - if err != nil { - t.Fatal(err) - } - test_helpers.UnmountPanic(mnt) - - // Mount using -zerokey and verify we get the same result - test_helpers.MountOrFatal(t, dir, mnt, "-extpass", "echo test") - content, err := ioutil.ReadFile(file1) - if err != nil { - t.Error(err) - } else if string(content) != "somecontent" { - t.Errorf("wrong content: %q", string(content)) - } - test_helpers.UnmountPanic(mnt) -} diff --git a/tests/cli/zerokey_test.go b/tests/cli/zerokey_test.go new file mode 100644 index 0000000..e9b9c50 --- /dev/null +++ b/tests/cli/zerokey_test.go @@ -0,0 +1,60 @@ +package cli + +import ( + "io/ioutil" + "os" + "os/exec" + "testing" + + "github.com/rfjakob/gocryptfs/v2/tests/test_helpers" +) + +// TestZerokey verifies that `gocryptfs -zerokey` uses the same options as +// `gocryptfs -init`. +func TestZerokey(t *testing.T) { + // Create FS + dir := test_helpers.InitFS(t) + + // Change masterkey to all-zero using password change + args := []string{"-q", "-passwd", "-masterkey", + "00000000-00000000-00000000-00000000-00000000-00000000-00000000-00000000"} + args = append(args, dir) + cmd := exec.Command(test_helpers.GocryptfsBinary, args...) + 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) + } + // New password = old password + p.Write([]byte("test\n")) + p.Close() + err = cmd.Wait() + if err != nil { + t.Error(err) + } + + // Add content + mnt := dir + ".mnt" + test_helpers.MountOrFatal(t, dir, mnt, "-extpass", "echo test") + file1 := mnt + "/file1" + err = ioutil.WriteFile(file1, []byte("somecontent"), 0600) + if err != nil { + t.Fatal(err) + } + test_helpers.UnmountPanic(mnt) + + // Mount using -zerokey and verify we get the same result + test_helpers.MountOrFatal(t, dir, mnt, "-extpass", "echo test") + content, err := ioutil.ReadFile(file1) + if err != nil { + t.Error(err) + } else if string(content) != "somecontent" { + t.Errorf("wrong content: %q", string(content)) + } + test_helpers.UnmountPanic(mnt) +} -- cgit v1.2.3