Skip to content

Commit df809c4

Browse files
committed
admission_test.go(testSCCAdmission): print test case name when test fails.
1 parent d076bb5 commit df809c4

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

pkg/security/admission/admission_test.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -939,16 +939,16 @@ func TestAdmitWithPrioritizedSCC(t *testing.T) {
939939

940940
// create the admission plugin
941941
plugin := NewTestAdmission(cache, tc)
942-
// match the restricted SCC
943-
testSCCAdmission(goodPod(), plugin, restricted.Name, t)
944-
// match matchingPrioritySCCOne by setting RunAsUser to 5
942+
943+
testSCCAdmission(goodPod(), plugin, restricted.Name, "match the restricted SCC", t)
944+
945945
matchingPrioritySCCOnePod := goodPod()
946946
matchingPrioritySCCOnePod.Spec.Containers[0].SecurityContext.RunAsUser = &uidFive
947-
testSCCAdmission(matchingPrioritySCCOnePod, plugin, matchingPrioritySCCOne.Name, t)
948-
// match matchingPriorityAndScoreSCCOne by setting RunAsUser to 6
947+
testSCCAdmission(matchingPrioritySCCOnePod, plugin, matchingPrioritySCCOne.Name, "match matchingPrioritySCCOne by setting RunAsUser to 5", t)
948+
949949
matchingPriorityAndScoreSCCOnePod := goodPod()
950950
matchingPriorityAndScoreSCCOnePod.Spec.Containers[0].SecurityContext.RunAsUser = &uidSix
951-
testSCCAdmission(matchingPriorityAndScoreSCCOnePod, plugin, matchingPriorityAndScoreSCCOne.Name, t)
951+
testSCCAdmission(matchingPriorityAndScoreSCCOnePod, plugin, matchingPriorityAndScoreSCCOne.Name, "match matchingPriorityAndScoreSCCOne by setting RunAsUser to 6", t)
952952
}
953953

954954
func TestAdmitSeccomp(t *testing.T) {
@@ -1064,21 +1064,21 @@ func TestAdmitSeccomp(t *testing.T) {
10641064

10651065
// testSCCAdmission is a helper to admit the pod and ensure it was validated against the expected
10661066
// SCC.
1067-
func testSCCAdmission(pod *kapi.Pod, plugin kadmission.Interface, expectedSCC string, t *testing.T) {
1067+
func testSCCAdmission(pod *kapi.Pod, plugin kadmission.Interface, expectedSCC, testName string, t *testing.T) {
10681068
attrs := kadmission.NewAttributesRecord(pod, nil, kapi.Kind("Pod").WithVersion("version"), pod.Namespace, pod.Name, kapi.Resource("pods").WithVersion("version"), "", kadmission.Create, &user.DefaultInfo{})
10691069
err := plugin.Admit(attrs)
10701070
if err != nil {
1071-
t.Errorf("error admitting pod: %v", err)
1071+
t.Errorf("%s error admitting pod: %v", testName, err)
10721072
return
10731073
}
10741074

10751075
validatedSCC, ok := pod.Annotations[allocator.ValidatedSCCAnnotation]
10761076
if !ok {
1077-
t.Errorf("expected to find the validated annotation on the pod for the scc but found none")
1077+
t.Errorf("expected %q to find the validated annotation on the pod for the scc but found none", testName)
10781078
return
10791079
}
10801080
if validatedSCC != expectedSCC {
1081-
t.Errorf("should have validated against %s but found %s", expectedSCC, validatedSCC)
1081+
t.Errorf("%q should have validated against %s but found %s", testName, expectedSCC, validatedSCC)
10821082
}
10831083
}
10841084

0 commit comments

Comments
 (0)