internal/auth/flags_test.go
Rama main · réplica de lectura del repositorio original.
package auth
import (
"strings"
"testing"
)
func TestNoIdentityMeansNoImpersonationFlags(t *testing.T) {
if got := KubectlFlags(t.Context()); got != nil {
t.Fatalf("flags = %v, want none", got)
}
if got := HelmFlags(AsServer(t.Context())); got != nil {
t.Fatalf("flags = %v, want none", got)
}
}
func TestKubectlAndHelmAreToldWhoIsAsking(t *testing.T) {
ctx := WithIdentity(t.Context(), Identity{
User: "[email protected]",
Groups: []string{"platform", "sre"},
})
kubectl := strings.Join(KubectlFlags(ctx), " ")
if kubectl != "--as [email protected] --as-group platform --as-group sre" {
t.Fatalf("kubectl flags = %q", kubectl)
}
helm := strings.Join(HelmFlags(ctx), " ")
if helm != "--kube-as-user [email protected] --kube-as-group platform --kube-as-group sre" {
t.Fatalf("helm flags = %q", helm)
}
}