diff options
author | Ashley Cui <acui@redhat.com> | 2021-08-31 09:57:03 -0400 |
---|---|---|
committer | Ashley Cui <acui@redhat.com> | 2021-08-31 13:53:51 -0400 |
commit | 1fb07c4225feb2eec9ffcf7ca039b373cfd69ed7 (patch) | |
tree | 0265fce296519a0a3d8f3d39cea9d37dfcb66142 /test | |
parent | 8ab84b437352bf2b3653fe92fbfa60a59b980a93 (diff) | |
download | podman-1fb07c4225feb2eec9ffcf7ca039b373cfd69ed7.tar.gz podman-1fb07c4225feb2eec9ffcf7ca039b373cfd69ed7.tar.bz2 podman-1fb07c4225feb2eec9ffcf7ca039b373cfd69ed7.zip |
Make secret env var available to exec session
Secret environment variables were only available to a podman run/start.
This commit makes sure that exec sessions can see them as well.
Signed-off-by: Ashley Cui <acui@redhat.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/e2e/exec_test.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/e2e/exec_test.go b/test/e2e/exec_test.go index 02680e739..65d60b24d 100644 --- a/test/e2e/exec_test.go +++ b/test/e2e/exec_test.go @@ -2,7 +2,9 @@ package integration import ( "fmt" + "io/ioutil" "os" + "path/filepath" "strings" . "github.com/containers/podman/v3/test/utils" @@ -540,4 +542,32 @@ RUN useradd -u 1000 auser`, fedoraMinimal) stop.WaitWithDefaultTimeout() Expect(stop).Should(Exit(0)) }) + + It("podman exec with env var secret", func() { + secretsString := "somesecretdata" + secretFilePath := filepath.Join(podmanTest.TempDir, "secret") + err := ioutil.WriteFile(secretFilePath, []byte(secretsString), 0755) + Expect(err).To(BeNil()) + + session := podmanTest.Podman([]string{"secret", "create", "mysecret", secretFilePath}) + session.WaitWithDefaultTimeout() + Expect(session).Should(Exit(0)) + + session = podmanTest.Podman([]string{"run", "-t", "-i", "-d", "--secret", "source=mysecret,type=env", "--name", "secr", ALPINE, "top"}) + session.WaitWithDefaultTimeout() + Expect(session).Should(Exit(0)) + + session = podmanTest.Podman([]string{"exec", "secr", "printenv", "mysecret"}) + session.WaitWithDefaultTimeout() + Expect(session).Should(Exit(0)) + Expect(session.OutputToString()).To(ContainSubstring(secretsString)) + + session = podmanTest.Podman([]string{"commit", "secr", "foobar.com/test1-image:latest"}) + session.WaitWithDefaultTimeout() + Expect(session).Should(Exit(0)) + + session = podmanTest.Podman([]string{"run", "foobar.com/test1-image:latest", "printenv", "mysecret"}) + session.WaitWithDefaultTimeout() + Expect(session.OutputToString()).To(Not(ContainSubstring(secretsString))) + }) }) |