aboutsummaryrefslogtreecommitdiff
path: root/test/e2e/run_selinux_test.go
diff options
context:
space:
mode:
authorEd Santiago <santiago@redhat.com>2021-11-22 10:54:22 -0700
committerEd Santiago <santiago@redhat.com>2021-11-22 14:37:43 -0700
commit97ab9176f77c4fc9c4413afad4d2dcf5fad824b6 (patch)
treefc67f0c7dd3304489f89fd58742d3c46431eb44a /test/e2e/run_selinux_test.go
parent1bfbb28b0365790552483b961b4bd48a69dd8070 (diff)
downloadpodman-97ab9176f77c4fc9c4413afad4d2dcf5fad824b6.tar.gz
podman-97ab9176f77c4fc9c4413afad4d2dcf5fad824b6.tar.bz2
podman-97ab9176f77c4fc9c4413afad4d2dcf5fad824b6.zip
e2e tests: clean up antihelpful BeTrue()s
Many ginkgo tests have been written to use this evil form: GrepString("foo") Expect(that to BeTrue()) ...which yields horrible useless messages on failure: false is not true Identify those (automatically, via script) and convert to: Expect(output to ContainSubstring("foo")) ...which yields: "this output" does not contain substring "foo" There are still many BeTrue()s left. This is just a start. This is commit 1 of 2. It includes the script I used, and all changes to *.go are those computed by the script. Commit 2 will apply some manual fixes. Signed-off-by: Ed Santiago <santiago@redhat.com>
Diffstat (limited to 'test/e2e/run_selinux_test.go')
-rw-r--r--test/e2e/run_selinux_test.go51
1 files changed, 17 insertions, 34 deletions
diff --git a/test/e2e/run_selinux_test.go b/test/e2e/run_selinux_test.go
index 3cb0663e0..cf63760cc 100644
--- a/test/e2e/run_selinux_test.go
+++ b/test/e2e/run_selinux_test.go
@@ -42,24 +42,21 @@ var _ = Describe("Podman run", func() {
session := podmanTest.Podman([]string{"run", ALPINE, "cat", "/proc/self/attr/current"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- match, _ := session.GrepString("container_t")
- Expect(match).Should(BeTrue())
+ Expect(session.OutputToString()).To(ContainSubstring("container_t"))
})
It("podman run selinux grep test", func() {
session := podmanTest.Podman([]string{"run", "-it", "--security-opt", "label=level:s0:c1,c2", ALPINE, "cat", "/proc/self/attr/current"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- match, _ := session.GrepString("s0:c1,c2")
- Expect(match).Should(BeTrue())
+ Expect(session.OutputToString()).To(ContainSubstring("s0:c1,c2"))
})
It("podman run selinux disable test", func() {
session := podmanTest.Podman([]string{"run", "-it", "--security-opt", "label=disable", ALPINE, "cat", "/proc/self/attr/current"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- match, _ := session.GrepString("spc_t")
- Expect(match).Should(BeTrue())
+ Expect(session.OutputToString()).To(ContainSubstring("spc_t"))
})
It("podman run selinux type check test", func() {
@@ -75,88 +72,77 @@ var _ = Describe("Podman run", func() {
session := podmanTest.Podman([]string{"run", "-it", "--security-opt", "label=type:spc_t", ALPINE, "cat", "/proc/self/attr/current"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- match, _ := session.GrepString("spc_t")
- Expect(match).Should(BeTrue())
+ Expect(session.OutputToString()).To(ContainSubstring("spc_t"))
})
It("podman privileged selinux", func() {
session := podmanTest.Podman([]string{"run", "--privileged", ALPINE, "cat", "/proc/self/attr/current"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- match, _ := session.GrepString("spc_t")
- Expect(match).Should(BeTrue())
+ Expect(session.OutputToString()).To(ContainSubstring("spc_t"))
})
It("podman test selinux label resolv.conf", func() {
session := podmanTest.Podman([]string{"run", fedoraMinimal, "ls", "-Z", "/etc/resolv.conf"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- match, _ := session.GrepString("container_file_t")
- Expect(match).Should(BeTrue())
+ Expect(session.OutputToString()).To(ContainSubstring("container_file_t"))
})
It("podman test selinux label hosts", func() {
session := podmanTest.Podman([]string{"run", fedoraMinimal, "ls", "-Z", "/etc/hosts"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- match, _ := session.GrepString("container_file_t")
- Expect(match).Should(BeTrue())
+ Expect(session.OutputToString()).To(ContainSubstring("container_file_t"))
})
It("podman test selinux label hostname", func() {
session := podmanTest.Podman([]string{"run", fedoraMinimal, "ls", "-Z", "/etc/hostname"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- match, _ := session.GrepString("container_file_t")
- Expect(match).Should(BeTrue())
+ Expect(session.OutputToString()).To(ContainSubstring("container_file_t"))
})
It("podman test selinux label /run/secrets", func() {
session := podmanTest.Podman([]string{"run", fedoraMinimal, "ls", "-dZ", "/run/secrets"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- match, _ := session.GrepString("container_file_t")
- Expect(match).Should(BeTrue())
+ Expect(session.OutputToString()).To(ContainSubstring("container_file_t"))
})
It("podman test selinux --privileged label resolv.conf", func() {
session := podmanTest.Podman([]string{"run", "--privileged", fedoraMinimal, "ls", "-Z", "/etc/resolv.conf"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- match, _ := session.GrepString("container_file_t")
- Expect(match).Should(BeTrue())
+ Expect(session.OutputToString()).To(ContainSubstring("container_file_t"))
})
It("podman test selinux --privileged label hosts", func() {
session := podmanTest.Podman([]string{"run", "--privileged", fedoraMinimal, "ls", "-Z", "/etc/hosts"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- match, _ := session.GrepString("container_file_t")
- Expect(match).Should(BeTrue())
+ Expect(session.OutputToString()).To(ContainSubstring("container_file_t"))
})
It("podman test selinux --privileged label hostname", func() {
session := podmanTest.Podman([]string{"run", "--privileged", fedoraMinimal, "ls", "-Z", "/etc/hostname"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- match, _ := session.GrepString("container_file_t")
- Expect(match).Should(BeTrue())
+ Expect(session.OutputToString()).To(ContainSubstring("container_file_t"))
})
It("podman test selinux --privileged label /run/secrets", func() {
session := podmanTest.Podman([]string{"run", "--privileged", fedoraMinimal, "ls", "-dZ", "/run/secrets"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- match, _ := session.GrepString("container_file_t")
- Expect(match).Should(BeTrue())
+ Expect(session.OutputToString()).To(ContainSubstring("container_file_t"))
})
It("podman run selinux file type setup test", func() {
session := podmanTest.Podman([]string{"run", "-it", "--security-opt", "label=type:spc_t", "--security-opt", "label=filetype:container_var_lib_t", fedoraMinimal, "ls", "-Z", "/dev"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- match, _ := session.GrepString("container_var_lib_t")
- Expect(match).Should(BeTrue())
+ Expect(session.OutputToString()).To(ContainSubstring("container_var_lib_t"))
session = podmanTest.Podman([]string{"run", "-it", "--security-opt", "label=type:spc_t", "--security-opt", "label=filetype:foobar", fedoraMinimal, "ls", "-Z", "/dev"})
session.WaitWithDefaultTimeout()
@@ -179,10 +165,8 @@ var _ = Describe("Podman run", func() {
session := podmanTest.Podman([]string{"run", "-it", "--privileged", "--security-opt", "label=type:spc_t", "--security-opt", "label=level:s0:c1,c2", ALPINE, "cat", "/proc/self/attr/current"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- match, _ := session.GrepString("spc_t")
- Expect(match).To(BeTrue())
- match2, _ := session.GrepString("s0:c1,c2")
- Expect(match2).To(BeTrue())
+ Expect(session.OutputToString()).To(ContainSubstring("spc_t"))
+ Expect(session.OutputToString()).To(ContainSubstring("s0:c1,c2"))
})
It("podman pod container share SELinux labels", func() {
@@ -349,7 +333,6 @@ var _ = Describe("Podman run", func() {
session := podmanTest.Podman([]string{"run", "-v", "testvol:/test1/test:Z", fedoraMinimal, "ls", "-alZ", "/test1"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- match, _ := session.GrepString(":s0:")
- Expect(match).Should(BeTrue())
+ Expect(session.OutputToString()).To(ContainSubstring(":s0:"))
})
})