test(secretengine): skip the host launch test where the kernel refuses namespaces
This commit is contained in:
1 parent
64acc0e97a
commit
d9fda2338f
3 files changed
+34
No files matched your search
@@ -0,0 +1,26 @@
|
||||
package secretengine
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"os/exec"
|
||||
"syscall"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// requireNamespaces skips when the kernel refuses the user and network
|
||||
// namespaces extension confinement needs, as a default Docker seccomp profile
|
||||
// does. Confinement has no fallback, so such a host cannot launch extensions
|
||||
// at all and there is nothing here to test.
|
||||
func requireNamespaces(t *testing.T) {
|
||||
t.Helper()
|
||||
cmd := exec.CommandContext(t.Context(), os.Args[0], "-test.run=^$")
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{
|
||||
Cloneflags: syscall.CLONE_NEWUSER | syscall.CLONE_NEWNET,
|
||||
UidMappings: []syscall.SysProcIDMap{{ContainerID: os.Getuid(), HostID: os.Getuid(), Size: 1}},
|
||||
GidMappings: []syscall.SysProcIDMap{{ContainerID: os.Getgid(), HostID: os.Getgid(), Size: 1}},
|
||||
}
|
||||
if err := cmd.Run(); errors.Is(err, syscall.EPERM) || errors.Is(err, syscall.EINVAL) || errors.Is(err, syscall.ENOSPC) {
|
||||
t.Skipf("kernel refuses user and network namespaces: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
//go:build !linux
|
||||
|
||||
package secretengine
|
||||
|
||||
import "testing"
|
||||
|
||||
func requireNamespaces(*testing.T) {}
|
||||
@@ -130,6 +130,7 @@ func lanAddress(t *testing.T) string {
|
||||
}
|
||||
|
||||
func TestHostLaunch(t *testing.T) {
|
||||
requireNamespaces(t)
|
||||
t.Setenv("ARCHIE_TEST_SECRET", "host-only")
|
||||
t.Setenv("ARCHIE_TEST_PASSED", "granted")
|
||||
good := selfDigest(t)
|
||||
|
||||
Reference in new issue
Block a user