Search in sources :

Example 36 with AuthConfig

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

the class AuthConfigFactoryTest method testFromSettingsDefault.

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

Example 37 with AuthConfig

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

the class AuthConfigFactoryTest method awsTemporaryCredentialsArePickedUpFromEnvironment.

@Test
public void awsTemporaryCredentialsArePickedUpFromEnvironment() throws MojoExecutionException {
    givenAwsSdkIsDisabled();
    String accessKeyId = randomUUID().toString();
    String secretAccessKey = randomUUID().toString();
    String sessionToken = randomUUID().toString();
    environmentVariables.set("AWS_ACCESS_KEY_ID", accessKeyId);
    environmentVariables.set("AWS_SECRET_ACCESS_KEY", secretAccessKey);
    environmentVariables.set("AWS_SESSION_TOKEN", sessionToken);
    AuthConfig authConfig = factory.createAuthConfig(false, true, null, settings, "user", ECR_NAME);
    verifyAuthConfig(authConfig, accessKeyId, secretAccessKey, null, sessionToken);
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) AuthConfig(io.fabric8.maven.docker.access.AuthConfig) Test(org.junit.Test)

Example 38 with AuthConfig

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

the class AuthConfigFactoryTest method testFromPluginConfigurationPull.

@Test
public void testFromPluginConfigurationPull() throws MojoExecutionException {
    Map pullConfig = new HashMap();
    pullConfig.put("username", "roland");
    pullConfig.put("password", "secret");
    pullConfig.put("email", "roland@jolokia.org");
    Map pluginConfig = new HashMap();
    pluginConfig.put("pull", pullConfig);
    AuthConfig config = factory.createAuthConfig(false, false, pluginConfig, settings, null, null);
    verifyAuthConfig(config, "roland", "secret", "roland@jolokia.org");
}
Also used : HashMap(java.util.HashMap) AuthConfig(io.fabric8.maven.docker.access.AuthConfig) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) Collections.singletonMap(java.util.Collections.singletonMap) Test(org.junit.Test)

Example 39 with AuthConfig

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

the class AuthConfigFactoryTest method getAuthConfigViaAwsSdk.

@Test
public void getAuthConfigViaAwsSdk() throws MojoExecutionException {
    String accessKeyId = randomUUID().toString();
    String secretAccessKey = randomUUID().toString();
    new MockedAwsSdkAuthConfigFactory(accessKeyId, secretAccessKey);
    AuthConfig authConfig = factory.createAuthConfig(false, true, null, settings, "user", ECR_NAME);
    verifyAuthConfig(authConfig, accessKeyId, secretAccessKey, null, null);
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) AuthConfig(io.fabric8.maven.docker.access.AuthConfig) Test(org.junit.Test)

Example 40 with AuthConfig

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

the class AuthConfigFactoryTest method ecsTaskRole.

@Test
public void ecsTaskRole() throws IOException, MojoExecutionException {
    givenAwsSdkIsDisabled();
    String containerCredentialsUri = "/v2/credentials/" + randomUUID().toString();
    String accessKeyId = randomUUID().toString();
    String secretAccessKey = randomUUID().toString();
    String sessionToken = randomUUID().toString();
    givenEcsMetadataService(containerCredentialsUri, accessKeyId, secretAccessKey, sessionToken);
    setupEcsMetadataConfiguration(httpServer, containerCredentialsUri);
    AuthConfig authConfig = factory.createAuthConfig(false, true, null, settings, "user", ECR_NAME);
    verifyAuthConfig(authConfig, accessKeyId, secretAccessKey, null, sessionToken);
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) AuthConfig(io.fabric8.maven.docker.access.AuthConfig) 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