Merge pull request #68815 from WanLinghao/sa_util_test_case

add a test case which check secret's type
pull/58/head
k8s-ci-robot 2018-09-26 19:22:25 -07:00 committed by GitHub
commit 745f75222f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 0 deletions

View File

@ -44,6 +44,20 @@ func TestIsServiceAccountToken(t *testing.T) {
},
}
secretTypeMistmatch := &v1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "token-secret-2",
Namespace: "default",
UID: "23456",
ResourceVersion: "1",
Annotations: map[string]string{
v1.ServiceAccountNameKey: "default",
v1.ServiceAccountUIDKey: "12345",
},
},
Type: v1.SecretTypeOpaque,
}
saIns := &v1.ServiceAccount{
ObjectMeta: metav1.ObjectMeta{
Name: "default",
@ -91,6 +105,11 @@ func TestIsServiceAccountToken(t *testing.T) {
sa: saInsUIDNotEqual,
expect: false,
},
"service account type not equal": {
secret: secretTypeMistmatch,
sa: saIns,
expect: false,
},
}
for k, v := range tests {