diff options
Diffstat (limited to 'integration_tests')
-rw-r--r-- | integration_tests/cli_test.go | 46 | ||||
-rw-r--r-- | integration_tests/helpers.go | 16 |
2 files changed, 54 insertions, 8 deletions
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) |