aboutsummaryrefslogtreecommitdiff
path: root/gocryptfs-xray/xray_tests/xray_test.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2020-05-10 00:04:14 +0200
committerJakob Unterwurzacher2020-05-10 00:04:14 +0200
commita9895b34872d2299cfe424444fab15516e7f96c9 (patch)
tree0d5a1c28e0f4cbac700b28c5298cdbbf8dd77b83 /gocryptfs-xray/xray_tests/xray_test.go
parentf2e8b776f8d2f4cff928e127798fc8c98ca2fbc5 (diff)
gocryptfs-xray: add -0 flag, add tests
The -0 flags works like xargs -0.
Diffstat (limited to 'gocryptfs-xray/xray_tests/xray_test.go')
-rw-r--r--gocryptfs-xray/xray_tests/xray_test.go50
1 files changed, 50 insertions, 0 deletions
diff --git a/gocryptfs-xray/xray_tests/xray_test.go b/gocryptfs-xray/xray_tests/xray_test.go
index dfd21e6..790d2db 100644
--- a/gocryptfs-xray/xray_tests/xray_test.go
+++ b/gocryptfs-xray/xray_tests/xray_test.go
@@ -6,6 +6,8 @@ import (
"io/ioutil"
"os/exec"
"testing"
+
+ "github.com/rfjakob/gocryptfs/tests/test_helpers"
)
func TestAesgcmXray(t *testing.T) {
@@ -58,3 +60,51 @@ func TestDumpmasterkey(t *testing.T) {
fmt.Printf("have: %s\n", out)
}
}
+
+func TestEncryptPaths(t *testing.T) {
+ cDir := test_helpers.InitFS(t)
+ pDir := cDir + ".mnt"
+ sock := cDir + ".sock"
+ test_helpers.MountOrFatal(t, cDir, pDir, "-ctlsock="+sock, "-extpass", "echo test")
+ defer test_helpers.UnmountPanic(pDir)
+
+ testCases := []struct {
+ in []string
+ sep0 bool
+ }{
+ {
+ []string{
+ "test1",
+ "test1\n",
+ "test1\ntest2",
+ "test1\ntest2\n",
+ },
+ false,
+ },
+ {
+ []string{
+ "test1",
+ "test1\000",
+ "test1\000test2",
+ "test1\000test2\000",
+ },
+ true,
+ },
+ }
+
+ for _, tc := range testCases {
+ for _, in := range tc.in {
+ sepArg := "-0=false"
+ if tc.sep0 {
+ sepArg = "-0=true"
+ }
+ cmd := exec.Command("../gocryptfs-xray", "-encrypt-paths", sepArg, sock)
+ cmd.Stdin = bytes.NewBuffer([]byte(in))
+ out, err := cmd.CombinedOutput()
+ t.Logf("%q", string(out))
+ if err != nil {
+ t.Fatal(err)
+ }
+ }
+ }
+}