diff options
author | Jakob Unterwurzacher | 2019-01-02 20:45:55 +0100 |
---|---|---|
committer | Jakob Unterwurzacher | 2019-01-02 20:45:55 +0100 |
commit | d269c28d169cdf071acf57d283b756cde2b6437f (patch) | |
tree | 019bbbaaf7b7307062603730d652000ecd314202 /tests | |
parent | bb7f919674533eda5ea5b2b21f54b13c06dbbff7 (diff) |
tests: xattr: set on 0200 file, list on 0000 file
https://github.com/rfjakob/gocryptfs/issues/308
Diffstat (limited to 'tests')
-rw-r--r-- | tests/xattr/xattr_integration_test.go | 32 |
1 files changed, 31 insertions, 1 deletions
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) + } +} |