use of io.fabric8.maven.docker.access.AuthConfig in project docker-maven-plugin by fabric8io.
the class AuthConfigFactory method getAuthConfigFromSystemProperties.
private AuthConfig getAuthConfigFromSystemProperties(LookupMode lookupMode) throws MojoExecutionException {
Properties props = System.getProperties();
String userKey = lookupMode.asSysProperty(AuthConfig.AUTH_USERNAME);
String passwordKey = lookupMode.asSysProperty(AuthConfig.AUTH_PASSWORD);
if (props.containsKey(userKey)) {
if (!props.containsKey(passwordKey)) {
throw new MojoExecutionException("No " + passwordKey + " provided for username " + props.getProperty(userKey));
}
return new AuthConfig(props.getProperty(userKey), decrypt(props.getProperty(passwordKey)), props.getProperty(lookupMode.asSysProperty(AuthConfig.AUTH_EMAIL)), getAuthProperty(props, lookupMode));
} else {
return null;
}
}
use of io.fabric8.maven.docker.access.AuthConfig in project docker-maven-plugin by fabric8io.
the class AuthConfigFactoryTest method testSystemProperty.
private void testSystemProperty(String prefix) throws Exception {
System.setProperty(prefix + ".username", "roland");
System.setProperty(prefix + ".password", "secret");
System.setProperty(prefix + ".email", "roland@jolokia.org");
try {
AuthConfig config = factory.createAuthConfig(true, false, null, settings, null, null);
verifyAuthConfig(config, "roland", "secret", "roland@jolokia.org");
} finally {
System.clearProperty(prefix + ".username");
System.clearProperty(prefix + ".password");
System.clearProperty(prefix + ".email");
}
}
use of io.fabric8.maven.docker.access.AuthConfig in project docker-maven-plugin by fabric8io.
the class AuthConfigFactoryTest method testDockerSystemPropertyHasPrecedence.
@Test
public void testDockerSystemPropertyHasPrecedence() throws Exception {
System.setProperty("docker.username", "roland");
System.setProperty("docker.password", "secret");
System.setProperty("docker.email", "roland@jolokia.org");
System.setProperty("registry.username", "_roland");
System.setProperty("registry.password", "_secret1");
System.setProperty("registry.email", "_1roland@jolokia.org");
try {
AuthConfig config = factory.createAuthConfig(true, false, null, settings, null, null);
verifyAuthConfig(config, "roland", "secret", "roland@jolokia.org");
} finally {
System.clearProperty("docker.username");
System.clearProperty("docker.password");
System.clearProperty("docker.email");
System.clearProperty("registry.username");
System.clearProperty("registry.password");
System.clearProperty("registry.email");
}
}
use of io.fabric8.maven.docker.access.AuthConfig in project docker-maven-plugin by fabric8io.
the class AuthConfigFactoryTest method incompleteAwsCredentialsAreIgnored.
@Test
public void incompleteAwsCredentialsAreIgnored() throws MojoExecutionException {
givenAwsSdkIsDisabled();
environmentVariables.set("AWS_ACCESS_KEY_ID", randomUUID().toString());
AuthConfig authConfig = factory.createAuthConfig(false, true, null, settings, "user", ECR_NAME);
assertNull(authConfig);
}
use of io.fabric8.maven.docker.access.AuthConfig in project docker-maven-plugin by fabric8io.
the class AuthConfigFactoryTest method testFromPluginConfiguration.
@Test
public void testFromPluginConfiguration() throws MojoExecutionException {
Map pluginConfig = new HashMap();
pluginConfig.put("username", "roland");
pluginConfig.put("password", "secret");
pluginConfig.put("email", "roland@jolokia.org");
AuthConfig config = factory.createAuthConfig(isPush, false, pluginConfig, settings, null, null);
verifyAuthConfig(config, "roland", "secret", "roland@jolokia.org");
}
Aggregations