Skip to content

Commit

Permalink
feat(e2e): Check install operator SecurityContext
Browse files Browse the repository at this point in the history
  • Loading branch information
gansheer committed Sep 15, 2023
1 parent 72a6abe commit 1aae831
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions e2e/install/cli/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ func TestBasicInstallation(t *testing.T) {
Eventually(PlatformConditionStatus(ns, v1.IntegrationPlatformConditionReady), TestTimeoutShort).
Should(Equal(corev1.ConditionTrue))

// Check if default security context has been applyed
Eventually(OperatorPodHas(ns, func(pod *corev1.Pod) bool {
if pod.Spec.Containers == nil || len(pod.Spec.Containers) == 0 {
return false
}
// exclude user for openshift
pod.Spec.Containers[0].SecurityContext.RunAsUser = nil
return reflect.DeepEqual(pod.Spec.Containers[0].SecurityContext, kubernetes.DefaultOperatorSecurityContext())
}), TestTimeoutShort).Should(BeTrue())

t.Run("run yaml", func(t *testing.T) {
Expect(KamelRunWithID(operatorID, ns, "files/yaml.yaml").Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "yaml"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Expand Down
10 changes: 10 additions & 0 deletions e2e/support/test_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,16 @@ func OperatorImage(ns string) func() string {
}
}

func OperatorPodHas(ns string, predicate func(pod *corev1.Pod) bool) func() bool {
return func() bool {
pod := OperatorPod(ns)()
if pod == nil {
return false
}
return predicate(pod)
}
}

func OperatorPodPhase(ns string) func() corev1.PodPhase {
return func() corev1.PodPhase {
pod := OperatorPod(ns)()
Expand Down

0 comments on commit 1aae831

Please sign in to comment.