From d95fc2333aa5c05de713694c0893c7690655a584 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 15 Nov 2015 13:38:19 +0100 Subject: Add "-extpass" cli option and associated tests --- integration_tests/cli_test.go | 46 +++++++++++++++++++++++++++++++++++++++++++ integration_tests/helpers.go | 16 +++++++-------- 2 files changed, 54 insertions(+), 8 deletions(-) create mode 100644 integration_tests/cli_test.go (limited to 'integration_tests') diff --git a/integration_tests/cli_test.go b/integration_tests/cli_test.go new file mode 100644 index 0000000..a696600 --- /dev/null +++ b/integration_tests/cli_test.go @@ -0,0 +1,46 @@ +package integration_tests + +// Test CLI operations like "-init", "-password" etc + +import ( + "os" + "os/exec" + "testing" + + "github.com/rfjakob/gocryptfs/cryptfs" +) + +func TestInit(t *testing.T) { + dir := tmpDir + "TestInit/" + err := os.Mkdir(dir, 0777) + if err != nil { + t.Fatal(err) + } + cmd := exec.Command(gocryptfsBinary, "-init", "-extpass", "echo test", dir) + if testing.Verbose() { + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + } + err = cmd.Run() + if err != nil { + t.Error(err) + } + _, err = os.Stat(dir + cryptfs.ConfDefaultName) + if err != nil { + t.Error(err) + } +} + +// "dir" has been initialized by TestInit +func TestPasswd(t *testing.T) { + dir := tmpDir + "TestInit/" + cmd := exec.Command(gocryptfsBinary, "-passwd", "-extpass", "echo test", dir) + if testing.Verbose() { + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + } + err := cmd.Run() + if err != nil { + t.Error(err) + } +} diff --git a/integration_tests/helpers.go b/integration_tests/helpers.go index fdad28b..3ab1d21 100644 --- a/integration_tests/helpers.go +++ b/integration_tests/helpers.go @@ -10,13 +10,13 @@ import ( "testing" ) +// Note: the code assumes that all have a trailing slash const tmpDir = "/tmp/gocryptfs_main_test/" - -// Mountpoint -// Note: the code assumes that both have a trailing slash! const plainDir = tmpDir + "plain/" const cipherDir = tmpDir + "cipher/" +const gocryptfsBinary = "../gocryptfs" + func resetTmpDir() { fu := exec.Command("fusermount", "-z", "-u", plainDir) fu.Run() @@ -40,11 +40,11 @@ func mount(extraArgs ...string) { //args = append(args, "--fusedebug") args = append(args, cipherDir) args = append(args, plainDir) - c := exec.Command("../gocryptfs", args...) - // Warning messages clutter the test output. Uncomment if you want to debug - // failures. - //c.Stdout = os.Stdout - //c.Stderr = os.Stderr + c := exec.Command(gocryptfsBinary, args...) + if testing.Verbose() { + c.Stdout = os.Stdout + c.Stderr = os.Stderr + } err := c.Run() if err != nil { fmt.Println(err) -- cgit v1.2.3