summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJakub Guzik <jguzik@redhat.com>2021-12-13 11:21:31 +0100
committerJakub Guzik <jguzik@redhat.com>2021-12-14 10:41:03 +0100
commit50501f49a327a2f5c7f1c6746f9fde482c877387 (patch)
tree26781fbc9830785e9442d42378dcb2d0ec9c769a /test
parent4543fd463e3d02aea42f1a5b6ed0d2ed190de655 (diff)
downloadpodman-50501f49a327a2f5c7f1c6746f9fde482c877387.tar.gz
podman-50501f49a327a2f5c7f1c6746f9fde482c877387.tar.bz2
podman-50501f49a327a2f5c7f1c6746f9fde482c877387.zip
Add secret list --filter to cli
This PR is a follow-up of #11431. It adds possibility of filtering secret list based on id and name. Signed-off-by: Jakub Guzik <jguzik@redhat.com>
Diffstat (limited to 'test')
-rw-r--r--test/e2e/secret_test.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/e2e/secret_test.go b/test/e2e/secret_test.go
index 661ebbdc0..f08638b1b 100644
--- a/test/e2e/secret_test.go
+++ b/test/e2e/secret_test.go
@@ -1,6 +1,7 @@
package integration
import (
+ "fmt"
"io/ioutil"
"os"
"path/filepath"
@@ -145,6 +146,54 @@ var _ = Describe("Podman secret", func() {
})
+ It("podman secret ls with filters", func() {
+ secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
+ err := ioutil.WriteFile(secretFilePath, []byte("mysecret"), 0755)
+ Expect(err).To(BeNil())
+
+ secret1 := "Secret1"
+ secret2 := "Secret2"
+
+ session := podmanTest.Podman([]string{"secret", "create", secret1, secretFilePath})
+ session.WaitWithDefaultTimeout()
+ secrID1 := session.OutputToString()
+ Expect(session).Should(Exit(0))
+
+ session = podmanTest.Podman([]string{"secret", "create", secret2, secretFilePath})
+ session.WaitWithDefaultTimeout()
+ secrID2 := session.OutputToString()
+ Expect(session).Should(Exit(0))
+
+ session = podmanTest.Podman([]string{"secret", "create", "Secret3", secretFilePath})
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+
+ list := podmanTest.Podman([]string{"secret", "ls", "--filter", fmt.Sprintf("name=%s", secret1)})
+ list.WaitWithDefaultTimeout()
+ Expect(list).Should(Exit(0))
+ Expect(list.OutputToStringArray()).To(HaveLen(2), ContainSubstring(secret1))
+
+ list = podmanTest.Podman([]string{"secret", "ls", "--filter", fmt.Sprintf("name=%s", secret2)})
+ list.WaitWithDefaultTimeout()
+ Expect(list).Should(Exit(0))
+ Expect(list.OutputToStringArray()).To(HaveLen(2), ContainSubstring(secret2))
+
+ list = podmanTest.Podman([]string{"secret", "ls", "--filter", fmt.Sprintf("id=%s", secrID1)})
+ list.WaitWithDefaultTimeout()
+ Expect(list).Should(Exit(0))
+ Expect(list.OutputToStringArray()).To(HaveLen(2), ContainSubstring(secrID1))
+
+ list = podmanTest.Podman([]string{"secret", "ls", "--filter", fmt.Sprintf("id=%s", secrID2)})
+ list.WaitWithDefaultTimeout()
+ Expect(list).Should(Exit(0))
+ Expect(list.OutputToStringArray()).To(HaveLen(2), ContainSubstring(secrID2))
+
+ list = podmanTest.Podman([]string{"secret", "ls", "--filter", fmt.Sprintf("name=%s,name=%s", secret1, secret2)})
+ list.WaitWithDefaultTimeout()
+ Expect(list).Should(Exit(0))
+ Expect(list.OutputToStringArray()).To(HaveLen(3), ContainSubstring(secret1), ContainSubstring(secret2))
+ })
+
It("podman secret ls with Go template", func() {
secretFilePath := filepath.Join(podmanTest.TempDir, "secret")
err := ioutil.WriteFile(secretFilePath, []byte("mysecret"), 0755)