summaryrefslogtreecommitdiff
path: root/test/e2e/generate_kube_test.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-03-09 22:22:29 +0100
committerGitHub <noreply@github.com>2020-03-09 22:22:29 +0100
commit3d48940927b1133e2bfd1c3accba84345cc56ee6 (patch)
treee9d4666d0b4b6a8f1a6449eca6c6d4919d537fe4 /test/e2e/generate_kube_test.go
parentb54a5e1f2ff08fe6903411ba471ad9b3badc6acd (diff)
parent17bab33bd2b8719c84e5ede1bd21b435ebeedf0e (diff)
downloadpodman-3d48940927b1133e2bfd1c3accba84345cc56ee6.tar.gz
podman-3d48940927b1133e2bfd1c3accba84345cc56ee6.tar.bz2
podman-3d48940927b1133e2bfd1c3accba84345cc56ee6.zip
Merge pull request #5307 from QiWang19/security-opt-genkube
fix security-opt generate kube
Diffstat (limited to 'test/e2e/generate_kube_test.go')
-rw-r--r--test/e2e/generate_kube_test.go47
1 files changed, 46 insertions, 1 deletions
diff --git a/test/e2e/generate_kube_test.go b/test/e2e/generate_kube_test.go
index 603edbe6b..389f2c822 100644
--- a/test/e2e/generate_kube_test.go
+++ b/test/e2e/generate_kube_test.go
@@ -10,7 +10,7 @@ import (
"github.com/ghodss/yaml"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
- "k8s.io/api/core/v1"
+ v1 "k8s.io/api/core/v1"
)
var _ = Describe("Podman generate kube", func() {
@@ -69,6 +69,51 @@ var _ = Describe("Podman generate kube", func() {
Expect(numContainers).To(Equal(1))
})
+ It("podman generate service kube on container with --security-opt level", func() {
+ session := podmanTest.Podman([]string{"create", "--name", "test", "--security-opt", "label=level:s0:c100,c200", "alpine"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ kube := podmanTest.Podman([]string{"generate", "kube", "test"})
+ kube.WaitWithDefaultTimeout()
+ Expect(kube.ExitCode()).To(Equal(0))
+
+ pod := new(v1.Pod)
+ err := yaml.Unmarshal(kube.Out.Contents(), pod)
+ Expect(err).To(BeNil())
+ Expect(kube.OutputToString()).To(ContainSubstring("level: s0:c100,c200"))
+ })
+
+ It("podman generate service kube on container with --security-opt disable", func() {
+ session := podmanTest.Podman([]string{"create", "--name", "test-disable", "--security-opt", "label=disable", "alpine"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ kube := podmanTest.Podman([]string{"generate", "kube", "test-disable"})
+ kube.WaitWithDefaultTimeout()
+ Expect(kube.ExitCode()).To(Equal(0))
+
+ pod := new(v1.Pod)
+ err = yaml.Unmarshal(kube.Out.Contents(), pod)
+ Expect(err).To(BeNil())
+ Expect(kube.OutputToString()).To(ContainSubstring("type: spc_t"))
+ })
+
+ It("podman generate service kube on container with --security-opt type", func() {
+ session := podmanTest.Podman([]string{"create", "--name", "test", "--security-opt", "label=type:foo_bar_t", "alpine"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ kube := podmanTest.Podman([]string{"generate", "kube", "test"})
+ kube.WaitWithDefaultTimeout()
+ Expect(kube.ExitCode()).To(Equal(0))
+
+ pod := new(v1.Pod)
+ err = yaml.Unmarshal(kube.Out.Contents(), pod)
+ Expect(err).To(BeNil())
+ Expect(kube.OutputToString()).To(ContainSubstring("type: foo_bar_t"))
+ })
+
It("podman generate service kube on container", func() {
session := podmanTest.RunTopContainer("top")
session.WaitWithDefaultTimeout()