pull/32390/merge
Mukul Negi 17 hours ago committed by GitHub
commit 1ec340c3a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -29,7 +29,6 @@ import (
"path/filepath"
"strconv"
"strings"
"syscall"
"testing"
"github.com/stretchr/testify/assert"
@ -167,8 +166,7 @@ func TestExtract(t *testing.T) {
tempDir := t.TempDir()
// Get current umask to predict expected permissions
currentUmask := syscall.Umask(0)
syscall.Umask(currentUmask)
currentUmask := processUmask()
// Write a tarball to a buffer for us to extract
var tarbuf bytes.Buffer
@ -226,8 +224,10 @@ func TestExtract(t *testing.T) {
require.NotErrorIs(t, err, fs.ErrNotExist, "Expected %s to exist but doesn't", pluginYAMLFullPath)
}
require.NoError(t, err)
require.Equalf(t, expectedPluginYAMLPerm, info.Mode().Perm(), "Expected %s to have %o mode but has %o (umask: %o)",
pluginYAMLFullPath, expectedPluginYAMLPerm, info.Mode().Perm(), currentUmask)
if posixPermsSupported {
require.Equalf(t, expectedPluginYAMLPerm, info.Mode().Perm(), "Expected %s to have %o mode but has %o (umask: %o)",
pluginYAMLFullPath, expectedPluginYAMLPerm, info.Mode().Perm(), currentUmask)
}
readmeFullPath := filepath.Join(tempDir, "README.md")
info, err = os.Stat(readmeFullPath)
@ -235,8 +235,10 @@ func TestExtract(t *testing.T) {
require.NotErrorIs(t, err, fs.ErrNotExist, "Expected %s to exist but doesn't", readmeFullPath)
}
require.NoError(t, err)
require.Equalf(t, expectedReadmePerm, info.Mode().Perm(), "Expected %s to have %o mode but has %o (umask: %o)",
readmeFullPath, expectedReadmePerm, info.Mode().Perm(), currentUmask)
if posixPermsSupported {
require.Equalf(t, expectedReadmePerm, info.Mode().Perm(), "Expected %s to have %o mode but has %o (umask: %o)",
readmeFullPath, expectedReadmePerm, info.Mode().Perm(), currentUmask)
}
}
func TestCleanJoin(t *testing.T) {

@ -0,0 +1,31 @@
//go:build !windows
/*
Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package installer
import "syscall"
// posixPermsSupported reports whether the platform honors POSIX file
// permission bits, allowing tests to assert on extracted file modes.
const posixPermsSupported = true
// processUmask returns the current process umask without changing it.
func processUmask() int {
umask := syscall.Umask(0)
syscall.Umask(umask)
return umask
}

@ -0,0 +1,28 @@
//go:build windows
/*
Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package installer
// posixPermsSupported reports whether the platform honors POSIX file
// permission bits, allowing tests to assert on extracted file modes.
// Windows does not, so permission assertions are skipped there.
const posixPermsSupported = false
// processUmask returns 0 on Windows, which has no umask concept.
func processUmask() int {
return 0
}
Loading…
Cancel
Save