pkg/chrootarchive: gofumpt test files
Excluding non-test files, as a large refactor of those files is being worked on. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
dee3f716b3
commit
d4d242ba76
2 changed files with 9 additions and 9 deletions
|
@ -47,10 +47,10 @@ func TestChrootTarUntar(t *testing.T) {
|
|||
if err := os.Mkdir(src, 0o700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(src, "toto"), []byte("hello toto"), 0644); err != nil {
|
||||
if err := os.WriteFile(filepath.Join(src, "toto"), []byte("hello toto"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(src, "lolo"), []byte("hello lolo"), 0644); err != nil {
|
||||
if err := os.WriteFile(filepath.Join(src, "lolo"), []byte("hello lolo"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
stream, err := archive.Tar(src, archive.Uncompressed)
|
||||
|
@ -75,7 +75,7 @@ func TestChrootUntarWithHugeExcludesList(t *testing.T) {
|
|||
if err := os.Mkdir(src, 0o700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(src, "toto"), []byte("hello toto"), 0644); err != nil {
|
||||
if err := os.WriteFile(filepath.Join(src, "toto"), []byte("hello toto"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
stream, err := archive.Tar(src, archive.Uncompressed)
|
||||
|
@ -110,7 +110,7 @@ func prepareSourceDirectory(numberOfFiles int, targetPath string, makeSymLinks b
|
|||
fileData := []byte("fooo")
|
||||
for n := 0; n < numberOfFiles; n++ {
|
||||
fileName := fmt.Sprintf("file-%d", n)
|
||||
if err := os.WriteFile(filepath.Join(targetPath, fileName), fileData, 0700); err != nil {
|
||||
if err := os.WriteFile(filepath.Join(targetPath, fileName), fileData, 0o700); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if makeSymLinks {
|
||||
|
@ -288,7 +288,7 @@ func TestChrootUntarPath(t *testing.T) {
|
|||
buf := new(bytes.Buffer)
|
||||
buf.ReadFrom(stream)
|
||||
tarfile := filepath.Join(tmpdir, "src.tar")
|
||||
if err := os.WriteFile(tarfile, buf.Bytes(), 0644); err != nil {
|
||||
if err := os.WriteFile(tarfile, buf.Bytes(), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := UntarPath(tarfile, dest); err != nil {
|
||||
|
@ -355,7 +355,7 @@ func TestChrootApplyDotDotFile(t *testing.T) {
|
|||
if err := os.Mkdir(src, 0o700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(src, "..gitme"), []byte(""), 0644); err != nil {
|
||||
if err := os.WriteFile(filepath.Join(src, "..gitme"), []byte(""), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
stream, err := archive.Tar(src, archive.Uncompressed)
|
||||
|
|
|
@ -34,7 +34,7 @@ func TestUntarWithMaliciousSymlinks(t *testing.T) {
|
|||
|
||||
// Add a file into a directory above root
|
||||
// Ensure that we can't access this file while tarring.
|
||||
err = os.WriteFile(filepath.Join(dir, "host-file"), []byte("I am a host file"), 0644)
|
||||
err = os.WriteFile(filepath.Join(dir, "host-file"), []byte("I am a host file"), 0o644)
|
||||
assert.NilError(t, err)
|
||||
|
||||
// Create some data which which will be copied into the "container" root into
|
||||
|
@ -44,7 +44,7 @@ func TestUntarWithMaliciousSymlinks(t *testing.T) {
|
|||
data := filepath.Join(dir, "data")
|
||||
err = os.Mkdir(data, 0o755)
|
||||
assert.NilError(t, err)
|
||||
err = os.WriteFile(filepath.Join(data, "local-file"), []byte("pwn3d"), 0644)
|
||||
err = os.WriteFile(filepath.Join(data, "local-file"), []byte("pwn3d"), 0o644)
|
||||
assert.NilError(t, err)
|
||||
|
||||
safe := filepath.Join(root, "safe")
|
||||
|
@ -99,7 +99,7 @@ func TestTarWithMaliciousSymlinks(t *testing.T) {
|
|||
|
||||
// Add a file into a directory above root
|
||||
// Ensure that we can't access this file while tarring.
|
||||
err = os.WriteFile(filepath.Join(dir, "host-file"), hostFileData, 0644)
|
||||
err = os.WriteFile(filepath.Join(dir, "host-file"), hostFileData, 0o644)
|
||||
assert.NilError(t, err)
|
||||
|
||||
safe := filepath.Join(root, "safe")
|
||||
|
|
Loading…
Reference in a new issue