Search in sources :

Example 36 with AuthConfig

use of io.fabric8.maven.docker.access.AuthConfig in project docker-maven-plugin by fabric8io.

the class AuthConfigFactoryTest method testFromSettingsDefault2.

@Test
public void testFromSettingsDefault2() throws MojoExecutionException {
    setupServers();
    AuthConfig config = factory.createAuthConfig(isPush, false, null, settings, "tanja", null);
    assertNotNull(config);
    verifyAuthConfig(config, "tanja", "doublesecret", "tanja@jolokia.org");
}
Also used : AuthConfig(io.fabric8.maven.docker.access.AuthConfig) Test(org.junit.Test)

Example 37 with AuthConfig

use of io.fabric8.maven.docker.access.AuthConfig in project docker-maven-plugin by fabric8io.

the class AuthConfigFactoryTest method testFromSettingsSimple.

@Test
public void testFromSettingsSimple() throws MojoExecutionException {
    setupServers();
    AuthConfig config = factory.createAuthConfig(isPush, false, null, settings, "roland", "test.org");
    assertNotNull(config);
    verifyAuthConfig(config, "roland", "secret", "roland@jolokia.org");
}
Also used : AuthConfig(io.fabric8.maven.docker.access.AuthConfig) Test(org.junit.Test)

Example 38 with AuthConfig

use of io.fabric8.maven.docker.access.AuthConfig in project docker-maven-plugin by fabric8io.

the class AwsSdkAuthConfigFactoryTest method reflectionWorksForSessionCredentials.

@Test
public void reflectionWorksForSessionCredentials() {
    String accessKey = randomUUID().toString();
    String secretKey = randomUUID().toString();
    String sessionToken = randomUUID().toString();
    environmentVariables.set("AWSCredentials.AWSAccessKeyId", accessKey);
    environmentVariables.set("AWSCredentials.AWSSecretKey", secretKey);
    environmentVariables.set("AWSSessionCredentials.SessionToken", sessionToken);
    AuthConfig authConfig = objectUnderTest.createAuthConfig();
    assertNotNull(authConfig);
    assertEquals(accessKey, authConfig.getUsername());
    assertEquals(secretKey, authConfig.getPassword());
    assertEquals(sessionToken, authConfig.getAuth());
    assertNull(authConfig.getIdentityToken());
}
Also used : AuthConfig(io.fabric8.maven.docker.access.AuthConfig) Test(org.junit.Test)

Example 39 with AuthConfig

use of io.fabric8.maven.docker.access.AuthConfig in project docker-maven-plugin by fabric8io.

the class AwsSdkAuthConfigFactoryTest method nullValueIsPassedOn.

@Test
public void nullValueIsPassedOn() {
    AuthConfig authConfig = objectUnderTest.createAuthConfig();
    assertNull(authConfig);
}
Also used : AuthConfig(io.fabric8.maven.docker.access.AuthConfig) Test(org.junit.Test)

Example 40 with AuthConfig

use of io.fabric8.maven.docker.access.AuthConfig in project docker-maven-plugin by fabric8io.

the class EcrExtendedAuthTest method testClientClosedAndCredentialsDecoded.

@Test
public void testClientClosedAndCredentialsDecoded(@Mocked final CloseableHttpClient closeableHttpClient, @Mocked final CloseableHttpResponse closeableHttpResponse, @Mocked final StatusLine statusLine) throws IOException, MojoExecutionException {
    final HttpEntity entity = new StringEntity("{\"authorizationData\": [{" + "\"authorizationToken\": \"QVdTOnBhc3N3b3Jk\"," + "\"expiresAt\": 1448878779.809," + "\"proxyEndpoint\": \"https://012345678910.dkr.ecr.eu-west-1.amazonaws.com\"}]}");
    new Expectations() {

        {
            statusLine.getStatusCode();
            result = 200;
            closeableHttpResponse.getEntity();
            result = entity;
        }
    };
    EcrExtendedAuth eea = new EcrExtendedAuth(logger, "123456789012.dkr.ecr.eu-west-1.amazonaws.com") {

        CloseableHttpClient createClient() {
            return closeableHttpClient;
        }
    };
    AuthConfig localCredentials = new AuthConfig("username", "password", null, null);
    AuthConfig awsCredentials = eea.extendedAuth(localCredentials);
    assertEquals("AWS", awsCredentials.getUsername());
    assertEquals("password", awsCredentials.getPassword());
    new Verifications() {

        {
            closeableHttpClient.close();
        }
    };
}
Also used : Expectations(mockit.Expectations) StringEntity(org.apache.http.entity.StringEntity) HttpEntity(org.apache.http.HttpEntity) AuthConfig(io.fabric8.maven.docker.access.AuthConfig) Verifications(mockit.Verifications) Test(org.junit.Test)

Aggregations

AuthConfig (io.fabric8.maven.docker.access.AuthConfig)38 Test (org.junit.Test)26 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)5 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)5 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)4 ImageName (io.fabric8.maven.docker.util.ImageName)4 HashMap (java.util.HashMap)4 Credential (com.google.cloud.tools.jib.api.Credential)3 JsonObject (com.google.gson.JsonObject)3 IOException (java.io.IOException)3 Date (java.util.Date)3 Map (java.util.Map)3 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 Collections.singletonMap (java.util.Collections.singletonMap)2 Expectations (mockit.Expectations)2 Verifications (mockit.Verifications)2 HttpPost (org.apache.http.client.methods.HttpPost)2 StringEntity (org.apache.http.entity.StringEntity)2 Gson (com.google.gson.Gson)1