use of com.spotify.docker.client.auth.RegistryAuthSupplier in project docker-client by spotify.
the class DefaultDockerClientUnitTest method buildThrowsIfRegistryAuthandRegistryAuthSupplierAreBothSpecified.
@Test
@SuppressWarnings("deprecated")
public void buildThrowsIfRegistryAuthandRegistryAuthSupplierAreBothSpecified() throws DockerCertificateException {
thrown.expect(IllegalStateException.class);
thrown.expectMessage("LOGIC ERROR");
final RegistryAuthSupplier authSupplier = mock(RegistryAuthSupplier.class);
// noinspection deprecation
DefaultDockerClient.builder().registryAuth(RegistryAuth.builder().identityToken("hello").build()).registryAuthSupplier(authSupplier).build();
}
use of com.spotify.docker.client.auth.RegistryAuthSupplier in project docker-client by spotify.
the class DefaultDockerClientUnitTest method testBuildPassesMultipleRegistryConfigs.
@Test
public void testBuildPassesMultipleRegistryConfigs() throws Exception {
final RegistryConfigs registryConfigs = RegistryConfigs.create(ImmutableMap.of("server1", RegistryAuth.builder().serverAddress("server1").username("u1").password("p1").email("e1").build(), "server2", RegistryAuth.builder().serverAddress("server2").username("u2").password("p2").email("e2").build()));
final RegistryAuthSupplier authSupplier = mock(RegistryAuthSupplier.class);
when(authSupplier.authForBuild()).thenReturn(registryConfigs);
final DefaultDockerClient client = builder.registryAuthSupplier(authSupplier).build();
// build() calls /version to check what format of header to send
enqueueServerApiVersion("1.20");
// TODO (mbrown): what to return for build response?
server.enqueue(new MockResponse().setResponseCode(200));
final Path path = Paths.get(Resources.getResource("dockerDirectory").toURI());
client.build(path);
final RecordedRequest versionRequest = takeRequestImmediately();
assertThat(versionRequest.getMethod(), is("GET"));
assertThat(versionRequest.getPath(), is("/version"));
final RecordedRequest buildRequest = takeRequestImmediately();
assertThat(buildRequest.getMethod(), is("POST"));
assertThat(buildRequest.getPath(), is("/build"));
final String registryConfigHeader = buildRequest.getHeader("X-Registry-Config");
assertThat(registryConfigHeader, is(not(nullValue())));
// check that the JSON in the header is equivalent to what we mocked out above from
// the registryAuthSupplier
final JsonNode headerJsonNode = toJson(BaseEncoding.base64().decode(registryConfigHeader));
assertThat(headerJsonNode, is(toJson(registryConfigs.configs())));
}
Aggregations