From 62e7eb7d04793d7d629c1105a3eddf04e396ac24 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Thu, 16 Feb 2017 21:20:29 +0100 Subject: tests: reverse: check Access() call --- tests/reverse/correctness_test.go | 24 ++++++++++++++++++++++++ tests/reverse/main_test.go | 12 +++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) (limited to 'tests/reverse') diff --git a/tests/reverse/correctness_test.go b/tests/reverse/correctness_test.go index 3565ea6..db64983 100644 --- a/tests/reverse/correctness_test.go +++ b/tests/reverse/correctness_test.go @@ -3,6 +3,7 @@ package reverse_test import ( "io/ioutil" "os" + "syscall" "testing" "github.com/rfjakob/gocryptfs/tests/test_helpers" @@ -65,3 +66,26 @@ func TestConfigMapping(t *testing.T) { t.Errorf("empty file") } } + +// Check that the access() syscall works on virtual files +func TestAccessVirtual(t *testing.T) { + if plaintextnames { + t.Skip() + } + var R_OK uint32 = 4 + var W_OK uint32 = 2 + var X_OK uint32 = 1 + fn := dirB + "/gocryptfs.diriv" + err := syscall.Access(fn, R_OK) + if err != nil { + t.Errorf("%q should be readable, but got error: %v", fn, err) + } + err = syscall.Access(fn, W_OK) + if err == nil { + t.Errorf("should NOT be writeable") + } + err = syscall.Access(fn, X_OK) + if err == nil { + t.Errorf("should NOT be executable") + } +} diff --git a/tests/reverse/main_test.go b/tests/reverse/main_test.go index be6016f..3425289 100644 --- a/tests/reverse/main_test.go +++ b/tests/reverse/main_test.go @@ -8,10 +8,20 @@ import ( "github.com/rfjakob/gocryptfs/tests/test_helpers" ) -var dirA, dirB, dirC string var x240 = string(bytes.Repeat([]byte("x"), 240)) var plaintextnames bool +// dirA is a normal directory +var dirA string + +// dirB is the reverse mount backed by dirA +var dirB string + +// dirC is a forward mount backed by dirB +var dirC string + +// Create directory "dirA", mount it reverse to "dirB", mount it forward +// to "dirC". func TestMain(m *testing.M) { var r int for _, plaintextnames = range []bool{false, true} { -- cgit v1.2.3