mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 23:47:50 +00:00
make well-known users and groups into constants
This commit is contained in:
@@ -24,9 +24,9 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
anonymousUser = "system:anonymous"
|
||||
anonymousUser = user.Anonymous
|
||||
|
||||
unauthenticatedGroup = "system:unauthenticated"
|
||||
unauthenticatedGroup = user.AllUnauthenticated
|
||||
)
|
||||
|
||||
func NewAuthenticator() authenticator.Request {
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"k8s.io/kubernetes/pkg/auth/authenticator"
|
||||
"k8s.io/kubernetes/pkg/auth/user"
|
||||
"k8s.io/kubernetes/pkg/util/sets"
|
||||
)
|
||||
|
||||
@@ -32,10 +33,10 @@ func TestAnonymous(t *testing.T) {
|
||||
if !ok {
|
||||
t.Fatalf("Unexpectedly unauthenticated")
|
||||
}
|
||||
if u.GetName() != "system:anonymous" {
|
||||
t.Fatalf("Expected username %s, got %s", "system:anonymous", u.GetName())
|
||||
if u.GetName() != user.Anonymous {
|
||||
t.Fatalf("Expected username %s, got %s", user.Anonymous, u.GetName())
|
||||
}
|
||||
if !sets.NewString(u.GetGroups()...).Equal(sets.NewString("system:unauthenticated")) {
|
||||
t.Fatalf("Expected group %s, got %v", "system:unauthenticated", u.GetGroups())
|
||||
if !sets.NewString(u.GetGroups()...).Equal(sets.NewString(user.AllUnauthenticated)) {
|
||||
t.Fatalf("Expected group %s, got %v", user.AllUnauthenticated, u.GetGroups())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user