mirror of
https://github.com/vmware-tanzu/pinniped.git
synced 2026-09-12 02:56:14 +00:00
Merge branch 'main' into dynamic_clients
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#! Copyright 2020-2021 the Pinniped contributors. All Rights Reserved.
|
||||
#! Copyright 2020-2022 the Pinniped contributors. All Rights Reserved.
|
||||
#! SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
---
|
||||
@@ -6,3 +6,8 @@ apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: tools
|
||||
labels:
|
||||
# When deploying onto a cluster which has PSAs enabled by default for namespaces,
|
||||
# effectively disable them for this namespace. This namespace is only for integration
|
||||
# testing helper tools, and should never be deployed in production installs.
|
||||
pod-security.kubernetes.io/enforce: privileged
|
||||
|
||||
@@ -949,6 +949,8 @@ func TestImpersonationProxy(t *testing.T) { //nolint:gocyclo // yeah, it's compl
|
||||
Image: env.ShellContainerImage,
|
||||
ImagePullPolicy: corev1.PullIfNotPresent,
|
||||
Command: []string{"sh", "-c", "sleep 3600"},
|
||||
// Use a restrictive security context just in case the test cluster has PSAs enabled.
|
||||
SecurityContext: testlib.RestrictiveSecurityContext(),
|
||||
},
|
||||
},
|
||||
ServiceAccountName: saName,
|
||||
@@ -1090,6 +1092,8 @@ func TestImpersonationProxy(t *testing.T) { //nolint:gocyclo // yeah, it's compl
|
||||
corev1.ResourceCPU: resource.MustParse("10m"),
|
||||
},
|
||||
},
|
||||
// Use a restrictive security context just in case the test cluster has PSAs enabled.
|
||||
SecurityContext: testlib.RestrictiveSecurityContext(),
|
||||
}}})
|
||||
|
||||
// Try "kubectl exec" through the impersonation proxy.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2020-2021 the Pinniped contributors. All Rights Reserved.
|
||||
// Copyright 2020-2022 the Pinniped contributors. All Rights Reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
package integration
|
||||
|
||||
@@ -176,6 +176,8 @@ func TestWhoAmI_ServiceAccount_TokenRequest_Parallel(t *testing.T) {
|
||||
Image: env.ShellContainerImage,
|
||||
ImagePullPolicy: corev1.PullIfNotPresent,
|
||||
Command: []string{"sh", "-c", "sleep 3600"},
|
||||
// Use a restrictive security context just in case the test cluster has PSAs enabled.
|
||||
SecurityContext: testlib.RestrictiveSecurityContext(),
|
||||
},
|
||||
},
|
||||
ServiceAccountName: sa.Name,
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
"k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
aggregatorclient "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset"
|
||||
"k8s.io/utils/pointer"
|
||||
|
||||
auth1alpha1 "go.pinniped.dev/generated/latest/apis/concierge/authentication/v1alpha1"
|
||||
"go.pinniped.dev/generated/latest/apis/concierge/login/v1alpha1"
|
||||
@@ -606,6 +607,19 @@ func CreateTokenCredentialRequest(ctx context.Context, t *testing.T, spec v1alph
|
||||
)
|
||||
}
|
||||
|
||||
// RestrictiveSecurityContext returns a container SecurityContext which will be allowed by the most
|
||||
// restrictive level of Pod Security Admission policy (as of Kube v1.25's policies).
|
||||
func RestrictiveSecurityContext() *corev1.SecurityContext {
|
||||
return &corev1.SecurityContext{
|
||||
Capabilities: &corev1.Capabilities{
|
||||
Drop: []corev1.Capability{"ALL"},
|
||||
},
|
||||
RunAsNonRoot: pointer.Bool(true),
|
||||
AllowPrivilegeEscalation: pointer.Bool(false),
|
||||
SeccompProfile: &corev1.SeccompProfile{Type: corev1.SeccompProfileTypeRuntimeDefault},
|
||||
}
|
||||
}
|
||||
|
||||
func CreatePod(ctx context.Context, t *testing.T, name, namespace string, spec corev1.PodSpec) *corev1.Pod {
|
||||
t.Helper()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user