|
|
|
@ -25,6 +25,7 @@ import (
|
|
|
|
|
"k8s.io/helm/pkg/helm/helmpath"
|
|
|
|
|
"os"
|
|
|
|
|
"path/filepath"
|
|
|
|
|
"syscall"
|
|
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
@ -213,19 +214,22 @@ func TestExtract(t *testing.T) {
|
|
|
|
|
//{"README.md", "so you know what's upp"},
|
|
|
|
|
//{"script.sh", "echo script"},
|
|
|
|
|
|
|
|
|
|
syscall.Umask(0000)
|
|
|
|
|
|
|
|
|
|
var tarbuf bytes.Buffer
|
|
|
|
|
tw := tar.NewWriter(&tarbuf)
|
|
|
|
|
var files = []struct {
|
|
|
|
|
Name, Body string
|
|
|
|
|
Mode int64
|
|
|
|
|
}{
|
|
|
|
|
{"../../plugin.yaml", "sneaky plugin metadata"},
|
|
|
|
|
{"README.md", "some text"},
|
|
|
|
|
{"../../plugin.yaml", "sneaky plugin metadata", 0600},
|
|
|
|
|
{"README.md", "some text", 0777},
|
|
|
|
|
}
|
|
|
|
|
for _, file := range files {
|
|
|
|
|
hdr := &tar.Header{
|
|
|
|
|
Name: file.Name,
|
|
|
|
|
Typeflag: tar.TypeReg,
|
|
|
|
|
Mode: 0600,
|
|
|
|
|
Mode: file.Mode,
|
|
|
|
|
Size: int64(len(file.Body)),
|
|
|
|
|
}
|
|
|
|
|
if err := tw.WriteHeader(hdr); err != nil {
|
|
|
|
@ -257,21 +261,25 @@ func TestExtract(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pluginYAMLFullPath := filepath.Join(cacheDir, "plugin.yaml")
|
|
|
|
|
if _, err := os.Stat(pluginYAMLFullPath); err != nil {
|
|
|
|
|
if info, err := os.Stat(pluginYAMLFullPath); err != nil {
|
|
|
|
|
if os.IsNotExist(err) {
|
|
|
|
|
t.Errorf("Expected %s to exist but doesn't", pluginYAMLFullPath)
|
|
|
|
|
} else {
|
|
|
|
|
t.Error(err)
|
|
|
|
|
}
|
|
|
|
|
} else if info.Mode().Perm() != 0600 {
|
|
|
|
|
t.Errorf("Expected %s to have 0600 mode it but has %o", pluginYAMLFullPath, info.Mode().Perm())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
readmeFullPath := filepath.Join(cacheDir, "README.md")
|
|
|
|
|
if _, err := os.Stat(readmeFullPath); err != nil {
|
|
|
|
|
if info, err := os.Stat(readmeFullPath); err != nil {
|
|
|
|
|
if os.IsNotExist(err) {
|
|
|
|
|
t.Errorf("Expected %s to exist but doesn't", readmeFullPath)
|
|
|
|
|
} else {
|
|
|
|
|
t.Error(err)
|
|
|
|
|
}
|
|
|
|
|
} else if info.Mode().Perm() != 0777 {
|
|
|
|
|
t.Errorf("Expected %s to have 0777 mode it but has %o", readmeFullPath, info.Mode().Perm())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|