Assert all APIs have a status subresource

Signed-off-by: Monis Khan <mok@vmware.com>
This commit is contained in:
Monis Khan 2021-02-10 21:20:19 -05:00
parent 0a9f446893
commit 4c304e4224
No known key found for this signature in database
GPG Key ID: 52C90ADA01B269B8

View File

@ -103,6 +103,12 @@ func TestGetAPIResourceList(t *testing.T) {
Verbs: []string{"delete", "deletecollection", "get", "list", "patch", "create", "update", "watch"}, Verbs: []string{"delete", "deletecollection", "get", "list", "patch", "create", "update", "watch"},
Categories: []string{"pinniped"}, 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"}, Verbs: []string{"delete", "deletecollection", "get", "list", "patch", "create", "update", "watch"},
Categories: []string{"pinniped"}, 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"}, Verbs: []string{"delete", "deletecollection", "get", "list", "patch", "create", "update", "watch"},
Categories: []string{"pinniped", "pinniped-authenticator", "pinniped-authenticators"}, Categories: []string{"pinniped", "pinniped-authenticator", "pinniped-authenticators"},
}, },
{
Name: "webhookauthenticators/status",
Namespaced: false,
Kind: "WebhookAuthenticator",
Verbs: []string{"get", "patch", "update"},
},
{ {
Name: "jwtauthenticators", Name: "jwtauthenticators",
SingularName: "jwtauthenticator", SingularName: "jwtauthenticator",
@ -198,6 +216,12 @@ func TestGetAPIResourceList(t *testing.T) {
Verbs: []string{"delete", "deletecollection", "get", "list", "patch", "create", "update", "watch"}, Verbs: []string{"delete", "deletecollection", "get", "list", "patch", "create", "update", "watch"},
Categories: []string{"pinniped", "pinniped-authenticator", "pinniped-authenticators"}, 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.Run("Pinniped resources do not have short names", func(t *testing.T) {
t.Parallel() t.Parallel()
for _, r := range resources { for _, r := range resources {