mirror of
https://github.com/containers/podman.git
synced 2025-11-30 01:58:46 +08:00
test: organize search tests with BeforeEach/AfterEach patterns
Signed-off-by: Jan Rodák <hony.com@seznam.cz>
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"text/template"
|
"text/template"
|
||||||
@@ -69,27 +70,31 @@ registries = []`
|
|||||||
return image
|
return image
|
||||||
}
|
}
|
||||||
|
|
||||||
It("podman search", func() {
|
Context("podman search with mock registry", func() {
|
||||||
registryAddress, srv, serverErr := CreateMockRegistryServer()
|
var registryAddress string
|
||||||
defer CloseMockRegistryServer(srv, serverErr)
|
var srv *http.Server
|
||||||
|
var serverErr chan error
|
||||||
|
|
||||||
|
BeforeEach(func() {
|
||||||
|
registryAddress, srv, serverErr = CreateMockRegistryServer()
|
||||||
|
})
|
||||||
|
|
||||||
|
AfterEach(func() {
|
||||||
|
CloseMockRegistryServer(srv, serverErr)
|
||||||
|
})
|
||||||
|
|
||||||
|
It("podman search", func() {
|
||||||
search := podmanTest.PodmanExitCleanly("search", "--tls-verify=false", registryAddress+"/alpine")
|
search := podmanTest.PodmanExitCleanly("search", "--tls-verify=false", registryAddress+"/alpine")
|
||||||
Expect(len(search.OutputToStringArray())).To(BeNumerically(">", 1))
|
Expect(len(search.OutputToStringArray())).To(BeNumerically(">", 1))
|
||||||
Expect(search.OutputToString()).To(ContainSubstring("alpine"))
|
Expect(search.OutputToString()).To(ContainSubstring("alpine"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman search single registry flag", func() {
|
It("podman search single registry flag", func() {
|
||||||
registryAddress, srv, serverErr := CreateMockRegistryServer()
|
|
||||||
defer CloseMockRegistryServer(srv, serverErr)
|
|
||||||
|
|
||||||
search := podmanTest.PodmanExitCleanly("search", "--tls-verify=false", registryAddress+"/skopeo/stable:latest")
|
search := podmanTest.PodmanExitCleanly("search", "--tls-verify=false", registryAddress+"/skopeo/stable:latest")
|
||||||
Expect(search.OutputToString()).To(ContainSubstring(registryAddress + "/skopeo/stable"))
|
Expect(search.OutputToString()).To(ContainSubstring(registryAddress + "/skopeo/stable"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman search image with description", func() {
|
It("podman search image with description", func() {
|
||||||
registryAddress, srv, serverErr := CreateMockRegistryServer()
|
|
||||||
defer CloseMockRegistryServer(srv, serverErr)
|
|
||||||
|
|
||||||
search := podmanTest.PodmanExitCleanly("search", "--tls-verify=false", registryAddress+"/podman/stable")
|
search := podmanTest.PodmanExitCleanly("search", "--tls-verify=false", registryAddress+"/podman/stable")
|
||||||
output := string(search.Out.Contents())
|
output := string(search.Out.Contents())
|
||||||
Expect(output).To(MatchRegexp(`(?m)NAME\s+DESCRIPTION$`))
|
Expect(output).To(MatchRegexp(`(?m)NAME\s+DESCRIPTION$`))
|
||||||
@@ -97,27 +102,18 @@ registries = []`
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("podman search image with --compatible", func() {
|
It("podman search image with --compatible", func() {
|
||||||
registryAddress, srv, serverErr := CreateMockRegistryServer()
|
|
||||||
defer CloseMockRegistryServer(srv, serverErr)
|
|
||||||
|
|
||||||
search := podmanTest.PodmanExitCleanly("search", "--compatible", "--tls-verify=false", registryAddress+"/podman/stable")
|
search := podmanTest.PodmanExitCleanly("search", "--compatible", "--tls-verify=false", registryAddress+"/podman/stable")
|
||||||
output := string(search.Out.Contents())
|
output := string(search.Out.Contents())
|
||||||
Expect(output).To(MatchRegexp(`(?m)NAME\s+DESCRIPTION\s+STARS\s+OFFICIAL\s+AUTOMATED$`))
|
Expect(output).To(MatchRegexp(`(?m)NAME\s+DESCRIPTION\s+STARS\s+OFFICIAL\s+AUTOMATED$`))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman search format flag", func() {
|
It("podman search format flag", func() {
|
||||||
registryAddress, srv, serverErr := CreateMockRegistryServer()
|
|
||||||
defer CloseMockRegistryServer(srv, serverErr)
|
|
||||||
|
|
||||||
search := podmanTest.PodmanExitCleanly("search", "--format", "table {{.Index}} {{.Name}}", "--tls-verify=false", registryAddress+"/testdigest_v2s2")
|
search := podmanTest.PodmanExitCleanly("search", "--format", "table {{.Index}} {{.Name}}", "--tls-verify=false", registryAddress+"/testdigest_v2s2")
|
||||||
Expect(len(search.OutputToStringArray())).To(BeNumerically(">", 1))
|
Expect(len(search.OutputToStringArray())).To(BeNumerically(">", 1))
|
||||||
Expect(search.OutputToString()).To(ContainSubstring(registryAddress + "/libpod/testdigest_v2s2"))
|
Expect(search.OutputToString()).To(ContainSubstring(registryAddress + "/libpod/testdigest_v2s2"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman search format json", func() {
|
It("podman search format json", func() {
|
||||||
registryAddress, srv, serverErr := CreateMockRegistryServer()
|
|
||||||
defer CloseMockRegistryServer(srv, serverErr)
|
|
||||||
|
|
||||||
search := podmanTest.PodmanExitCleanly("search", "--format", "json", "--tls-verify=false", registryAddress+"/testdigest_v2s1")
|
search := podmanTest.PodmanExitCleanly("search", "--format", "json", "--tls-verify=false", registryAddress+"/testdigest_v2s1")
|
||||||
Expect(search.OutputToString()).To(BeValidJSON())
|
Expect(search.OutputToString()).To(BeValidJSON())
|
||||||
Expect(search.OutputToString()).To(ContainSubstring(registryAddress + "/libpod/testdigest_v2s1"))
|
Expect(search.OutputToString()).To(ContainSubstring(registryAddress + "/libpod/testdigest_v2s1"))
|
||||||
@@ -134,9 +130,6 @@ registries = []`
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("podman search format json list tags", func() {
|
It("podman search format json list tags", func() {
|
||||||
registryAddress, srv, serverErr := CreateMockRegistryServer()
|
|
||||||
defer CloseMockRegistryServer(srv, serverErr)
|
|
||||||
|
|
||||||
search := podmanTest.PodmanExitCleanly("search", "--list-tags", "--format", "json", "--tls-verify=false", registryAddress+"/libpod/alpine:latest")
|
search := podmanTest.PodmanExitCleanly("search", "--list-tags", "--format", "json", "--tls-verify=false", registryAddress+"/libpod/alpine:latest")
|
||||||
Expect(search.OutputToString()).To(BeValidJSON())
|
Expect(search.OutputToString()).To(BeValidJSON())
|
||||||
Expect(search.OutputToString()).To(ContainSubstring(registryAddress + "/libpod/alpine"))
|
Expect(search.OutputToString()).To(ContainSubstring(registryAddress + "/libpod/alpine"))
|
||||||
@@ -146,9 +139,6 @@ registries = []`
|
|||||||
|
|
||||||
// Test for https://github.com/containers/podman/issues/11894
|
// Test for https://github.com/containers/podman/issues/11894
|
||||||
It("podman search no-trunc=false flag", func() {
|
It("podman search no-trunc=false flag", func() {
|
||||||
registryAddress, srv, serverErr := CreateMockRegistryServer()
|
|
||||||
defer CloseMockRegistryServer(srv, serverErr)
|
|
||||||
|
|
||||||
search := podmanTest.PodmanExitCleanly("search", "--no-trunc=false", "--tls-verify=false", registryAddress+"/alpine", "--format={{.Description}}")
|
search := podmanTest.PodmanExitCleanly("search", "--no-trunc=false", "--tls-verify=false", registryAddress+"/alpine", "--format={{.Description}}")
|
||||||
|
|
||||||
for _, line := range search.OutputToStringArray() {
|
for _, line := range search.OutputToStringArray() {
|
||||||
@@ -159,9 +149,6 @@ registries = []`
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("podman search limit flag", func() {
|
It("podman search limit flag", func() {
|
||||||
registryAddress, srv, serverErr := CreateMockRegistryServer()
|
|
||||||
defer CloseMockRegistryServer(srv, serverErr)
|
|
||||||
|
|
||||||
search := podmanTest.PodmanExitCleanly("search", "--tls-verify=false", registryAddress+"/alpine")
|
search := podmanTest.PodmanExitCleanly("search", "--tls-verify=false", registryAddress+"/alpine")
|
||||||
Expect(len(search.OutputToStringArray())).To(BeNumerically(">", 10))
|
Expect(len(search.OutputToStringArray())).To(BeNumerically(">", 10))
|
||||||
|
|
||||||
@@ -175,9 +162,6 @@ registries = []`
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("podman search with filter stars", func() {
|
It("podman search with filter stars", func() {
|
||||||
registryAddress, srv, serverErr := CreateMockRegistryServer()
|
|
||||||
defer CloseMockRegistryServer(srv, serverErr)
|
|
||||||
|
|
||||||
search := podmanTest.PodmanExitCleanly("search", "--filter", "stars=10", "--format", "{{.Stars}}", "--tls-verify=false", registryAddress+"/alpine")
|
search := podmanTest.PodmanExitCleanly("search", "--filter", "stars=10", "--format", "{{.Stars}}", "--tls-verify=false", registryAddress+"/alpine")
|
||||||
output := search.OutputToStringArray()
|
output := search.OutputToStringArray()
|
||||||
for i := range output {
|
for i := range output {
|
||||||
@@ -186,9 +170,6 @@ registries = []`
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("podman search with filter is-official", func() {
|
It("podman search with filter is-official", func() {
|
||||||
registryAddress, srv, serverErr := CreateMockRegistryServer()
|
|
||||||
defer CloseMockRegistryServer(srv, serverErr)
|
|
||||||
|
|
||||||
search := podmanTest.PodmanExitCleanly("search", "--filter", "is-official", "--format", "{{.Official}}", "--tls-verify=false", registryAddress+"/alpine")
|
search := podmanTest.PodmanExitCleanly("search", "--filter", "is-official", "--format", "{{.Official}}", "--tls-verify=false", registryAddress+"/alpine")
|
||||||
output := search.OutputToStringArray()
|
output := search.OutputToStringArray()
|
||||||
for i := range output {
|
for i := range output {
|
||||||
@@ -197,9 +178,6 @@ registries = []`
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("podman search with filter is-automated", func() {
|
It("podman search with filter is-automated", func() {
|
||||||
registryAddress, srv, serverErr := CreateMockRegistryServer()
|
|
||||||
defer CloseMockRegistryServer(srv, serverErr)
|
|
||||||
|
|
||||||
search := podmanTest.PodmanExitCleanly("search", "--filter", "is-automated=false", "--format", "{{.Automated}}", "--tls-verify=false", registryAddress+"/alpine")
|
search := podmanTest.PodmanExitCleanly("search", "--filter", "is-automated=false", "--format", "{{.Automated}}", "--tls-verify=false", registryAddress+"/alpine")
|
||||||
output := search.OutputToStringArray()
|
output := search.OutputToStringArray()
|
||||||
for i := range output {
|
for i := range output {
|
||||||
@@ -208,134 +186,17 @@ registries = []`
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("podman search format list tags with custom", func() {
|
It("podman search format list tags with custom", func() {
|
||||||
registryAddress, srv, serverErr := CreateMockRegistryServer()
|
|
||||||
defer CloseMockRegistryServer(srv, serverErr)
|
|
||||||
|
|
||||||
search := podmanTest.PodmanExitCleanly("search", "--list-tags", "--format", "{{.Name}}", "--limit", "1", "--tls-verify=false", registryAddress+"/libpod/alpine")
|
search := podmanTest.PodmanExitCleanly("search", "--list-tags", "--format", "{{.Name}}", "--limit", "1", "--tls-verify=false", registryAddress+"/libpod/alpine")
|
||||||
Expect(search.OutputToString()).To(Equal(registryAddress + "/libpod/alpine"))
|
Expect(search.OutputToString()).To(Equal(registryAddress + "/libpod/alpine"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman search attempts HTTP if tls-verify flag is set false", func() {
|
|
||||||
ep := mockFakeRegistryServerAsContainer("registry")
|
|
||||||
// if this test succeeded, there will be no output (there is no entry named fake/image:andtag in an empty registry)
|
|
||||||
// and the exit code will be 0
|
|
||||||
search := podmanTest.PodmanExitCleanly("search", fmt.Sprintf("%s/fake/image:andtag", ep.Address()), "--tls-verify=false")
|
|
||||||
Expect(search.OutputToString()).Should(BeEmpty())
|
|
||||||
})
|
|
||||||
|
|
||||||
It("podman search in local registry", func() {
|
|
||||||
ep := mockFakeRegistryServerAsContainer("registry3")
|
|
||||||
|
|
||||||
image := pushAlpineImageIntoMockRegistry(ep)
|
|
||||||
|
|
||||||
search := podmanTest.PodmanExitCleanly("search", image, "--tls-verify=false")
|
|
||||||
Expect(search.OutputToString()).ShouldNot(BeEmpty())
|
|
||||||
|
|
||||||
// podman search v2 registry with empty query
|
|
||||||
searchEmpty := podmanTest.PodmanExitCleanly("search", fmt.Sprintf("%s/", ep.Address()), "--tls-verify=false")
|
|
||||||
Expect(searchEmpty.OutputToStringArray()).ToNot(BeEmpty())
|
|
||||||
Expect(search.OutputToString()).To(ContainSubstring("my-alpine"))
|
|
||||||
})
|
|
||||||
|
|
||||||
It("podman search attempts HTTP if registry is in registries.insecure and force secure is false", func() {
|
|
||||||
ep := mockFakeRegistryServerAsContainer("registry4")
|
|
||||||
|
|
||||||
image := pushAlpineImageIntoMockRegistry(ep)
|
|
||||||
|
|
||||||
// registries.conf set up
|
|
||||||
var buffer bytes.Buffer
|
|
||||||
err = registryFileTmpl.Execute(&buffer, ep)
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
podmanTest.setRegistriesConfigEnv(buffer.Bytes())
|
|
||||||
err = os.WriteFile(fmt.Sprintf("%s/registry4.conf", tempdir), buffer.Bytes(), 0o644)
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
if IsRemote() {
|
|
||||||
podmanTest.RestartRemoteService()
|
|
||||||
defer podmanTest.RestartRemoteService()
|
|
||||||
}
|
|
||||||
|
|
||||||
search := podmanTest.PodmanExitCleanly("search", image)
|
|
||||||
Expect(search.OutputToString()).To(ContainSubstring("my-alpine"))
|
|
||||||
|
|
||||||
// cleanup
|
|
||||||
resetRegistriesConfigEnv()
|
|
||||||
})
|
|
||||||
|
|
||||||
It("podman search doesn't attempt HTTP if force secure is true", func() {
|
|
||||||
ep := mockFakeRegistryServerAsContainer("registry5")
|
|
||||||
|
|
||||||
port, err := strconv.ParseInt(ep.Port, 10, 64)
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
|
|
||||||
image := pushAlpineImageIntoMockRegistry(ep)
|
|
||||||
|
|
||||||
var buffer bytes.Buffer
|
|
||||||
err = registryFileTmpl.Execute(&buffer, ep)
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
podmanTest.setRegistriesConfigEnv(buffer.Bytes())
|
|
||||||
err = os.WriteFile(fmt.Sprintf("%s/registry5.conf", tempdir), buffer.Bytes(), 0o644)
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
|
|
||||||
search := podmanTest.Podman([]string{"search", image, "--tls-verify=true"})
|
|
||||||
search.WaitWithDefaultTimeout()
|
|
||||||
|
|
||||||
Expect(search).Should(ExitWithError(125, fmt.Sprintf(`couldn't search registry "localhost:%d": pinging container registry localhost:%d: Get "https://localhost:%d/v2/": http: server gave HTTP response to HTTPS client`, port, port, port)))
|
|
||||||
Expect(search.OutputToString()).Should(BeEmpty())
|
|
||||||
|
|
||||||
// cleanup
|
|
||||||
resetRegistriesConfigEnv()
|
|
||||||
})
|
|
||||||
|
|
||||||
It("podman search doesn't attempt HTTP if registry is not listed as insecure", func() {
|
|
||||||
ep := mockFakeRegistryServerAsContainer("registry6")
|
|
||||||
|
|
||||||
port, err := strconv.ParseInt(ep.Port, 10, 64)
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
|
|
||||||
image := pushAlpineImageIntoMockRegistry(ep)
|
|
||||||
|
|
||||||
var buffer bytes.Buffer
|
|
||||||
err = registryFileBadTmpl.Execute(&buffer, ep)
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
podmanTest.setRegistriesConfigEnv(buffer.Bytes())
|
|
||||||
err = os.WriteFile(fmt.Sprintf("%s/registry6.conf", tempdir), buffer.Bytes(), 0o644)
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
|
|
||||||
if IsRemote() {
|
|
||||||
podmanTest.RestartRemoteService()
|
|
||||||
defer podmanTest.RestartRemoteService()
|
|
||||||
}
|
|
||||||
|
|
||||||
search := podmanTest.Podman([]string{"search", image})
|
|
||||||
search.WaitWithDefaultTimeout()
|
|
||||||
|
|
||||||
Expect(search).Should(ExitWithError(125, fmt.Sprintf(`couldn't search registry "localhost:%d": pinging container registry localhost:%d: Get "https://localhost:%d/v2/": http: server gave HTTP response to HTTPS client`, port, port, port)))
|
|
||||||
Expect(search.OutputToString()).Should(BeEmpty())
|
|
||||||
|
|
||||||
// cleanup
|
|
||||||
resetRegistriesConfigEnv()
|
|
||||||
})
|
|
||||||
|
|
||||||
// search should fail with nonexistent authfile
|
|
||||||
It("podman search fail with nonexistent --authfile", func() {
|
|
||||||
search := podmanTest.Podman([]string{"search", "--authfile", "/tmp/nonexistent", ALPINE})
|
|
||||||
search.WaitWithDefaultTimeout()
|
|
||||||
Expect(search).To(ExitWithError(125, "credential file is not accessible: faccessat /tmp/nonexistent: no such file or directory"))
|
|
||||||
})
|
|
||||||
|
|
||||||
It("podman search with wildcards", func() {
|
It("podman search with wildcards", func() {
|
||||||
registryAddress, srv, serverErr := CreateMockRegistryServer()
|
|
||||||
defer CloseMockRegistryServer(srv, serverErr)
|
|
||||||
|
|
||||||
search := podmanTest.PodmanExitCleanly("search", "--tls-verify=false", registryAddress+"/*alpine*")
|
search := podmanTest.PodmanExitCleanly("search", "--tls-verify=false", registryAddress+"/*alpine*")
|
||||||
Expect(len(search.OutputToStringArray())).To(BeNumerically(">", 1))
|
Expect(len(search.OutputToStringArray())).To(BeNumerically(">", 1))
|
||||||
Expect(search.OutputToString()).To(ContainSubstring("alpine"))
|
Expect(search.OutputToString()).To(ContainSubstring("alpine"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman search repository tags", func() {
|
It("podman search repository tags", func() {
|
||||||
registryAddress, srv, serverErr := CreateMockRegistryServer()
|
|
||||||
defer CloseMockRegistryServer(srv, serverErr)
|
|
||||||
|
|
||||||
search := podmanTest.PodmanExitCleanly("search", "--list-tags", "--limit", "30", "--tls-verify=false", registryAddress+"/podman/stable")
|
search := podmanTest.PodmanExitCleanly("search", "--list-tags", "--limit", "30", "--tls-verify=false", registryAddress+"/podman/stable")
|
||||||
Expect(search.OutputToStringArray()).To(HaveLen(31))
|
Expect(search.OutputToStringArray()).To(HaveLen(31))
|
||||||
|
|
||||||
@@ -360,10 +221,103 @@ registries = []`
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("podman search with limit over 100", func() {
|
It("podman search with limit over 100", func() {
|
||||||
registryAddress, srv, serverErr := CreateMockRegistryServer()
|
|
||||||
defer CloseMockRegistryServer(srv, serverErr)
|
|
||||||
|
|
||||||
search := podmanTest.PodmanExitCleanly("search", "--limit", "100", "--tls-verify=false", registryAddress+"/podman")
|
search := podmanTest.PodmanExitCleanly("search", "--limit", "100", "--tls-verify=false", registryAddress+"/podman")
|
||||||
Expect(len(search.OutputToStringArray())).To(BeNumerically("<=", 101))
|
Expect(len(search.OutputToStringArray())).To(BeNumerically("<=", 101))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
Context("podman search with container-based registries", func() {
|
||||||
|
var ep endpoint
|
||||||
|
var image string
|
||||||
|
var registryName string
|
||||||
|
var port int64
|
||||||
|
|
||||||
|
setupRegistryConfig := func(ep endpoint, registryName string, template *template.Template) {
|
||||||
|
var buffer bytes.Buffer
|
||||||
|
err := template.Execute(&buffer, ep)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
podmanTest.setRegistriesConfigEnv(buffer.Bytes())
|
||||||
|
err = os.WriteFile(fmt.Sprintf("%s/%s.conf", tempdir, registryName), buffer.Bytes(), 0o644)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
}
|
||||||
|
|
||||||
|
BeforeEach(func() {
|
||||||
|
registryName = fmt.Sprintf("registry%d", GinkgoRandomSeed())
|
||||||
|
ep = mockFakeRegistryServerAsContainer(registryName)
|
||||||
|
image = pushAlpineImageIntoMockRegistry(ep)
|
||||||
|
|
||||||
|
port, err = strconv.ParseInt(ep.Port, 10, 64)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
})
|
||||||
|
|
||||||
|
AfterEach(func() {
|
||||||
|
resetRegistriesConfigEnv()
|
||||||
|
podmanTest.PodmanExitCleanly("rm", "-f", registryName)
|
||||||
|
})
|
||||||
|
|
||||||
|
It("podman search attempts HTTP if tls-verify flag is set false", func() {
|
||||||
|
// if this test succeeded, there will be no output (there is no entry named fake/image:andtag in an empty registry)
|
||||||
|
// and the exit code will be 0
|
||||||
|
search := podmanTest.PodmanExitCleanly("search", fmt.Sprintf("%s/fake/image:andtag", ep.Address()), "--tls-verify=false")
|
||||||
|
Expect(search.OutputToString()).Should(BeEmpty())
|
||||||
|
})
|
||||||
|
|
||||||
|
It("podman search in local registry", func() {
|
||||||
|
search := podmanTest.PodmanExitCleanly("search", image, "--tls-verify=false")
|
||||||
|
Expect(search.OutputToString()).ShouldNot(BeEmpty())
|
||||||
|
|
||||||
|
// podman search v2 registry with empty query
|
||||||
|
searchEmpty := podmanTest.PodmanExitCleanly("search", fmt.Sprintf("%s/", ep.Address()), "--tls-verify=false")
|
||||||
|
Expect(searchEmpty.OutputToStringArray()).ToNot(BeEmpty())
|
||||||
|
Expect(search.OutputToString()).To(ContainSubstring("my-alpine"))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("podman search attempts HTTP if registry is in registries.insecure and force secure is false", func() {
|
||||||
|
// registries.conf set up
|
||||||
|
setupRegistryConfig(ep, registryName, registryFileTmpl)
|
||||||
|
if IsRemote() {
|
||||||
|
podmanTest.RestartRemoteService()
|
||||||
|
defer podmanTest.RestartRemoteService()
|
||||||
|
}
|
||||||
|
|
||||||
|
search := podmanTest.PodmanExitCleanly("search", image)
|
||||||
|
Expect(search.OutputToString()).To(ContainSubstring("my-alpine"))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("podman search doesn't attempt HTTP if force secure is true", func() {
|
||||||
|
setupRegistryConfig(ep, registryName, registryFileTmpl)
|
||||||
|
if IsRemote() {
|
||||||
|
podmanTest.RestartRemoteService()
|
||||||
|
defer podmanTest.RestartRemoteService()
|
||||||
|
}
|
||||||
|
|
||||||
|
search := podmanTest.Podman([]string{"search", image, "--tls-verify=true"})
|
||||||
|
search.WaitWithDefaultTimeout()
|
||||||
|
|
||||||
|
Expect(search).Should(ExitWithError(125, fmt.Sprintf(`couldn't search registry "localhost:%d": pinging container registry localhost:%d: Get "https://localhost:%d/v2/": http: server gave HTTP response to HTTPS client`, port, port, port)))
|
||||||
|
Expect(search.OutputToString()).Should(BeEmpty())
|
||||||
|
})
|
||||||
|
|
||||||
|
It("podman search doesn't attempt HTTP if registry is not listed as insecure", func() {
|
||||||
|
setupRegistryConfig(ep, registryName, registryFileBadTmpl)
|
||||||
|
if IsRemote() {
|
||||||
|
podmanTest.RestartRemoteService()
|
||||||
|
defer podmanTest.RestartRemoteService()
|
||||||
|
}
|
||||||
|
|
||||||
|
search := podmanTest.Podman([]string{"search", image})
|
||||||
|
search.WaitWithDefaultTimeout()
|
||||||
|
|
||||||
|
Expect(search).Should(ExitWithError(125, fmt.Sprintf(`couldn't search registry "localhost:%d": pinging container registry localhost:%d: Get "https://localhost:%d/v2/": http: server gave HTTP response to HTTPS client`, port, port, port)))
|
||||||
|
Expect(search.OutputToString()).Should(BeEmpty())
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
// search should fail with nonexistent authfile
|
||||||
|
It("podman search fail with nonexistent --authfile", func() {
|
||||||
|
search := podmanTest.Podman([]string{"search", "--authfile", "/tmp/nonexistent", ALPINE})
|
||||||
|
search.WaitWithDefaultTimeout()
|
||||||
|
Expect(search).To(ExitWithError(125, "credential file is not accessible: faccessat /tmp/nonexistent: no such file or directory"))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user