Skip to content

Commit

Permalink
provide dummy expected permissions for testing on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
langmartin committed Aug 15, 2019
1 parent cb8c602 commit 394ecaf
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 15 deletions.
29 changes: 22 additions & 7 deletions decompress_tar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"runtime"
"testing"
"time"
)
Expand Down Expand Up @@ -77,16 +78,30 @@ func testDecompressorPermissions(t *testing.T, d Decompressor, input string, exp
func TestDecompressTarPermissions(t *testing.T) {
d := new(tarDecompressor)
input := "./test-fixtures/decompress-tar/permissions.tar"
expected := map[string]int{
"directory/public": 0666,
"directory/private": 0600,
"directory/zero": 0,
"directory/exec": 0755,
"directory/setuid": 040000755,

var expected map[string]int
var masked int

if runtime.GOOS == "windows" {
expected = map[string]int{
"directory/public": 0666,
"directory/private": 0666,
"directory/exec": 0666,
"directory/setuid": 0666,
}
masked = 0666
} else {
expected = map[string]int{
"directory/public": 0666,
"directory/private": 0600,
"directory/exec": 0755,
"directory/setuid": 040000755,
}
masked = 0755
}

testDecompressorPermissions(t, d, input, expected, os.FileMode(0))

expected["directory/setuid"] = 0755
expected["directory/setuid"] = masked
testDecompressorPermissions(t, d, input, expected, os.FileMode(060000000))
}
30 changes: 22 additions & 8 deletions decompress_zip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package getter
import (
"os"
"path/filepath"
"runtime"
"testing"
)

Expand Down Expand Up @@ -101,17 +102,30 @@ func TestZipDecompressor(t *testing.T) {
func TestDecompressZipPermissions(t *testing.T) {
d := new(ZipDecompressor)
input := "./test-fixtures/decompress-zip/permissions.zip"
expected := map[string]int{
"directory/public": 0666,
"directory/private": 0600,
// zip won't add this file, since it can't be read
// "directory/zero": 0,
"directory/exec": 0755,
"directory/setuid": 040000755,

var expected map[string]int
var masked int

if runtime.GOOS == "windows" {
expected = map[string]int{
"directory/public": 0666,
"directory/private": 0666,
"directory/exec": 0666,
"directory/setuid": 0666,
}
masked = 0666
} else {
expected = map[string]int{
"directory/public": 0666,
"directory/private": 0600,
"directory/exec": 0755,
"directory/setuid": 040000755,
}
masked = 0755
}

testDecompressorPermissions(t, d, input, expected, os.FileMode(0))

expected["directory/setuid"] = 0755
expected["directory/setuid"] = masked
testDecompressorPermissions(t, d, input, expected, os.FileMode(060000000))
}
Binary file modified test-fixtures/decompress-tar/permissions.tar
Binary file not shown.

0 comments on commit 394ecaf

Please sign in to comment.