mirror of https://github.com/k3s-io/k3s
add a test case which check secret's type
parent
e763a3c56d
commit
1c8d0eec01
|
@ -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{
|
saIns := &v1.ServiceAccount{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "default",
|
Name: "default",
|
||||||
|
@ -91,6 +105,11 @@ func TestIsServiceAccountToken(t *testing.T) {
|
||||||
sa: saInsUIDNotEqual,
|
sa: saInsUIDNotEqual,
|
||||||
expect: false,
|
expect: false,
|
||||||
},
|
},
|
||||||
|
"service account type not equal": {
|
||||||
|
secret: secretTypeMistmatch,
|
||||||
|
sa: saIns,
|
||||||
|
expect: false,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for k, v := range tests {
|
for k, v := range tests {
|
||||||
|
|
Loading…
Reference in New Issue