Skip to content

Commit 2914ba8

Browse files
authored
Merge pull request kubernetes#86573 from zhlhahaha/e2e_kubeadm_1410
add extra group and usage check for bootstraptoken
2 parents f13e2ed + 299a9c8 commit 2914ba8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

test/e2e_kubeadm/bootstrap_token_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
corev1 "k8s.io/api/core/v1"
2121
rbacv1 "k8s.io/api/rbac/v1"
2222
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23+
bootstrapapi "k8s.io/cluster-bootstrap/token/api"
2324
"k8s.io/kubernetes/test/e2e/framework"
2425

2526
"github.com/onsi/ginkgo"
@@ -54,8 +55,12 @@ var _ = Describe("bootstrap token", func() {
5455

5556
tokenNum := 0
5657
for _, s := range secrets.Items {
57-
if s.Type == corev1.SecretTypeBootstrapToken {
58-
//TODO: might be we want to further check tokens (auth-extra-groups, usage etc)
58+
// check extra group and usage of token, make sure at least one token exist
59+
if s.Type == corev1.SecretTypeBootstrapToken && string(s.Data[bootstrapapi.BootstrapTokenExtraGroupsKey]) == bootstrapTokensGroup {
60+
usageBootstrapAuthentication := string(s.Data[bootstrapapi.BootstrapTokenUsageAuthentication])
61+
usageBootstrapSigning := string(s.Data[bootstrapapi.BootstrapTokenUsageSigningKey])
62+
gomega.Expect(usageBootstrapAuthentication).Should(gomega.Equal("true"), "the bootstrap token should be able to be used for authentication")
63+
gomega.Expect(usageBootstrapSigning).Should(gomega.Equal("true"), "the bootstrap token should be able to be used for signing")
5964
tokenNum++
6065
}
6166
}

0 commit comments

Comments
 (0)