aboutsummaryrefslogtreecommitdiff
path: root/tests/cli
diff options
context:
space:
mode:
authorJakob Unterwurzacher2022-01-03 14:27:09 +0100
committerJakob Unterwurzacher2022-01-03 14:27:52 +0100
commit1eaf1211a259a38cdf3e7dad2e00e140409bef9a (patch)
tree21a959e7ed2e997f521a446c645ea223df993dab /tests/cli
parent5749e70c7cc4365d6de6a4d5afb73d71d0c10003 (diff)
tests/cli: Check for leftover socket file
This fails at the moment: $ go test ./tests/cli/ --- FAIL: TestMountPasswordEmpty (0.01s) cli_test.go:430: socket file "/tmp/gocryptfs-test-parent-1026/3413782690/TestMountPasswordEmpty.753166857.sock" left behind https://github.com/rfjakob/gocryptfs/issues/634
Diffstat (limited to 'tests/cli')
-rw-r--r--tests/cli/cli_test.go26
1 files changed, 24 insertions, 2 deletions
diff --git a/tests/cli/cli_test.go b/tests/cli/cli_test.go
index c433e92..915759d 100644
--- a/tests/cli/cli_test.go
+++ b/tests/cli/cli_test.go
@@ -398,15 +398,37 @@ func TestShadows(t *testing.T) {
}
// TestMountPasswordIncorrect makes sure the correct exit code is used when the password
-// was incorrect while mounting
+// was incorrect while mounting.
+// Also checks that we don't leave a socket file behind.
func TestMountPasswordIncorrect(t *testing.T) {
cDir := test_helpers.InitFS(t) // Create filesystem with password "test"
+ ctlSock := cDir + ".sock"
pDir := cDir + ".mnt"
- err := test_helpers.Mount(cDir, pDir, false, "-extpass", "echo WRONG", "-wpanic=false")
+ err := test_helpers.Mount(cDir, pDir, false, "-extpass", "echo WRONG", "-wpanic=false", "-ctlsock", ctlSock)
exitCode := test_helpers.ExtractCmdExitCode(err)
if exitCode != exitcodes.PasswordIncorrect {
t.Errorf("want=%d, got=%d", exitcodes.PasswordIncorrect, exitCode)
}
+ if _, err := os.Stat(ctlSock); err == nil {
+ t.Errorf("socket file %q left behind", ctlSock)
+ }
+}
+
+// TestMountPasswordEmpty makes sure the correct exit code is used when the password
+// was empty while mounting.
+// Also checks that we don't leave a socket file behind (https://github.com/rfjakob/gocryptfs/issues/634).
+func TestMountPasswordEmpty(t *testing.T) {
+ cDir := test_helpers.InitFS(t) // Create filesystem with password "test"
+ ctlSock := cDir + ".sock"
+ pDir := cDir + ".mnt"
+ err := test_helpers.Mount(cDir, pDir, false, "-extpass", "true", "-wpanic=false", "-ctlsock", ctlSock)
+ exitCode := test_helpers.ExtractCmdExitCode(err)
+ if exitCode != exitcodes.ReadPassword {
+ t.Errorf("want=%d, got=%d", exitcodes.ReadPassword, exitCode)
+ }
+ if _, err := os.Stat(ctlSock); err == nil {
+ t.Errorf("socket file %q left behind", ctlSock)
+ }
}
// TestPasswdPasswordIncorrect makes sure the correct exit code is used when the password