Search in sources :

Example 6 with RegistryAuth

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

the class DockerConfigReaderTest method testFromDockerConfig_IdentityToken.

@Test
public void testFromDockerConfig_IdentityToken() throws Exception {
    final RegistryAuth authConfig = reader.fromFirstConfig(getTestFilePath("dockerConfig/identityTokenConfig.json"));
    assertThat(authConfig, equalTo(IDENTITY_TOKEN_AUTH_CONFIG));
}
Also used : RegistryAuth(com.spotify.docker.client.messages.RegistryAuth) Test(org.junit.Test)

Example 7 with RegistryAuth

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

the class DockerConfigReaderTest method testFromDockerConfig_CredsStore.

@Test
public void testFromDockerConfig_CredsStore() throws Exception {
    assumeTrue("Need to have a credential store.", getAuthCredentialsExist());
    String domain1 = "https://test.fakedomain.com";
    String domain2 = "https://test.fakedomain2.com";
    String testAuth1 = "{\n" + "\t\"ServerURL\": \"" + domain1 + "\",\n" + "\t\"Username\": \"david\",\n" + "\t\"Secret\": \"passw0rd1\"\n" + "}";
    String testAuth2 = "{\n" + "\t\"ServerURL\": \"" + domain2 + "\",\n" + "\t\"Username\": \"carl\",\n" + "\t\"Secret\": \"myPassword\"\n" + "}";
    storeAuthCredential(testAuth1);
    storeAuthCredential(testAuth2);
    final Path path = getTestFilePath("dockerConfig/" + getCredsStoreFileName());
    final RegistryConfigs configs = reader.fromConfig(path);
    for (RegistryAuth authConfigs : configs.configs().values()) {
        if (domain1.equals(authConfigs.serverAddress())) {
            assertThat(authConfigs.username(), equalTo("david"));
            assertThat(authConfigs.password(), equalTo("passw0rd1"));
        } else if (domain2.equals(authConfigs.serverAddress())) {
            assertThat(authConfigs.username(), equalTo("carl"));
            assertThat(authConfigs.password(), equalTo("myPassword"));
        }
    }
    eraseAuthCredential(domain1);
    eraseAuthCredential(domain2);
}
Also used : Path(java.nio.file.Path) RegistryConfigs(com.spotify.docker.client.messages.RegistryConfigs) RegistryAuth(com.spotify.docker.client.messages.RegistryAuth) Test(org.junit.Test)

Example 8 with RegistryAuth

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

the class DockerConfigReaderTest method testFromDockerConfig_MultiConfig.

@Test
public void testFromDockerConfig_MultiConfig() throws Exception {
    final Path path = getTestFilePath("dockerConfig/multiConfig.json");
    final RegistryAuth myDockParsed = reader.fromConfig(path, "https://narnia.mydock.io/v1/");
    assertThat(myDockParsed, equalTo(MY_AUTH_CONFIG));
    final RegistryAuth dockerIoParsed = reader.fromConfig(path, "https://index.docker.io/v1/");
    assertThat(dockerIoParsed, equalTo(DOCKER_AUTH_CONFIG));
}
Also used : Path(java.nio.file.Path) RegistryAuth(com.spotify.docker.client.messages.RegistryAuth) Test(org.junit.Test)

Example 9 with RegistryAuth

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

the class DockerConfigReaderTest method testFromDockerConfig_WrongConfigs.

@Test
public void testFromDockerConfig_WrongConfigs() throws Exception {
    final RegistryAuth registryAuth1 = reader.fromFirstConfig(getTestFilePath("dockerConfig/wrongConfig1.json"));
    assertThat(registryAuth1, is(emptyRegistryAuth()));
    final RegistryAuth registryAuth2 = reader.fromFirstConfig(getTestFilePath("dockerConfig/wrongConfig2.json"));
    assertThat(registryAuth2, is(emptyRegistryAuth()));
}
Also used : RegistryAuth(com.spotify.docker.client.messages.RegistryAuth) Test(org.junit.Test)

Example 10 with RegistryAuth

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

the class DockerConfigReaderTest method testFromDockerConfig_FullConfig.

@Test
public void testFromDockerConfig_FullConfig() throws Exception {
    final RegistryAuth registryAuth = reader.fromFirstConfig(getTestFilePath("dockerConfig/fullConfig.json"));
    assertThat(registryAuth, equalTo(DOCKER_AUTH_CONFIG));
}
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