Search in sources :

Example 1 with SystemMock

use of org.eclipse.jkube.kit.common.SystemMock 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");
}
Also used : HashMap(java.util.HashMap) SystemMock(org.eclipse.jkube.kit.common.SystemMock) JsonObject(com.google.gson.JsonObject) MockUp(mockit.MockUp) AuthConfig(org.eclipse.jkube.kit.build.api.auth.AuthConfig) Test(org.junit.Test)

Example 2 with SystemMock

use of org.eclipse.jkube.kit.common.SystemMock in project jkube by eclipse.

the class AuthConfigFactoryTest method testGetStandardAuthConfigFromProperties.

@Test
public void testGetStandardAuthConfigFromProperties(@Mocked KitLogger logger) throws IOException {
    // Given
    new SystemMock().put("jkube.docker.username", "testuser").put("jkube.docker.password", "testpass");
    // When
    AuthConfigFactory authConfigFactory = new AuthConfigFactory(logger);
    AuthConfig authConfig = authConfigFactory.createAuthConfig(true, true, Collections.emptyMap(), Collections.emptyList(), "testuser", "testregistry.io", s -> s);
    // Then
    assertAuthConfig(authConfig, "testuser", "testpass");
}
Also used : SystemMock(org.eclipse.jkube.kit.common.SystemMock) AwsSdkAuthConfigFactory(org.eclipse.jkube.kit.build.service.docker.auth.ecr.AwsSdkAuthConfigFactory) AuthConfig(org.eclipse.jkube.kit.build.api.auth.AuthConfig) Test(org.junit.Test)

Example 3 with SystemMock

use of org.eclipse.jkube.kit.common.SystemMock in project jkube by eclipse.

the class AuthConfigFactoryTest method testGetAuthConfigFromSystemProperties.

@Test
public void testGetAuthConfigFromSystemProperties() throws IOException {
    // Given
    new SystemMock().put("jkube.docker.username", "testuser").put("jkube.docker.password", "testpass");
    // When
    AuthConfig authConfig = AuthConfigFactory.getAuthConfigFromSystemProperties(AuthConfigFactory.LookupMode.DEFAULT, s -> s);
    // Then
    assertAuthConfig(authConfig, "testuser", "testpass");
}
Also used : SystemMock(org.eclipse.jkube.kit.common.SystemMock) AuthConfig(org.eclipse.jkube.kit.build.api.auth.AuthConfig) Test(org.junit.Test)

Example 4 with SystemMock

use of org.eclipse.jkube.kit.common.SystemMock in project jkube by eclipse.

the class ThorntailV2HealthCheckEnricherTest method createWithThorntailSpecificPropertiesInKubernetes.

@Test
public void createWithThorntailSpecificPropertiesInKubernetes() {
    // Given
    new SystemMock().put("thorntail.http.port", "1337");
    final ThorntailV2HealthCheckEnricher thorntailV2HealthCheckEnricher = new ThorntailV2HealthCheckEnricher(context);
    // When
    new ThorntailV2HealthCheckEnricher(context).create(PlatformMode.kubernetes, klb);
    // Then
    assertThat(klb.build().getItems()).hasSize(1).extracting("spec", DeploymentSpec.class).extracting("template", PodTemplateSpec.class).extracting("spec", PodSpec.class).flatExtracting(PodSpec::getContainers).extracting("livenessProbe.initialDelaySeconds", "livenessProbe.httpGet.scheme", "livenessProbe.httpGet.path", "readinessProbe.initialDelaySeconds", "readinessProbe.httpGet.scheme", "readinessProbe.httpGet.path", "readinessProbe.httpGet.port.intVal").containsExactly(tuple(180, "HTTP", "/health", 10, "HTTP", "/health", 1337));
}
Also used : DeploymentSpec(io.fabric8.kubernetes.api.model.apps.DeploymentSpec) PodSpec(io.fabric8.kubernetes.api.model.PodSpec) SystemMock(org.eclipse.jkube.kit.common.SystemMock) Test(org.junit.Test)

Example 5 with SystemMock

use of org.eclipse.jkube.kit.common.SystemMock in project jkube by eclipse.

the class EnvUtilTest method testIsWindows.

@Test
public void testIsWindows() {
    // Given
    new SystemMock().put("os.name", "windows");
    // When
    boolean result = EnvUtil.isWindows();
    // Then
    assertThat(result).isTrue();
}
Also used : SystemMock(org.eclipse.jkube.kit.common.SystemMock) Test(org.junit.Test)

Aggregations

SystemMock (org.eclipse.jkube.kit.common.SystemMock)7 Test (org.junit.Test)7 AuthConfig (org.eclipse.jkube.kit.build.api.auth.AuthConfig)3 JsonObject (com.google.gson.JsonObject)1 PodSpec (io.fabric8.kubernetes.api.model.PodSpec)1 DeploymentSpec (io.fabric8.kubernetes.api.model.apps.DeploymentSpec)1 HashMap (java.util.HashMap)1 MockUp (mockit.MockUp)1 AwsSdkAuthConfigFactory (org.eclipse.jkube.kit.build.service.docker.auth.ecr.AwsSdkAuthConfigFactory)1 JavaProject (org.eclipse.jkube.kit.common.JavaProject)1