diff options
author | baude <bbaude@redhat.com> | 2018-07-31 17:16:08 -0500 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-08-02 12:40:14 +0000 |
commit | a6de23278a6e5b7f27c093eb19c201b77b7c4416 (patch) | |
tree | 18226712362c752832a61bc772e7902338b50251 /test/e2e/search_test.go | |
parent | 3d1449b2cccdf6c84248c82758b0850c971d05be (diff) | |
download | podman-a6de23278a6e5b7f27c093eb19c201b77b7c4416.tar.gz podman-a6de23278a6e5b7f27c093eb19c201b77b7c4416.tar.bz2 podman-a6de23278a6e5b7f27c093eb19c201b77b7c4416.zip |
Use REGISTRIES_CONFIG_PATH for all tests
We should not be using the test systems registries.conf file for integration
tests. We should always use a constructed file created specifically for the
integration tests or we stand to have unpredictable results. The beforeTest
function now sets an environment variable pointing to a registries.conf file
in the test's tempdir. That file will container docker.io as a default.
The afterTest function then clears the environment variable.
Signed-off-by: baude <bbaude@redhat.com>
Closes: #1197
Approved by: rhatdan
Diffstat (limited to 'test/e2e/search_test.go')
-rw-r--r-- | test/e2e/search_test.go | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/test/e2e/search_test.go b/test/e2e/search_test.go index bdbd5e770..7b9612a35 100644 --- a/test/e2e/search_test.go +++ b/test/e2e/search_test.go @@ -2,9 +2,7 @@ package integration import ( "fmt" - "io/ioutil" "os" - "path/filepath" "strconv" . "github.com/onsi/ginkgo" @@ -177,10 +175,7 @@ var _ = Describe("Podman search", func() { Expect(push.ExitCode()).To(Equal(0)) // registries.conf set up - regFileBytes := []byte(regFileContents) - outfile := filepath.Join(podmanTest.TempDir, "registries.conf") - os.Setenv("REGISTRIES_CONFIG_PATH", outfile) - ioutil.WriteFile(outfile, regFileBytes, 0644) + podmanTest.setRegistriesConfigEnv([]byte(regFileContents)) search := podmanTest.Podman([]string{"search", "localhost:5000/my-alpine"}) search.WaitWithDefaultTimeout() @@ -191,7 +186,7 @@ var _ = Describe("Podman search", func() { Expect(search.ErrorToString()).Should(BeEmpty()) // cleanup - os.Setenv("REGISTRIES_CONFIG_PATH", "") + resetRegistriesConfigEnv() }) It("podman search doesn't attempt HTTP if force secure is true", func() { @@ -208,10 +203,7 @@ var _ = Describe("Podman search", func() { Expect(push.ExitCode()).To(Equal(0)) // registries.conf set up - regFileBytes := []byte(regFileContents) - outfile := filepath.Join(podmanTest.TempDir, "registries.conf") - os.Setenv("REGISTRIES_CONFIG_PATH", outfile) - ioutil.WriteFile(outfile, regFileBytes, 0644) + podmanTest.setRegistriesConfigEnv([]byte(regFileContents)) search := podmanTest.Podman([]string{"search", "localhost:5000/my-alpine", "--tls-verify=true"}) search.WaitWithDefaultTimeout() @@ -222,7 +214,7 @@ var _ = Describe("Podman search", func() { Expect(match).Should(BeTrue()) // cleanup - os.Setenv("REGISTRIES_CONFIG_PATH", "") + resetRegistriesConfigEnv() }) It("podman search doesn't attempt HTTP if registry is not listed as insecure", func() { @@ -239,10 +231,7 @@ var _ = Describe("Podman search", func() { Expect(push.ExitCode()).To(Equal(0)) // registries.conf set up - regFileBytes := []byte(badRegFileContents) - outfile := filepath.Join(podmanTest.TempDir, "registries.conf") - os.Setenv("REGISTRIES_CONFIG_PATH", outfile) - ioutil.WriteFile(outfile, regFileBytes, 0644) + podmanTest.setRegistriesConfigEnv([]byte(badRegFileContents)) search := podmanTest.Podman([]string{"search", "localhost:5000/my-alpine"}) search.WaitWithDefaultTimeout() @@ -253,7 +242,7 @@ var _ = Describe("Podman search", func() { Expect(match).Should(BeTrue()) // cleanup - os.Setenv("REGISTRIES_CONFIG_PATH", "") + resetRegistriesConfigEnv() }) It("podman search doesn't attempt HTTP if one registry is not listed as insecure", func() { @@ -278,10 +267,7 @@ var _ = Describe("Podman search", func() { Expect(push.ExitCode()).To(Equal(0)) // registries.conf set up - regFileBytes := []byte(regFileContents2) - outfile := filepath.Join(podmanTest.TempDir, "registries.conf") - os.Setenv("REGISTRIES_CONFIG_PATH", outfile) - ioutil.WriteFile(outfile, regFileBytes, 0644) + podmanTest.setRegistriesConfigEnv([]byte(regFileContents2)) search := podmanTest.Podman([]string{"search", "my-alpine"}) search.WaitWithDefaultTimeout() @@ -292,6 +278,6 @@ var _ = Describe("Podman search", func() { Expect(match).Should(BeTrue()) // cleanup - os.Setenv("REGISTRIES_CONFIG_PATH", "") + resetRegistriesConfigEnv() }) }) |