use of com.spotify.docker.client.messages.RegistryAuth in project docker-client by spotify.
the class DefaultDockerClientTest method testBadAuth.
@Test
public void testBadAuth() throws Exception {
final RegistryAuth badRegistryAuth = RegistryAuth.builder().username(AUTH_USERNAME).email(// docker < 1.11 requires email to be set in RegistryAuth
"user@example.com").password("foobar").build();
final int statusCode = sut.auth(badRegistryAuth);
assertThat(statusCode, equalTo(401));
}
use of com.spotify.docker.client.messages.RegistryAuth in project docker-client by spotify.
the class PushPullIT method testBuildHubPrivateImageWithAuth.
@Test
public void testBuildHubPrivateImageWithAuth() throws Exception {
final String dockerDirectory = Resources.getResource("dockerDirectoryNeedsAuth").getPath();
final RegistryAuth registryAuth = RegistryAuth.builder().username(HUB_AUTH_USERNAME2).password(HUB_AUTH_PASSWORD2).build();
final DockerClient client = DefaultDockerClient.fromEnv().registryAuthSupplier(new FixedRegistryAuthSupplier(registryAuth, RegistryConfigs.create(singletonMap(HUB_NAME, registryAuth)))).build();
client.build(Paths.get(dockerDirectory), "testauth", BuildParam.pullNewerImage());
}
use of com.spotify.docker.client.messages.RegistryAuth in project docker-client by spotify.
the class PushPullIT method testPushHubPublicImageWithAuth.
@Test
public void testPushHubPublicImageWithAuth() throws Exception {
// Push an image to a public repo on Docker Hub and check it succeeds
final String dockerDirectory = Resources.getResource("dockerDirectory").getPath();
final RegistryAuth registryAuth = RegistryAuth.builder().username(HUB_AUTH_USERNAME).password(HUB_AUTH_PASSWORD).build();
final DockerClient client = DefaultDockerClient.fromEnv().registryAuthSupplier(new FixedRegistryAuthSupplier(registryAuth, RegistryConfigs.create(singletonMap(HUB_NAME, registryAuth)))).build();
client.build(Paths.get(dockerDirectory), HUB_PUBLIC_IMAGE);
client.push(HUB_PUBLIC_IMAGE);
}
use of com.spotify.docker.client.messages.RegistryAuth in project docker-client by spotify.
the class PushPullIT method testPullHubPrivateImageWithBadAuth.
@Test
public void testPullHubPrivateImageWithBadAuth() throws Exception {
final RegistryAuth badRegistryAuth = RegistryAuth.builder().username(HUB_AUTH_USERNAME2).password("foobar").build();
exception.expect(DockerException.class);
exception.expectCause(isA(NotAuthorizedException.class));
client.pull(CIRROS_PRIVATE_LATEST, badRegistryAuth);
}
use of com.spotify.docker.client.messages.RegistryAuth in project docker-client by spotify.
the class MultiRegistryAuthSupplierTest method testAuthForBuild.
@Test
public void testAuthForBuild() throws Exception {
final RegistryAuth auth1 = RegistryAuth.builder().username("1").serverAddress("a").build();
final RegistryAuth auth2 = RegistryAuth.builder().username("2").serverAddress("b").build();
final RegistryAuth auth3 = RegistryAuth.builder().username("3").serverAddress("b").build();
final RegistryAuth auth4 = RegistryAuth.builder().username("4").serverAddress("c").build();
when(supplier1.authForBuild()).thenReturn(RegistryConfigs.create(ImmutableMap.of("a", auth1, "b", auth2)));
when(supplier2.authForBuild()).thenReturn(RegistryConfigs.create(ImmutableMap.of("b", auth3, "c", auth4)));
// ensure that supplier1 had priority for server b
assertThat(multiSupplier.authForBuild().configs(), allOf(hasEntry("a", auth1), hasEntry("b", auth2), hasEntry("c", auth4)));
}
Aggregations