Skip to content

Commit

Permalink
Add user xattr to test TestTarUntarWithXattr
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Rodák <[email protected]>
  • Loading branch information
Honny1 committed Jun 26, 2024
1 parent d8c5cc5 commit 965fb12
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pkg/archive/archive_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ func TestTarUntarWithXattr(t *testing.T) {
encoded := [20]byte{0, 0, 0, 2}
err = system.Lsetxattr(filepath.Join(origin, "2"), "security.capability", encoded[:], 0)
require.NoError(t, err)
err = system.Lsetxattr(filepath.Join(origin, "1"), "user.test", []byte("helloWord"), 0)
require.NoError(t, err)

for _, c := range []Compression{
Uncompressed,
Expand All @@ -248,9 +250,13 @@ func TestTarUntarWithXattr(t *testing.T) {
if len(changes) != 1 || changes[0].Path != "/3" {
t.Fatalf("Unexpected differences after tarUntar: %v", changes)
}
capability, _ := system.Lgetxattr(filepath.Join(origin, "2"), "security.capability")
if capability == nil && capability[0] != 0x00 {
t.Fatalf("Untar should have kept the 'security.capability' xattr.")
}

capability, err := system.Lgetxattr(filepath.Join(origin, "2"), "security.capability")
require.NoError(t, err)
assert.EqualValues(t, capability, encoded)

test, err := system.Lgetxattr(filepath.Join(origin, "1"), "user.test")
require.NoError(t, err)
assert.EqualValues(t, test, []byte("helloWord"))
}
}

0 comments on commit 965fb12

Please sign in to comment.