Skip to content

Commit

Permalink
admission_test.go(TestAdmit): eliminate duplicated code by using exis…
Browse files Browse the repository at this point in the history
…ting method.
  • Loading branch information
php-coder committed Nov 14, 2017
1 parent df809c4 commit c634e11
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions pkg/security/admission/admission_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,18 +497,8 @@ func TestAdmit(t *testing.T) {
v.pod.Spec.Containers, v.pod.Spec.InitContainers = v.pod.Spec.InitContainers, v.pod.Spec.Containers

if !v.shouldAdmit {
attrs := kadmission.NewAttributesRecord(v.pod, nil, kapi.Kind("Pod").WithVersion("version"), v.pod.Namespace, v.pod.Name, kapi.Resource("pods").WithVersion("version"), "", kadmission.Create, &user.DefaultInfo{})
err := p.Admit(attrs)
if err != nil {
t.Errorf("Expected %s to pass with escalated scc but got error %v", k, err)
}
validatedSCC, ok := v.pod.Annotations[allocator.ValidatedSCCAnnotation]
if !ok {
t.Errorf("%s expected to find the validated annotation on the pod for the scc but found none", k)
}
if validatedSCC != adminSCC.Name {
t.Errorf("%s should have validated against %s but found %s", k, adminSCC.Name, validatedSCC)
}
// pods that were rejected by strict SCC, should pass with relaxed SCC
testSCCAdmission(v.pod, p, adminSCC.Name, k, t)
}
}
}
Expand Down

0 comments on commit c634e11

Please sign in to comment.