@@ -11,6 +11,8 @@ import (
11
11
12
12
. "github.com/onsi/ginkgo/v2"
13
13
. "github.com/onsi/gomega"
14
+ "github.com/onsi/gomega/gexec"
15
+ "github.com/redhat-developer/odo/pkg/labels"
14
16
segment "github.com/redhat-developer/odo/pkg/segment/context"
15
17
"github.com/redhat-developer/odo/tests/helper"
16
18
)
@@ -533,6 +535,18 @@ CMD ["npm", "start"]
533
535
})
534
536
})
535
537
538
+ It ("should not set securitycontext for podsecurity admission on job's pod template" , func () {
539
+ if os .Getenv ("KUBERNETES" ) != "true" {
540
+ Skip ("This is a Kubernetes specific scenario, skipping" )
541
+ }
542
+ helper .Cmd ("odo" , "deploy" ).Should (func (session * gexec.Session ) {
543
+ component := helper .NewComponent (cmpName , "app" , labels .ComponentDeployMode , commonVar .Project , commonVar .CliRunner )
544
+ jobDef := component .GetJobDef ()
545
+ Expect (jobDef .Spec .Template .Spec .SecurityContext .RunAsNonRoot ).To (BeNil ())
546
+ Expect (jobDef .Spec .Template .Spec .SecurityContext .SeccompProfile ).To (BeNil ())
547
+ })
548
+ })
549
+
536
550
}
537
551
538
552
When ("using a devfile name with length more than 63" , func () {
@@ -578,4 +592,35 @@ CMD ["npm", "start"]
578
592
})
579
593
580
594
})
595
+
596
+ Context ("deploying devfile with long-running exec" , func () {
597
+ BeforeEach (func () {
598
+ helper .CopyExampleDevFile (
599
+ filepath .Join ("source" , "devfiles" , "nodejs" , "devfile-deploy-exec-long.yaml" ),
600
+ path .Join (commonVar .Context , "devfile.yaml" ),
601
+ helper .DevfileMetadataNameSetter (cmpName ))
602
+ })
603
+
604
+ When ("pod security is enforced as restricted" , func () {
605
+ BeforeEach (func () {
606
+ commonVar .CliRunner .SetLabelsOnNamespace (
607
+ commonVar .Project ,
608
+ "pod-security.kubernetes.io/enforce=restricted" ,
609
+ "pod-security.kubernetes.io/enforce-version=latest" ,
610
+ )
611
+ })
612
+
613
+ It ("should set securitycontext for podsecurity admission on job's pod template" , func () {
614
+ if os .Getenv ("KUBERNETES" ) != "true" {
615
+ Skip ("This is a Kubernetes specific scenario, skipping" )
616
+ }
617
+ helper .Cmd ("odo" , "deploy" ).Should (func (session * gexec.Session ) {
618
+ component := helper .NewComponent (cmpName , "app" , labels .ComponentDeployMode , commonVar .Project , commonVar .CliRunner )
619
+ jobDef := component .GetJobDef ()
620
+ Expect (* jobDef .Spec .Template .Spec .SecurityContext .RunAsNonRoot ).To (BeTrue ())
621
+ Expect (string (jobDef .Spec .Template .Spec .SecurityContext .SeccompProfile .Type )).To (Equal ("RuntimeDefault" ))
622
+ })
623
+ })
624
+ })
625
+ })
581
626
})
0 commit comments