|
| 1 | +package tests |
| 2 | + |
| 3 | +import ( |
| 4 | + . "github.com/onsi/ginkgo/v2" |
| 5 | + . "github.com/onsi/gomega" |
| 6 | + |
| 7 | + securityv1 "github.com/openshift/api/security/v1" |
| 8 | + apps "k8s.io/api/apps/v1" |
| 9 | + core "k8s.io/api/core/v1" |
| 10 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 11 | + "k8s.io/apimachinery/pkg/types" |
| 12 | + "sigs.k8s.io/controller-runtime/pkg/client" |
| 13 | + |
| 14 | + "kubevirt.io/ssp-operator/internal/common" |
| 15 | +) |
| 16 | + |
| 17 | +var _ = Describe("Required SCC annotation", func() { |
| 18 | + It("[test_id:TODO] SSP pods should have 'openshift.io/required-scc' annotation", func() { |
| 19 | + deployment := &apps.Deployment{} |
| 20 | + Expect(apiClient.Get(ctx, types.NamespacedName{ |
| 21 | + Name: strategy.GetSSPDeploymentName(), |
| 22 | + Namespace: strategy.GetSSPDeploymentNameSpace(), |
| 23 | + }, deployment)).To(Succeed()) |
| 24 | + |
| 25 | + selector, err := metav1.LabelSelectorAsSelector(deployment.Spec.Selector) |
| 26 | + Expect(err).ToNot(HaveOccurred()) |
| 27 | + |
| 28 | + pods := &core.PodList{} |
| 29 | + Expect(apiClient.List(ctx, pods, client.MatchingLabelsSelector{Selector: selector})).To(Succeed()) |
| 30 | + Expect(pods.Items).ToNot(BeEmpty()) |
| 31 | + |
| 32 | + for _, pod := range pods.Items { |
| 33 | + Expect(pod.Annotations).To(HaveKeyWithValue(securityv1.RequiredSCCAnnotation, common.RequiredSCCAnnotationValue), |
| 34 | + "SSP pod %s/%s does not have required annotation", |
| 35 | + pod.Namespace, pod.Name, |
| 36 | + ) |
| 37 | + } |
| 38 | + }) |
| 39 | +}) |
0 commit comments