diff options
| author | Jakob Unterwurzacher | 2016-10-08 20:57:38 +0200 | 
|---|---|---|
| committer | Jakob Unterwurzacher | 2016-10-08 20:57:38 +0200 | 
| commit | f054353bd3b05ab0d3d024ec8fa809bc5fed1d08 (patch) | |
| tree | d5dfcccc3035e552449c4796207920fd4f1275e4 /tests | |
| parent | dde4a66454107709a7309ca5047ceb0ecf3c0b9f (diff) | |
reverse: make gocryptfs.conf mapping plaintextnames-aware
Only in plaintextnames-mode AND with the config file at the
default location it will be mapped into the mountpoint.
Also adds a test for that.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/reverse/correctness_test.go | 15 | ||||
| -rw-r--r-- | tests/reverse/main_test.go | 46 | 
2 files changed, 44 insertions, 17 deletions
| diff --git a/tests/reverse/correctness_test.go b/tests/reverse/correctness_test.go index 40bd320..c75a1fd 100644 --- a/tests/reverse/correctness_test.go +++ b/tests/reverse/correctness_test.go @@ -1,6 +1,7 @@  package reverse_test  import ( +	"io/ioutil"  	"os"  	"testing"  	//"time" @@ -49,3 +50,17 @@ func TestSymlinks(t *testing.T) {  		t.Errorf("wrong symlink target: want=%q have=%q", target, actualTarget)  	}  } + +// .gocryptfs.reverse.conf in the plaintext dir should be visible as +// gocryptfs.conf +func TestConfigMapping(t *testing.T) { +	c := dirB + "/gocryptfs.conf" +	test_helpers.VerifyExistence(c) +	data, err := ioutil.ReadFile(c) +	if err != nil { +		t.Fatal(err) +	} +	if len(data) == 0 { +		t.Errorf("empty file") +	} +} diff --git a/tests/reverse/main_test.go b/tests/reverse/main_test.go index a42bb82..a2b7eb6 100644 --- a/tests/reverse/main_test.go +++ b/tests/reverse/main_test.go @@ -10,26 +10,38 @@ import (  var dirA, dirB, dirC string  var x240 string +var plaintextnames bool  func TestMain(m *testing.M) {  	x240 = string(bytes.Repeat([]byte("x"), 240)) -	dirA = test_helpers.TmpDir + "/a" -	dirB = test_helpers.TmpDir + "/b" -	dirC = test_helpers.TmpDir + "/c" -	if err := os.Mkdir(dirA, 0700); err != nil { -		panic(err) -	} -	if err := os.Mkdir(dirB, 0700); err != nil { -		panic(err) -	} -	if err := os.Mkdir(dirC, 0700); err != nil { -		panic(err) +	var r int +	for _, plaintextnames = range []bool{false, true} { +		argsA := []string{"-reverse"} +		if plaintextnames { +			argsA = append(argsA, "-plaintextnames") +		} +		dirA = test_helpers.InitFS(nil, argsA...) +		dirB = test_helpers.TmpDir + "/b" +		dirC = test_helpers.TmpDir + "/c" +		if err := os.Mkdir(dirB, 0700); err != nil { +			panic(err) +		} +		if err := os.Mkdir(dirC, 0700); err != nil { +			panic(err) +		} +		test_helpers.MountOrExit(dirA, dirB, "-reverse", "-extpass", "echo test") +		test_helpers.MountOrExit(dirB, dirC, "-extpass", "echo test") +		r = m.Run() +		test_helpers.UnmountPanic(dirC) +		test_helpers.UnmountPanic(dirB) + +		os.RemoveAll(dirA) +		os.RemoveAll(dirB) +		os.RemoveAll(dirC) + +		if r != 0 { +			os.Exit(r) +		}  	} -	test_helpers.MountOrExit(dirA, dirB, "-zerokey", "-reverse") -	test_helpers.MountOrExit(dirB, dirC, "-zerokey", "-aessiv") -	r := m.Run() -	test_helpers.UnmountPanic(dirC) -	test_helpers.UnmountPanic(dirB) -	os.RemoveAll(test_helpers.TmpDir)  	os.Exit(r)  } | 
