From 4c304e4224b8cbc52c8e3611a0eaf9e4b3f64f4b Mon Sep 17 00:00:00 2001 From: Monis Khan Date: Wed, 10 Feb 2021 21:20:19 -0500 Subject: [PATCH] Assert all APIs have a status subresource Signed-off-by: Monis Khan --- test/integration/kube_api_discovery_test.go | 50 +++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/test/integration/kube_api_discovery_test.go b/test/integration/kube_api_discovery_test.go index 9bab7796..c7783b81 100644 --- a/test/integration/kube_api_discovery_test.go +++ b/test/integration/kube_api_discovery_test.go @@ -103,6 +103,12 @@ func TestGetAPIResourceList(t *testing.T) { Verbs: []string{"delete", "deletecollection", "get", "list", "patch", "create", "update", "watch"}, Categories: []string{"pinniped"}, }, + { + Name: "federationdomains/status", + Namespaced: true, + Kind: "FederationDomain", + Verbs: []string{"get", "patch", "update"}, + }, }, }, }, @@ -163,6 +169,12 @@ func TestGetAPIResourceList(t *testing.T) { Verbs: []string{"delete", "deletecollection", "get", "list", "patch", "create", "update", "watch"}, Categories: []string{"pinniped"}, }, + { + Name: "credentialissuers/status", + Namespaced: false, + Kind: "CredentialIssuer", + Verbs: []string{"get", "patch", "update"}, + }, }, }, }, @@ -190,6 +202,12 @@ func TestGetAPIResourceList(t *testing.T) { Verbs: []string{"delete", "deletecollection", "get", "list", "patch", "create", "update", "watch"}, Categories: []string{"pinniped", "pinniped-authenticator", "pinniped-authenticators"}, }, + { + Name: "webhookauthenticators/status", + Namespaced: false, + Kind: "WebhookAuthenticator", + Verbs: []string{"get", "patch", "update"}, + }, { Name: "jwtauthenticators", SingularName: "jwtauthenticator", @@ -198,6 +216,12 @@ func TestGetAPIResourceList(t *testing.T) { Verbs: []string{"delete", "deletecollection", "get", "list", "patch", "create", "update", "watch"}, Categories: []string{"pinniped", "pinniped-authenticator", "pinniped-authenticators"}, }, + { + Name: "jwtauthenticators/status", + Namespaced: false, + Kind: "JWTAuthenticator", + Verbs: []string{"get", "patch", "update"}, + }, }, }, }, @@ -253,6 +277,32 @@ func TestGetAPIResourceList(t *testing.T) { } }) + t.Run("every API has a status subresource", func(t *testing.T) { + t.Parallel() + + var regular, status []string + + for _, r := range resources { + if !strings.Contains(r.GroupVersion, env.APIGroupSuffix) { + continue + } + + for _, a := range r.APIResources { + if a.Name == "tokencredentialrequests" { + continue // our special aggregated API with its own magical properties + } + + if strings.HasSuffix(a.Name, "/status") { + status = append(status, strings.TrimSuffix(a.Name, "/status")) + } else { + regular = append(regular, a.Name) + } + } + } + + assert.Equal(t, regular, status) + }) + t.Run("Pinniped resources do not have short names", func(t *testing.T) { t.Parallel() for _, r := range resources {