Search in sources :

Example 26 with AuthConfig

use of org.eclipse.jkube.kit.build.api.auth.AuthConfig in project jkube by eclipse.

the class OpenShiftRegistryAuthHandlerTest method testOpenShiftConfigFromSystemPropsNegative.

@Test
public void testOpenShiftConfigFromSystemPropsNegative() throws Exception {
    try {
        System.setProperty("docker.useOpenShiftAuth", "false");
        executeWithTempHomeDir(homeDir -> {
            createOpenShiftConfig(homeDir, "openshift_simple_config.yaml");
            AuthConfig config = handler.create(RegistryAuthConfig.Kind.PUSH, "roland", null, s -> s);
            assertNull(config);
        });
    } finally {
        System.getProperties().remove("docker.useOpenShiftAuth");
    }
}
Also used : AuthConfig(org.eclipse.jkube.kit.build.api.auth.AuthConfig) RegistryAuthConfig(org.eclipse.jkube.kit.build.api.auth.RegistryAuthConfig) Test(org.junit.Test)

Example 27 with AuthConfig

use of org.eclipse.jkube.kit.build.api.auth.AuthConfig in project jkube by eclipse.

the class KubernetesConfigAuthUtilTest method readKubeConfigAuth_withMissingCurrentContext.

@Test
public void readKubeConfigAuth_withMissingCurrentContext() throws IOException {
    withKubeConfig("kube-config-missing-current-context.yaml");
    executeWithTempSystemUserHome(() -> {
        final AuthConfig result = readKubeConfigAuth();
        assertThat(result).isNull();
    });
}
Also used : AuthConfig(org.eclipse.jkube.kit.build.api.auth.AuthConfig) Test(org.junit.Test)

Example 28 with AuthConfig

use of org.eclipse.jkube.kit.build.api.auth.AuthConfig in project jkube by eclipse.

the class KubernetesConfigAuthUtilTest method readKubeConfigAuth_withEmptyFile.

@Test
public void readKubeConfigAuth_withEmptyFile() throws IOException {
    withKubeConfig("kube-config-empty.yaml");
    executeWithTempSystemUserHome(() -> {
        final AuthConfig result = readKubeConfigAuth();
        assertThat(result).isNull();
    });
}
Also used : AuthConfig(org.eclipse.jkube.kit.build.api.auth.AuthConfig) Test(org.junit.Test)

Example 29 with AuthConfig

use of org.eclipse.jkube.kit.build.api.auth.AuthConfig in project jkube by eclipse.

the class AuthConfigFactoryTest method awsTemporaryCredentialsArePickedUpFromEnvironment.

@Test
public void awsTemporaryCredentialsArePickedUpFromEnvironment() throws IOException {
    givenAwsSdkIsDisabled();
    String accessKeyId = randomUUID().toString();
    String secretAccessKey = randomUUID().toString();
    String sessionToken = randomUUID().toString();
    new Expectations() {

        {
            awsSdkHelper.getAwsAccessKeyIdEnvVar();
            result = accessKeyId;
            awsSdkHelper.getAwsSecretAccessKeyEnvVar();
            result = secretAccessKey;
            awsSdkHelper.getAwsSessionTokenEnvVar();
            result = sessionToken;
        }
    };
    AuthConfig authConfig = factory.createAuthConfig(false, true, null, Collections.emptyList(), "user", ECR_NAME, s -> s);
    verifyAuthConfig(authConfig, accessKeyId, secretAccessKey, null, sessionToken);
}
Also used : Expectations(mockit.Expectations) AuthConfig(org.eclipse.jkube.kit.build.api.auth.AuthConfig) Test(org.junit.Test)

Example 30 with AuthConfig

use of org.eclipse.jkube.kit.build.api.auth.AuthConfig in project jkube by eclipse.

the class AuthConfigFactoryTest method testGetAuthConfigFromPluginConfiguration.

@Test
public void testGetAuthConfigFromPluginConfiguration() {
    // Given
    Map<String, Object> authConfigMap = new HashMap<>();
    authConfigMap.put("username", "testuser");
    authConfigMap.put("password", "testpass");
    authConfigMap.put("email", "test@example.com");
    // When
    AuthConfig authConfig = AuthConfigFactory.getAuthConfigFromPluginConfiguration(AuthConfigFactory.LookupMode.DEFAULT, authConfigMap, s -> s);
    // Then
    assertNotNull(authConfig);
    assertAuthConfig(authConfig, "testuser", "testpass");
    assertEquals("test@example.com", authConfig.getEmail());
}
Also used : HashMap(java.util.HashMap) JsonObject(com.google.gson.JsonObject) AuthConfig(org.eclipse.jkube.kit.build.api.auth.AuthConfig) Test(org.junit.Test)

Aggregations

AuthConfig (org.eclipse.jkube.kit.build.api.auth.AuthConfig)42 Test (org.junit.Test)34 RegistryAuthConfig (org.eclipse.jkube.kit.build.api.auth.RegistryAuthConfig)10 JsonObject (com.google.gson.JsonObject)6 Expectations (mockit.Expectations)6 IOException (java.io.IOException)4 HashMap (java.util.HashMap)4 Date (java.util.Date)3 MockUp (mockit.MockUp)3 ImageName (org.eclipse.jkube.kit.config.image.ImageName)3 ArrayList (java.util.ArrayList)2 HttpPost (org.apache.http.client.methods.HttpPost)2 StringEntity (org.apache.http.entity.StringEntity)2 AuthConfigFactory (org.eclipse.jkube.kit.build.service.docker.auth.AuthConfigFactory)2 RegistryServerConfiguration (org.eclipse.jkube.kit.common.RegistryServerConfiguration)2 SystemMock (org.eclipse.jkube.kit.common.SystemMock)2 Credential (com.google.cloud.tools.jib.api.Credential)1 Gson (com.google.gson.Gson)1 JsonPrimitive (com.google.gson.JsonPrimitive)1 KubernetesList (io.fabric8.kubernetes.api.model.KubernetesList)1