From b03d0e31ad1299f804a3388643dea63fd95672b3 Mon Sep 17 00:00:00 2001 From: Mayank Kumar Date: Sat, 2 Feb 2019 01:15:02 -0800 Subject: [PATCH] add positive ut for service account projection --- pkg/apis/core/validation/validation_test.go | 27 +++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/pkg/apis/core/validation/validation_test.go b/pkg/apis/core/validation/validation_test.go index 531bf2ff2d3..fca42d05230 100644 --- a/pkg/apis/core/validation/validation_test.go +++ b/pkg/apis/core/validation/validation_test.go @@ -6686,6 +6686,33 @@ func TestValidatePod(t *testing.T) { DNSPolicy: core.DNSClusterFirst, }, }, + { // valid serviceaccount token projected volume with serviceaccount name specified + ObjectMeta: metav1.ObjectMeta{Name: "valid-extended", Namespace: "ns"}, + Spec: core.PodSpec{ + ServiceAccountName: "some-service-account", + Containers: []core.Container{{Name: "ctr", Image: "image", ImagePullPolicy: "IfNotPresent", TerminationMessagePolicy: "File"}}, + RestartPolicy: core.RestartPolicyAlways, + DNSPolicy: core.DNSClusterFirst, + Volumes: []core.Volume{ + { + Name: "projected-volume", + VolumeSource: core.VolumeSource{ + Projected: &core.ProjectedVolumeSource{ + Sources: []core.VolumeProjection{ + { + ServiceAccountToken: &core.ServiceAccountTokenProjection{ + Audience: "foo-audience", + ExpirationSeconds: 6000, + Path: "foo-path", + }, + }, + }, + }, + }, + }, + }, + }, + }, } for _, pod := range successCases { if errs := ValidatePod(&pod); len(errs) != 0 {