use of com.spotify.docker.client.messages.RegistryAuth in project docker-client by spotify.
the class PushPullIT method testPushHubPrivateImageWithAuth.
@Test
public void testPushHubPrivateImageWithAuth() throws Exception {
// Push an image to a private 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_PRIVATE_IMAGE);
client.push(HUB_PRIVATE_IMAGE);
}
use of com.spotify.docker.client.messages.RegistryAuth in project docker-client by spotify.
the class ConfigFileRegistryAuthSupplierTest method testAuthFor_Success.
@Test
public void testAuthFor_Success() throws Exception {
final RegistryAuth auth = RegistryAuth.builder().username("abc123").build();
when(reader.fromConfig(configFile.toPath(), "foo.example.net")).thenReturn(auth);
assertThat(supplier.authFor("foo.example.net/bar:1.2.3"), is(equalTo(auth)));
}
use of com.spotify.docker.client.messages.RegistryAuth in project docker-client by spotify.
the class MultiRegistryAuthSupplierTest method testAuthFor.
@Test
public void testAuthFor() throws Exception {
final String image1 = "foobar:latest";
final RegistryAuth auth1 = RegistryAuth.builder().build();
when(supplier1.authFor(image1)).thenReturn(auth1);
assertThat(multiSupplier.authFor(image1), is(auth1));
verify(supplier2, never()).authFor(image1);
// test fallback
final String image2 = "bizbat:1.2.3";
final RegistryAuth auth2 = RegistryAuth.builder().email("foo@biz.com").build();
when(supplier1.authFor(image2)).thenReturn(null);
when(supplier2.authFor(image2)).thenReturn(auth2);
assertThat(multiSupplier.authFor(image2), is(auth2));
}
use of com.spotify.docker.client.messages.RegistryAuth in project docker-client by spotify.
the class DefaultDockerClientTest method testMissingAuthParam.
@Test
public void testMissingAuthParam() throws Exception {
requireDockerApiVersionLessThan("1.23", "https://github.com/docker/docker/issues/24093");
final RegistryAuth badRegistryAuth = RegistryAuth.builder().username(AUTH_USERNAME).build();
final int statusCode = sut.auth(badRegistryAuth);
assertThat(statusCode, equalTo(500));
}
use of com.spotify.docker.client.messages.RegistryAuth in project docker-client by spotify.
the class DockerConfigReaderTest method testFromDockerConfig_IncompleteConfig.
@Test
public void testFromDockerConfig_IncompleteConfig() throws Exception {
final RegistryAuth registryAuth = reader.fromFirstConfig(getTestFilePath("dockerConfig/incompleteConfig.json"));
final RegistryAuth expected = RegistryAuth.builder().email("dockerman@hub.com").serverAddress("https://different.docker.io/v1/").build();
assertThat(registryAuth, is(expected));
}
Aggregations