From d7c0f968ca60994306c8c76cd8e4e0a677fe9ada Mon Sep 17 00:00:00 2001 From: Qi Wang Date: Fri, 25 Oct 2019 21:16:37 -0400 Subject: fix bug check nonexist authfile Use GetDefaultAuthFile() from buildah. For podman command(except login), if authfile does not exist returns error. close #4328 Signed-off-by: Qi Wang --- test/e2e/create_test.go | 7 +++++++ test/e2e/login_logout_test.go | 10 ++++++++++ test/e2e/play_kube_test.go | 10 ++++++++++ test/e2e/pull_test.go | 7 +++++++ test/e2e/run_test.go | 7 +++++++ test/e2e/runlabel_test.go | 15 +++++++++++++++ test/e2e/search_test.go | 8 ++++++++ 7 files changed, 64 insertions(+) (limited to 'test') diff --git a/test/e2e/create_test.go b/test/e2e/create_test.go index f5dca321c..7d977f4e3 100644 --- a/test/e2e/create_test.go +++ b/test/e2e/create_test.go @@ -297,4 +297,11 @@ var _ = Describe("Podman create", func() { Expect(session.ExitCode()).To((Equal(0))) Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINEARM64DIGEST)) }) + + It("podman create --authfile with nonexist authfile", func() { + SkipIfRemote() + session := podmanTest.PodmanNoCache([]string{"create", "--authfile", "/tmp/nonexist", "--name=foo", ALPINE}) + session.WaitWithDefaultTimeout() + Expect(session).To(Not(Equal(0))) + }) }) diff --git a/test/e2e/login_logout_test.go b/test/e2e/login_logout_test.go index 14cfed5db..c3df10f5e 100644 --- a/test/e2e/login_logout_test.go +++ b/test/e2e/login_logout_test.go @@ -123,6 +123,11 @@ var _ = Describe("Podman login and logout", func() { json.Unmarshal(authInfo, &info) fmt.Println(info) + // push should fail with nonexist authfile + session = podmanTest.Podman([]string{"push", "--authfile", "/tmp/nonexist", ALPINE, testImg}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Not(Equal(0))) + session = podmanTest.Podman([]string{"push", "--authfile", authFile, ALPINE, testImg}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) @@ -131,6 +136,11 @@ var _ = Describe("Podman login and logout", func() { session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) + // logout should fail with nonexist authfile + session = podmanTest.Podman([]string{"logout", "--authfile", "/tmp/nonexist", server}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Not(Equal(0))) + session = podmanTest.Podman([]string{"logout", "--authfile", authFile, server}) }) diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go index 7069e049d..416c64b5a 100644 --- a/test/e2e/play_kube_test.go +++ b/test/e2e/play_kube_test.go @@ -209,6 +209,16 @@ var _ = Describe("Podman generate kube", func() { processTestResult(f) }) + It("podman play kube fail with nonexist authfile", func() { + err := generateKubeYaml(getPod(), kubeYaml) + Expect(err).To(BeNil()) + + kube := podmanTest.Podman([]string{"play", "kube", "--authfile", "/tmp/nonexist", kubeYaml}) + kube.WaitWithDefaultTimeout() + Expect(kube.ExitCode()).To(Not(Equal(0))) + + }) + It("podman play kube test correct command", func() { err := generateKubeYaml(getPod(), kubeYaml) Expect(err).To(BeNil()) diff --git a/test/e2e/pull_test.go b/test/e2e/pull_test.go index 5152409af..eee0b131b 100644 --- a/test/e2e/pull_test.go +++ b/test/e2e/pull_test.go @@ -353,4 +353,11 @@ var _ = Describe("Podman pull", func() { rmi.WaitWithDefaultTimeout() Expect(rmi.ExitCode()).To(Equal(0)) }) + + It("podman pull from docker with nonexist --authfile", func() { + SkipIfRemote() + session := podmanTest.PodmanNoCache([]string{"pull", "--authfile", "/tmp/nonexist", ALPINE}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Not(Equal(0))) + }) }) diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index 874aa498e..7fc85c9ce 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -992,4 +992,11 @@ USER mail` session.WaitWithDefaultTimeout() Expect(session).To(ExitWithError()) }) + + It("podman run should fail with nonexist authfile", func() { + SkipIfRemote() + session := podmanTest.Podman([]string{"run", "--authfile", "/tmp/nonexist", ALPINE, "ls"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Not(Equal(0))) + }) }) diff --git a/test/e2e/runlabel_test.go b/test/e2e/runlabel_test.go index 52a011efb..41d61e9d9 100644 --- a/test/e2e/runlabel_test.go +++ b/test/e2e/runlabel_test.go @@ -98,4 +98,19 @@ var _ = Describe("podman container runlabel", func() { result.WaitWithDefaultTimeout() Expect(result.ExitCode()).To(Equal(0)) }) + + It("runlabel should fail with nonexist authfile", func() { + SkipIfRemote() + image := "podman-runlabel-test:podman" + podmanTest.BuildImage(PodmanDockerfile, image, "false") + + // runlabel should fail with nonexist authfile + result := podmanTest.Podman([]string{"container", "runlabel", "--authfile", "/tmp/nonexist", "RUN", image}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Not(Equal(0))) + + result = podmanTest.Podman([]string{"rmi", image}) + result.WaitWithDefaultTimeout() + Expect(result.ExitCode()).To(Equal(0)) + }) }) diff --git a/test/e2e/search_test.go b/test/e2e/search_test.go index 9c28849f0..d88231510 100644 --- a/test/e2e/search_test.go +++ b/test/e2e/search_test.go @@ -391,4 +391,12 @@ registries = ['{{.Host}}:{{.Port}}']` // cleanup resetRegistriesConfigEnv() }) + + // search should fail with nonexist authfile + It("podman search fail with nonexist --authfile", func() { + SkipIfRemote() + search := podmanTest.Podman([]string{"search", "--authfile", "/tmp/nonexist", ALPINE}) + search.WaitWithDefaultTimeout() + Expect(search.ExitCode()).To(Not(Equal(0))) + }) }) -- cgit v1.2.3-54-g00ecf