Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Auth config for build images #602

46 changes: 41 additions & 5 deletions docker_test.go
Expand Up @@ -1075,6 +1075,7 @@ func Test_BuildContainerFromDockerfileWithAuthConfig_ShouldSucceedWithAuthConfig
},
},
},

ExposedPorts: []string{"6379/tcp"},
WaitingFor: wait.ForLog("Ready to accept connections"),
}
Expand Down Expand Up @@ -1107,17 +1108,52 @@ func Test_BuildContainerFromDockerfileWithAuthConfig_ShouldFailWithoutAuthConfig
}

func prepareLocalRegistryWithAuth(t *testing.T) {
compose, err := NewDockerCompose("./testresources/docker-compose-auth.yml")
assert.NoError(t, err, "NewDockerCompose()")
ctx := context.Background()
wd, err := os.Getwd()
mdelapenya marked this conversation as resolved.
Show resolved Hide resolved
assert.NoError(t, err)
req := ContainerRequest{
Image: "registry:2",
ExposedPorts: []string{"5000:5000/tcp"},
Env: map[string]string{
"REGISTRY_AUTH": "htpasswd",
"REGISTRY_AUTH_HTPASSWD_REALM": "Registry",
"REGISTRY_AUTH_HTPASSWD_PATH": "/auth/htpasswd",
"REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY": "/data",
},
Mounts: ContainerMounts{
ContainerMount{
Source: GenericBindMountSource{
HostPath: fmt.Sprintf("%s/testresources/auth", wd),
},
Target: "/auth",
},
ContainerMount{
Source: GenericBindMountSource{
HostPath: fmt.Sprintf("%s/testresources/data", wd),
},
Target: "/data",
},
},
WaitingFor: wait.ForExposedPort(),
}

genContainerReq := GenericContainerRequest{
ProviderType: providerType,
ContainerRequest: req,
Started: true,
}

t.Log("creating registry container")

registryC, err := GenericContainer(ctx, genContainerReq)
assert.NoError(t, err)

t.Cleanup(func() {
assert.NoError(t, compose.Down(context.Background(), RemoveOrphans(true), RemoveImagesLocal), "compose.Down()")
assert.NoError(t, registryC.Terminate(context.Background()))
})

ctx, cancel := context.WithCancel(context.Background())
t.Cleanup(cancel)

assert.NoError(t, compose.Up(ctx, Wait(true)), "compose.Up()")
}

func prepareRedisImage(ctx context.Context, req ContainerRequest, t *testing.T) (Container, error) {
Expand Down
14 changes: 0 additions & 14 deletions testresources/docker-compose-auth.yml

This file was deleted.