From d269c28d169cdf071acf57d283b756cde2b6437f Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Wed, 2 Jan 2019 20:45:55 +0100 Subject: tests: xattr: set on 0200 file, list on 0000 file https://github.com/rfjakob/gocryptfs/issues/308 --- tests/xattr/xattr_integration_test.go | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/tests/xattr/xattr_integration_test.go b/tests/xattr/xattr_integration_test.go index 5eb5dd6..b2870e8 100644 --- a/tests/xattr/xattr_integration_test.go +++ b/tests/xattr/xattr_integration_test.go @@ -97,7 +97,7 @@ func setGetRmList(fn string) error { // Test xattr set, get, rm on a regular file. func TestSetGetRmRegularFile(t *testing.T) { fn := test_helpers.DefaultPlainDir + "/TestSetGetRmRegularFile" - err := ioutil.WriteFile(fn, nil, 0700) + err := ioutil.WriteFile(fn, []byte("12345"), 0700) if err != nil { t.Fatalf("creating empty file failed: %v", err) } @@ -105,6 +105,10 @@ func TestSetGetRmRegularFile(t *testing.T) { if err != nil { t.Error(err) } + fi, _ := os.Lstat(fn) + if fi.Size() != 5 { + t.Errorf("file size has changed!? size=%d", fi.Size()) + } } // Test xattr set, get, rm on a fifo. This should not hang. @@ -276,3 +280,29 @@ func TestBase64XattrRead(t *testing.T) { } } } + +// Listing xattrs should work even when we don't have read access +func TestList0000File(t *testing.T) { + fn := test_helpers.DefaultPlainDir + "/TestList0000File" + err := ioutil.WriteFile(fn, nil, 0000) + if err != nil { + t.Fatalf("creating empty file failed: %v", err) + } + _, err = xattr.LList(fn) + if err != nil { + t.Error(err) + } +} + +// Setting xattrs should work even when we don't have read access +func TestSet0200File(t *testing.T) { + fn := test_helpers.DefaultPlainDir + "/TestSet0200File" + err := ioutil.WriteFile(fn, nil, 0200) + if err != nil { + t.Fatalf("creating empty file failed: %v", err) + } + err = xattr.LSet(fn, "user.foo", []byte("bar")) + if err != nil { + t.Error(err) + } +} -- cgit v1.2.3