Skip to content

Commit b53134f

Browse files
committed
Test anonymous and RBAC handling via config file
1 parent 264cd64 commit b53134f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/integration/auth/authz_config_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package auth
1818

1919
import (
20+
"bytes"
2021
"context"
2122
"encoding/json"
2223
"fmt"
@@ -34,6 +35,7 @@ import (
3435
"k8s.io/apiserver/pkg/features"
3536
utilfeature "k8s.io/apiserver/pkg/util/feature"
3637
clientset "k8s.io/client-go/kubernetes"
38+
"k8s.io/client-go/rest"
3739
featuregatetesting "k8s.io/component-base/featuregate/testing"
3840
kubeapiservertesting "k8s.io/kubernetes/cmd/kube-apiserver/app/testing"
3941
"k8s.io/kubernetes/test/integration/authutil"
@@ -63,6 +65,16 @@ authorizers:
6365
)
6466
t.Cleanup(server.TearDownFn)
6567

68+
// Make sure anonymous requests work
69+
anonymousClient := clientset.NewForConfigOrDie(rest.AnonymousClientConfig(server.ClientConfig))
70+
healthzResult, err := anonymousClient.DiscoveryClient.RESTClient().Get().AbsPath("/healthz").Do(context.TODO()).Raw()
71+
if !bytes.Equal(healthzResult, []byte(`ok`)) {
72+
t.Fatalf("expected 'ok', got %s", string(healthzResult))
73+
}
74+
if err != nil {
75+
t.Fatal(err)
76+
}
77+
6678
adminClient := clientset.NewForConfigOrDie(server.ClientConfig)
6779

6880
sar := &authorizationv1.SubjectAccessReview{Spec: authorizationv1.SubjectAccessReviewSpec{

0 commit comments

Comments
 (0)