Merge pull request #86573 from zhlhahaha/e2e_kubeadm_1410

add extra group and usage check for bootstraptoken
This commit is contained in:
Kubernetes Prow Robot 2019-12-25 21:49:38 -08:00 committed by GitHub
commit 2914ba8e04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,6 +20,7 @@ import (
corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
bootstrapapi "k8s.io/cluster-bootstrap/token/api"
"k8s.io/kubernetes/test/e2e/framework"
"github.com/onsi/ginkgo"
@ -54,8 +55,12 @@ var _ = Describe("bootstrap token", func() {
tokenNum := 0
for _, s := range secrets.Items {
if s.Type == corev1.SecretTypeBootstrapToken {
//TODO: might be we want to further check tokens (auth-extra-groups, usage etc)
// check extra group and usage of token, make sure at least one token exist
if s.Type == corev1.SecretTypeBootstrapToken && string(s.Data[bootstrapapi.BootstrapTokenExtraGroupsKey]) == bootstrapTokensGroup {
usageBootstrapAuthentication := string(s.Data[bootstrapapi.BootstrapTokenUsageAuthentication])
usageBootstrapSigning := string(s.Data[bootstrapapi.BootstrapTokenUsageSigningKey])
gomega.Expect(usageBootstrapAuthentication).Should(gomega.Equal("true"), "the bootstrap token should be able to be used for authentication")
gomega.Expect(usageBootstrapSigning).Should(gomega.Equal("true"), "the bootstrap token should be able to be used for signing")
tokenNum++
}
}