MCPcopy Create free account
hub / github.com/docker/compose / TestBuildSSH

Function TestBuildSSH

pkg/e2e/build_test.go:146–199  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

144}
145
146func TestBuildSSH(t *testing.T) {
147 if runtime.GOOS == "windows" {
148 t.Skip("Running on Windows. Skipping...")
149 }
150 c := NewParallelCLI(t)
151
152 t.Run("build failed with ssh default value", func(t *testing.T) {
153 res := c.RunDockerComposeCmdNoCheck(t, "--project-directory", "fixtures/build-test", "build", "--ssh", "")
154 res.Assert(t, icmd.Expected{
155 ExitCode: 1,
156 Err: "invalid empty ssh agent socket: make sure SSH_AUTH_SOCK is set",
157 })
158 })
159
160 t.Run("build succeed with ssh from Compose file", func(t *testing.T) {
161 c.RunDockerOrExitError(t, "rmi", "build-test-ssh")
162
163 c.RunDockerComposeCmd(t, "--project-directory", "fixtures/build-test/ssh", "build")
164 c.RunDockerCmd(t, "image", "inspect", "build-test-ssh")
165 })
166
167 t.Run("build succeed with ssh from CLI", func(t *testing.T) {
168 c.RunDockerOrExitError(t, "rmi", "build-test-ssh")
169
170 c.RunDockerComposeCmd(t, "-f", "fixtures/build-test/ssh/compose-without-ssh.yaml", "--project-directory",
171 "fixtures/build-test/ssh", "build", "--no-cache", "--ssh", "fake-ssh=./fixtures/build-test/ssh/fake_rsa")
172 c.RunDockerCmd(t, "image", "inspect", "build-test-ssh")
173 })
174
175 /*
176 FIXME disabled waiting for https://github.com/moby/buildkit/issues/5558
177 t.Run("build failed with wrong ssh key id from CLI", func(t *testing.T) {
178 c.RunDockerOrExitError(t, "rmi", "build-test-ssh")
179
180 res := c.RunDockerComposeCmdNoCheck(t, "-f", "fixtures/build-test/ssh/compose-without-ssh.yaml",
181 "--project-directory", "fixtures/build-test/ssh", "build", "--no-cache", "--ssh",
182 "wrong-ssh=./fixtures/build-test/ssh/fake_rsa")
183 res.Assert(t, icmd.Expected{
184 ExitCode: 1,
185 Err: "unset ssh forward key fake-ssh",
186 })
187 })
188 */
189
190 t.Run("build succeed as part of up with ssh from Compose file", func(t *testing.T) {
191 c.RunDockerOrExitError(t, "rmi", "build-test-ssh")
192
193 c.RunDockerComposeCmd(t, "--project-directory", "fixtures/build-test/ssh", "up", "-d", "--build")
194 t.Cleanup(func() {
195 c.RunDockerComposeCmd(t, "--project-directory", "fixtures/build-test/ssh", "down")
196 })
197 c.RunDockerCmd(t, "image", "inspect", "build-test-ssh")
198 })
199}
200
201func TestBuildSecrets(t *testing.T) {
202 if runtime.GOOS == "windows" {

Callers

nothing calls this directly

Calls 5

NewParallelCLIFunction · 0.85
RunDockerOrExitErrorMethod · 0.80
RunDockerComposeCmdMethod · 0.80
RunDockerCmdMethod · 0.80

Tested by

no test coverage detected