Search in sources :

Example 11 with RegistryAuth

use of com.spotify.docker.client.messages.RegistryAuth in project docker-client by spotify.

the class DockerConfigReaderTest method testFromDockerConfig_FullDockerCfg.

@Test
public void testFromDockerConfig_FullDockerCfg() throws Exception {
    final RegistryAuth registryAuth = reader.fromFirstConfig(getTestFilePath("dockerConfig/fullDockerCfg"));
    assertThat(registryAuth, equalTo(DOCKER_AUTH_CONFIG));
}
Also used : RegistryAuth(com.spotify.docker.client.messages.RegistryAuth) Test(org.junit.Test)

Example 12 with RegistryAuth

use of com.spotify.docker.client.messages.RegistryAuth in project docker-client by spotify.

the class FixedRegistryAuthSupplierTest method authForReturnsWrappedAuthRegistry.

@Test
public void authForReturnsWrappedAuthRegistry() throws DockerException {
    final RegistryAuth registryAuth = mock(RegistryAuth.class);
    FixedRegistryAuthSupplier fixedRegistryAuthSupplier = new FixedRegistryAuthSupplier(registryAuth, null);
    assertEquals(registryAuth, fixedRegistryAuthSupplier.authFor("doesn't matter"));
}
Also used : RegistryAuth(com.spotify.docker.client.messages.RegistryAuth) Test(org.junit.Test)

Example 13 with RegistryAuth

use of com.spotify.docker.client.messages.RegistryAuth in project docker-client by spotify.

the class PushPullIT method testPullHubPrivateImageWithAuth.

@Test
public void testPullHubPrivateImageWithAuth() throws Exception {
    final RegistryAuth registryAuth = RegistryAuth.builder().username(HUB_AUTH_USERNAME2).password(HUB_AUTH_PASSWORD2).build();
    client.pull("dxia2/scratch-private:latest", registryAuth);
}
Also used : RegistryAuth(com.spotify.docker.client.messages.RegistryAuth) Test(org.junit.Test)

Example 14 with RegistryAuth

use of com.spotify.docker.client.messages.RegistryAuth in project docker-client by spotify.

the class PushPullIT method setup.

@Before
public void setup() throws Exception {
    final RegistryAuth registryAuth = RegistryAuth.builder().username(LOCAL_AUTH_USERNAME).password(LOCAL_AUTH_PASSWORD).build();
    client = DefaultDockerClient.fromEnv().registryAuthSupplier(new FixedRegistryAuthSupplier(registryAuth, RegistryConfigs.create(singletonMap(HUB_NAME, registryAuth)))).build();
    System.out.printf("- %s\n", testName.getMethodName());
}
Also used : FixedRegistryAuthSupplier(com.spotify.docker.client.auth.FixedRegistryAuthSupplier) RegistryAuth(com.spotify.docker.client.messages.RegistryAuth) Before(org.junit.Before)

Example 15 with RegistryAuth

use of com.spotify.docker.client.messages.RegistryAuth in project docker-client by spotify.

the class PushPullIT method testPushImageToPrivateAuthedRegistryWithAuth.

@Test
public void testPushImageToPrivateAuthedRegistryWithAuth() throws Exception {
    registryContainerId = startAuthedRegistry(client);
    // Push an image to the private registry and check it succeeds
    final String dockerDirectory = Resources.getResource("dockerDirectory").getPath();
    client.build(Paths.get(dockerDirectory), LOCAL_IMAGE);
    client.tag(LOCAL_IMAGE, LOCAL_IMAGE_2);
    client.push(LOCAL_IMAGE);
    // Push the same image again under a different user
    final RegistryAuth registryAuth = RegistryAuth.builder().username(LOCAL_AUTH_USERNAME_2).password(LOCAL_AUTH_PASSWORD_2).build();
    client.push(LOCAL_IMAGE_2, registryAuth);
    // We should be able to pull it again
    client.pull(LOCAL_IMAGE);
    client.pull(LOCAL_IMAGE_2);
}
Also used : RegistryAuth(com.spotify.docker.client.messages.RegistryAuth) Test(org.junit.Test)

Aggregations

RegistryAuth (com.spotify.docker.client.messages.RegistryAuth)28 Test (org.junit.Test)22 FixedRegistryAuthSupplier (com.spotify.docker.client.auth.FixedRegistryAuthSupplier)7 DefaultDockerClient (com.spotify.docker.client.DefaultDockerClient)4 DockerClient (com.spotify.docker.client.DockerClient)4 Path (java.nio.file.Path)4 Endpoint (com.spotify.docker.client.messages.swarm.Endpoint)2 HashMap (java.util.HashMap)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 AccessToken (com.google.auth.oauth2.AccessToken)1 DockerException (com.spotify.docker.client.exceptions.DockerException)1 ProgressMessage (com.spotify.docker.client.messages.ProgressMessage)1 RegistryAuthV2 (com.spotify.docker.client.messages.RegistryAuthV2)1 RegistryConfigs (com.spotify.docker.client.messages.RegistryConfigs)1 BufferedReader (java.io.BufferedReader)1 BufferedWriter (java.io.BufferedWriter)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 OutputStreamWriter (java.io.OutputStreamWriter)1