use of io.fabric8.maven.docker.access.AuthConfig in project docker-maven-plugin by fabric8io.
the class AwsSigner4RequestTest method testSign.
@Test
public void testSign() throws Exception {
HttpPost request = new HttpPost("https://ecr.us-east-1.amazonaws.com/");
request.setHeader("host", "ecr.us-east-1.amazonaws.com");
request.setHeader("Content-Type", "application/x-amz-json-1.1");
request.setHeader("X-Amz-Target", "AmazonEC2ContainerRegistry_V20150921.GetAuthorizationToken");
request.setEntity(new StringEntity("{\"registryIds\":[\"012345678901\"]}", StandardCharsets.UTF_8));
AwsSigner4 signer = new AwsSigner4("us-east-1", "ecr");
Date signingTime = AwsSigner4Request.TIME_FORMAT.parse("20150830T123600Z");
AwsSigner4Request sr = new AwsSigner4Request("us-east-1", "service", request, signingTime);
AuthConfig credentials = new AuthConfig("AKIDEXAMPLE", "wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY", null, null);
Assert.assertEquals(TASK1, signer.task1(sr));
Assert.assertEquals(TASK2, signer.task2(sr));
StringBuilder dst = new StringBuilder();
AwsSigner4.hexEncode(dst, signer.task3(sr, credentials));
Assert.assertEquals(TASK3, dst.toString());
Assert.assertEquals(TASK4, signer.task4(sr, credentials));
}
use of io.fabric8.maven.docker.access.AuthConfig in project docker-maven-plugin by fabric8io.
the class DockerAccessWithHcClient method pushImage.
@Override
public void pushImage(String image, AuthConfig authConfig, String registry, int retries) throws DockerAccessException {
ImageName name = new ImageName(image);
String pushUrl = urlBuilder.pushImage(name, registry);
TemporaryImageHandler temporaryImageHandler = tagTemporaryImage(name, registry);
DockerAccessException dae = null;
try {
doPushImage(pushUrl, createAuthHeader(authConfig), createPullOrPushResponseHandler(), HTTP_OK, retries);
} catch (IOException e) {
dae = new DockerAccessException(e, "Unable to push '%s'%s", image, (registry != null) ? " to registry '" + registry + "'" : "");
throw dae;
} finally {
temporaryImageHandler.handle(dae);
}
}
use of io.fabric8.maven.docker.access.AuthConfig in project docker-maven-plugin by fabric8io.
the class JibBuildServiceTest method testGetRegistryCredentialsForPull.
@Test
@java.lang.SuppressWarnings("squid:S00112")
public void testGetRegistryCredentialsForPull() throws MojoExecutionException {
// Given
ImageConfiguration imageConfiguration = getImageConfiguration();
RegistryService.RegistryConfig registryConfig = new RegistryService.RegistryConfig.Builder().authConfig(Collections.emptyMap()).authConfigFactory(authConfigFactory).settings(settings).build();
mockAuthConfigFactory(false, registryConfig);
// When
Credential credential = JibBuildService.getRegistryCredentials(registryConfig, false, imageConfiguration, logger);
// Then
assertNotNull(credential);
assertEquals("testuserpull", credential.getUsername());
assertEquals("testpass", credential.getPassword());
}
use of io.fabric8.maven.docker.access.AuthConfig in project docker-maven-plugin by fabric8io.
the class AuthConfigTest method mapConstructor.
@Test
public void mapConstructor() {
AuthConfig config = new AuthConfig("roland", "#>secrets??", "roland@jolokia.org", null);
check(config);
}
use of io.fabric8.maven.docker.access.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");
}
Aggregations