File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
internal/shared/util/image Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ func forceOwnershipRWX() archive.Filter {
23
23
h .Uid = uid
24
24
h .Gid = gid
25
25
h .Mode |= 0700
26
+ h .PAXRecords = nil
27
+ h .Xattrs = nil //nolint:staticcheck
26
28
return true , nil
27
29
}
28
30
}
Original file line number Diff line number Diff line change @@ -2,11 +2,39 @@ package image
2
2
3
3
import (
4
4
"archive/tar"
5
+ "os"
5
6
"testing"
6
7
7
8
"github.com/stretchr/testify/assert"
9
+ "github.com/stretchr/testify/require"
10
+ "k8s.io/apimachinery/pkg/util/rand"
8
11
)
9
12
13
+ func TestForceOwnershipRWX (t * testing.T ) {
14
+ h := tar.Header {
15
+ Name : "foo/bar" ,
16
+ Mode : 0000 ,
17
+ Uid : rand .Int (),
18
+ Gid : rand .Int (),
19
+ Xattrs : map [string ]string { //nolint:staticcheck
20
+ "foo" : "bar" ,
21
+ },
22
+ PAXRecords : map [string ]string {
23
+ "fizz" : "buzz" ,
24
+ },
25
+ }
26
+ ok , err := forceOwnershipRWX ()(& h )
27
+ require .NoError (t , err )
28
+ assert .True (t , ok )
29
+
30
+ assert .Equal (t , "foo/bar" , h .Name )
31
+ assert .Equal (t , int64 (0700 ), h .Mode )
32
+ assert .Equal (t , os .Getuid (), h .Uid )
33
+ assert .Equal (t , os .Getgid (), h .Gid )
34
+ assert .Nil (t , h .PAXRecords )
35
+ assert .Nil (t , h .Xattrs ) //nolint:staticcheck
36
+ }
37
+
10
38
func TestOnlyPath (t * testing.T ) {
11
39
type testCase struct {
12
40
name string
You can’t perform that action at this time.
0 commit comments