set/validate object namespace before admission

This commit is contained in:
Jordan Liggitt
2020-09-09 01:12:31 -04:00
parent f0ef426238
commit 92422a7305
8 changed files with 147 additions and 52 deletions

View File

@@ -203,8 +203,8 @@ func TestServiceAccountTokenCreate(t *testing.T) {
treqWithBadNamespace := treq.DeepCopy()
treqWithBadNamespace.Namespace = "invalid-namespace"
if resp, err := cs.CoreV1().ServiceAccounts(sa.Namespace).CreateToken(context.TODO(), sa.Name, treqWithBadNamespace, metav1.CreateOptions{}); err == nil || !strings.Contains(err.Error(), "must match the service account namespace") {
t.Fatalf("expected err creating token with mismatched namespace but got: %#v", resp)
if resp, err := cs.CoreV1().ServiceAccounts(sa.Namespace).CreateToken(context.TODO(), sa.Name, treqWithBadNamespace, metav1.CreateOptions{}); err == nil || !strings.Contains(err.Error(), "does not match the namespace") {
t.Fatalf("expected err creating token with mismatched namespace but got: %#v, %v", resp, err)
}
warningHandler.clear()