use of org.eclipse.jkube.kit.build.api.auth.AuthConfig in project jkube by eclipse.
the class AuthConfigFactoryTest method testGetAuthConfigFromOpenShiftConfig.
@Test
public void testGetAuthConfigFromOpenShiftConfig() {
// Given
new SystemMock().put("jkube.docker.useOpenShiftAuth", "true");
Map<String, Object> authConfigMap = new HashMap<>();
new MockUp<KubernetesConfigAuthUtil>() {
@Mock
AuthConfig readKubeConfigAuth() {
return AuthConfig.builder().username("test").password("sometoken").build();
}
};
// When
AuthConfig authConfig = AuthConfigFactory.getAuthConfigFromOpenShiftConfig(AuthConfigFactory.LookupMode.DEFAULT, authConfigMap);
// Then
assertAuthConfig(authConfig, "test", "sometoken");
}
use of org.eclipse.jkube.kit.build.api.auth.AuthConfig in project jkube by eclipse.
the class AuthConfigFactoryTest method testGetAuthConfigFromDockerConfig.
@Test
public void testGetAuthConfigFromDockerConfig(@Mocked KitLogger logger) throws IOException {
// Given
new MockUp<DockerFileUtil>() {
@Mock
JsonObject readDockerConfig() {
JsonObject dockerConfig = new JsonObject();
JsonObject auths = new JsonObject();
JsonObject creds = new JsonObject();
creds.addProperty("auth", "dGVzdHVzZXI6dGVzdHBhc3M=");
auths.add("https://index.docker.io/v1/", creds);
dockerConfig.add("auths", auths);
return dockerConfig;
}
};
// When
AuthConfig authConfig = AuthConfigFactory.getAuthConfigFromDockerConfig("https://index.docker.io/v1/", logger);
// Then
assertAuthConfig(authConfig, "testuser", "testpass");
}
use of org.eclipse.jkube.kit.build.api.auth.AuthConfig in project jkube by eclipse.
the class AuthConfigFactoryTest method awsStaticCredentialsArePickedUpFromEnvironment.
@Test
public void awsStaticCredentialsArePickedUpFromEnvironment() throws IOException {
givenAwsSdkIsDisabled();
String accessKeyId = randomUUID().toString();
String secretAccessKey = randomUUID().toString();
new Expectations() {
{
awsSdkHelper.getAwsAccessKeyIdEnvVar();
result = accessKeyId;
awsSdkHelper.getAwsSecretAccessKeyEnvVar();
result = secretAccessKey;
}
};
AuthConfig authConfig = factory.createAuthConfig(false, true, null, Collections.emptyList(), "user", ECR_NAME, s -> s);
verifyAuthConfig(authConfig, accessKeyId, secretAccessKey, null, null);
}
use of org.eclipse.jkube.kit.build.api.auth.AuthConfig in project jkube by eclipse.
the class AuthConfigFactoryTest method testGetStandardAuthConfigFromMavenSettings.
@Test
public void testGetStandardAuthConfigFromMavenSettings(@Mocked KitLogger logger) throws IOException {
// Given
List<RegistryServerConfiguration> settings = new ArrayList<>();
settings.add(RegistryServerConfiguration.builder().id("testregistry.io").username("testuser").password("testpass").build());
// When
AuthConfigFactory authConfigFactory = new AuthConfigFactory(logger);
AuthConfig authConfig = authConfigFactory.createAuthConfig(true, true, Collections.emptyMap(), settings, "testuser", "testregistry.io", s -> s);
// Then
assertAuthConfig(authConfig, "testuser", "testpass");
}
use of org.eclipse.jkube.kit.build.api.auth.AuthConfig in project jkube by eclipse.
the class AuthConfigFactoryTest method getAuthConfigViaAwsSdk.
@Test
public void getAuthConfigViaAwsSdk() throws IOException {
new Expectations() {
{
awsSdkHelper.isDefaultAWSCredentialsProviderChainPresentInClassPath();
result = true;
}
};
String accessKeyId = randomUUID().toString();
String secretAccessKey = randomUUID().toString();
new MockedAwsSdkAuthConfigFactory(accessKeyId, secretAccessKey);
AuthConfig authConfig = factory.createAuthConfig(false, true, null, Collections.emptyList(), "user", ECR_NAME, s -> s);
verifyAuthConfig(authConfig, accessKeyId, secretAccessKey, null, null);
}
Aggregations