@@ -302,11 +302,13 @@ func TestTarUntar(t *testing.T) {
302
302
{
303
303
name : "gakki" ,
304
304
data : "tmp/gakki" ,
305
+ omitted : true ,
305
306
fileType : SymLink ,
306
307
},
307
308
{
308
309
name : "relative_to_dest" ,
309
310
data : path .Join (dir2 , "foo" ),
311
+ omitted : true ,
310
312
fileType : SymLink ,
311
313
},
312
314
{
@@ -358,7 +360,7 @@ func TestTarUntar(t *testing.T) {
358
360
}
359
361
360
362
reader := bytes .NewBuffer (writer .Bytes ())
361
- if err := opts .untarAll (reader , dir2 , "" ); err != nil {
363
+ if err := opts .untarAll (fileSpec {}, reader , dir2 , "" ); err != nil {
362
364
t .Fatalf ("unexpected error: %v" , err )
363
365
}
364
366
@@ -419,7 +421,7 @@ func TestTarUntarWrongPrefix(t *testing.T) {
419
421
}
420
422
421
423
reader := bytes .NewBuffer (writer .Bytes ())
422
- err = opts .untarAll (reader , dir2 , "verylongprefix-showing-the-tar-was-tempered-with" )
424
+ err = opts .untarAll (fileSpec {}, reader , dir2 , "verylongprefix-showing-the-tar-was-tempered-with" )
423
425
if err == nil || ! strings .Contains (err .Error (), "tar contents corrupted" ) {
424
426
t .Fatalf ("unexpected error: %v" , err )
425
427
}
@@ -534,7 +536,7 @@ func TestBadTar(t *testing.T) {
534
536
}
535
537
536
538
opts := NewCopyOptions (genericclioptions .NewTestIOStreamsDiscard ())
537
- if err := opts .untarAll (& buf , dir , "/prefix" ); err != nil {
539
+ if err := opts .untarAll (fileSpec {}, & buf , dir , "/prefix" ); err != nil {
538
540
t .Errorf ("unexpected error: %v " , err )
539
541
t .FailNow ()
540
542
}
@@ -780,35 +782,20 @@ func TestUntar(t *testing.T) {
780
782
expected : "" ,
781
783
}}
782
784
783
- mkExpectation := func (expected , suffix string ) string {
784
- if expected == "" {
785
- return ""
786
- }
787
- return expected + suffix
788
- }
789
- mkBacklinkExpectation := func (expected , suffix string ) string {
790
- // "resolve" the back link relative to the expectation
791
- targetDir := filepath .Dir (filepath .Dir (expected ))
792
- // If the "resolved" target is not nested in basedir, it is escaping.
793
- if ! filepath .HasPrefix (targetDir , basedir ) {
794
- return ""
795
- }
796
- return expected + suffix
797
- }
798
785
links := []file {}
799
786
for _ , f := range files {
800
787
links = append (links , file {
801
788
path : f .path + "-innerlink" ,
802
789
linkTarget : "link-target" ,
803
- expected : mkExpectation ( f . expected , "-innerlink" ) ,
790
+ expected : "" ,
804
791
}, file {
805
792
path : f .path + "-innerlink-abs" ,
806
793
linkTarget : filepath .Join (basedir , "link-target" ),
807
- expected : mkExpectation ( f . expected , "-innerlink-abs" ) ,
794
+ expected : "" ,
808
795
}, file {
809
796
path : f .path + "-backlink" ,
810
797
linkTarget : filepath .Join (".." , "link-target" ),
811
- expected : mkBacklinkExpectation ( f . expected , "-backlink" ) ,
798
+ expected : "" ,
812
799
}, file {
813
800
path : f .path + "-outerlink-abs" ,
814
801
linkTarget : filepath .Join (testdir , "link-target" ),
@@ -832,7 +819,7 @@ func TestUntar(t *testing.T) {
832
819
file {
833
820
path : "nested/again/back-link" ,
834
821
linkTarget : "../../nested" ,
835
- expected : filepath . Join ( basedir , "nested/again/back-link" ) ,
822
+ expected : "" ,
836
823
},
837
824
file {
838
825
path : "nested/again/back-link/../../../back-link-file" ,
@@ -844,7 +831,7 @@ func TestUntar(t *testing.T) {
844
831
file {
845
832
path : "nested/back-link-first" ,
846
833
linkTarget : "../" ,
847
- expected : filepath . Join ( basedir , "nested/back-link-first" ) ,
834
+ expected : "" ,
848
835
},
849
836
file {
850
837
path : "nested/back-link-first/back-link-second" ,
@@ -892,7 +879,7 @@ func TestUntar(t *testing.T) {
892
879
output := (* testWriter )(t )
893
880
opts := NewCopyOptions (genericclioptions.IOStreams {In : & bytes.Buffer {}, Out : output , ErrOut : output })
894
881
895
- require .NoError (t , opts .untarAll (buf , filepath .Join (basedir ), "" ))
882
+ require .NoError (t , opts .untarAll (fileSpec {}, buf , filepath .Join (basedir ), "" ))
896
883
897
884
filepath .Walk (testdir , func (path string , info os.FileInfo , err error ) error {
898
885
if err != nil {
@@ -943,7 +930,7 @@ func TestUntar_SingleFile(t *testing.T) {
943
930
output := (* testWriter )(t )
944
931
opts := NewCopyOptions (genericclioptions.IOStreams {In : & bytes.Buffer {}, Out : output , ErrOut : output })
945
932
946
- require .NoError (t , opts .untarAll (buf , filepath .Join (dest ), srcName ))
933
+ require .NoError (t , opts .untarAll (fileSpec {}, buf , filepath .Join (dest ), srcName ))
947
934
cmpFileData (t , dest , content )
948
935
}
949
936
0 commit comments