Search in sources :

Example 1 with JWT_PROXY_POD_NAME

use of org.eclipse.che.workspace.infrastructure.kubernetes.server.secure.jwtproxy.JwtProxyProvisioner.JWT_PROXY_POD_NAME in project che-server by eclipse-che.

the class ProxySettingsProvisionerTest method shouldNotApplyProxySettingsToJWTProxyContainer.

@Test
public void shouldNotApplyProxySettingsToJWTProxyContainer() throws Exception {
    Map<String, Pod> pods = new HashMap<>();
    pods.put(JWT_PROXY_POD_NAME, buildPod(JWT_PROXY_POD_NAME, buildContainers(2)));
    KubernetesEnvironment k8sEnv = KubernetesEnvironment.builder().setPods(pods).build();
    provisioner.provision(k8sEnv, runtimeId);
    assertTrue(k8sEnv.getPodsData().values().stream().filter(pod -> pod.getMetadata().getName().equals(JWT_PROXY_POD_NAME)).flatMap(pod -> pod.getSpec().getContainers().stream()).noneMatch(container -> container.getEnv().contains(new EnvVar(HTTP_PROXY, HTTP_PROXY_VALUE, null)) || container.getEnv().contains(new EnvVar(HTTPS_PROXY, HTTPS_PROXY_VALUE, null)) || container.getEnv().contains(new EnvVar(NO_PROXY, NO_PROXY_VALUE, null))));
}
Also used : HTTP_PROXY(org.eclipse.che.workspace.infrastructure.kubernetes.provision.ProxySettingsProvisioner.HTTP_PROXY) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) Arrays(java.util.Arrays) NameGenerator.generate(org.eclipse.che.commons.lang.NameGenerator.generate) Listeners(org.testng.annotations.Listeners) Container(io.fabric8.kubernetes.api.model.Container) Mock(org.mockito.Mock) KubernetesEnvironment(org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment) HashMap(java.util.HashMap) Test(org.testng.annotations.Test) Mockito.lenient(org.mockito.Mockito.lenient) ArrayList(java.util.ArrayList) HTTPS_PROXY(org.eclipse.che.workspace.infrastructure.kubernetes.provision.ProxySettingsProvisioner.HTTPS_PROXY) NO_PROXY(org.eclipse.che.workspace.infrastructure.kubernetes.provision.ProxySettingsProvisioner.NO_PROXY) JWT_PROXY_POD_NAME(org.eclipse.che.workspace.infrastructure.kubernetes.server.secure.jwtproxy.JwtProxyProvisioner.JWT_PROXY_POD_NAME) PodBuilder(io.fabric8.kubernetes.api.model.PodBuilder) Map(java.util.Map) ContainerBuilder(io.fabric8.kubernetes.api.model.ContainerBuilder) MockitoTestNGListener(org.mockito.testng.MockitoTestNGListener) BeforeMethod(org.testng.annotations.BeforeMethod) Pod(io.fabric8.kubernetes.api.model.Pod) List(java.util.List) Stream(java.util.stream.Stream) RuntimeIdentity(org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity) Assert.assertTrue(org.testng.Assert.assertTrue) Pod(io.fabric8.kubernetes.api.model.Pod) HashMap(java.util.HashMap) KubernetesEnvironment(org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) Test(org.testng.annotations.Test)

Example 2 with JWT_PROXY_POD_NAME

use of org.eclipse.che.workspace.infrastructure.kubernetes.server.secure.jwtproxy.JwtProxyProvisioner.JWT_PROXY_POD_NAME in project devspaces-images by redhat-developer.

the class ProxySettingsProvisionerTest method shouldNotApplyProxySettingsToJWTProxyContainer.

@Test
public void shouldNotApplyProxySettingsToJWTProxyContainer() throws Exception {
    Map<String, Pod> pods = new HashMap<>();
    pods.put(JWT_PROXY_POD_NAME, buildPod(JWT_PROXY_POD_NAME, buildContainers(2)));
    KubernetesEnvironment k8sEnv = KubernetesEnvironment.builder().setPods(pods).build();
    provisioner.provision(k8sEnv, runtimeId);
    assertTrue(k8sEnv.getPodsData().values().stream().filter(pod -> pod.getMetadata().getName().equals(JWT_PROXY_POD_NAME)).flatMap(pod -> pod.getSpec().getContainers().stream()).noneMatch(container -> container.getEnv().contains(new EnvVar(HTTP_PROXY, HTTP_PROXY_VALUE, null)) || container.getEnv().contains(new EnvVar(HTTPS_PROXY, HTTPS_PROXY_VALUE, null)) || container.getEnv().contains(new EnvVar(NO_PROXY, NO_PROXY_VALUE, null))));
}
Also used : HTTP_PROXY(org.eclipse.che.workspace.infrastructure.kubernetes.provision.ProxySettingsProvisioner.HTTP_PROXY) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) Arrays(java.util.Arrays) NameGenerator.generate(org.eclipse.che.commons.lang.NameGenerator.generate) Listeners(org.testng.annotations.Listeners) Container(io.fabric8.kubernetes.api.model.Container) Mock(org.mockito.Mock) KubernetesEnvironment(org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment) HashMap(java.util.HashMap) Test(org.testng.annotations.Test) Mockito.lenient(org.mockito.Mockito.lenient) ArrayList(java.util.ArrayList) HTTPS_PROXY(org.eclipse.che.workspace.infrastructure.kubernetes.provision.ProxySettingsProvisioner.HTTPS_PROXY) NO_PROXY(org.eclipse.che.workspace.infrastructure.kubernetes.provision.ProxySettingsProvisioner.NO_PROXY) JWT_PROXY_POD_NAME(org.eclipse.che.workspace.infrastructure.kubernetes.server.secure.jwtproxy.JwtProxyProvisioner.JWT_PROXY_POD_NAME) PodBuilder(io.fabric8.kubernetes.api.model.PodBuilder) Map(java.util.Map) ContainerBuilder(io.fabric8.kubernetes.api.model.ContainerBuilder) MockitoTestNGListener(org.mockito.testng.MockitoTestNGListener) BeforeMethod(org.testng.annotations.BeforeMethod) Pod(io.fabric8.kubernetes.api.model.Pod) List(java.util.List) Stream(java.util.stream.Stream) RuntimeIdentity(org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity) Assert.assertTrue(org.testng.Assert.assertTrue) Pod(io.fabric8.kubernetes.api.model.Pod) HashMap(java.util.HashMap) KubernetesEnvironment(org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) Test(org.testng.annotations.Test)

Aggregations

Container (io.fabric8.kubernetes.api.model.Container)2 ContainerBuilder (io.fabric8.kubernetes.api.model.ContainerBuilder)2 EnvVar (io.fabric8.kubernetes.api.model.EnvVar)2 Pod (io.fabric8.kubernetes.api.model.Pod)2 PodBuilder (io.fabric8.kubernetes.api.model.PodBuilder)2 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Stream (java.util.stream.Stream)2 RuntimeIdentity (org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity)2 NameGenerator.generate (org.eclipse.che.commons.lang.NameGenerator.generate)2 KubernetesEnvironment (org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment)2 HTTPS_PROXY (org.eclipse.che.workspace.infrastructure.kubernetes.provision.ProxySettingsProvisioner.HTTPS_PROXY)2 HTTP_PROXY (org.eclipse.che.workspace.infrastructure.kubernetes.provision.ProxySettingsProvisioner.HTTP_PROXY)2 NO_PROXY (org.eclipse.che.workspace.infrastructure.kubernetes.provision.ProxySettingsProvisioner.NO_PROXY)2 JWT_PROXY_POD_NAME (org.eclipse.che.workspace.infrastructure.kubernetes.server.secure.jwtproxy.JwtProxyProvisioner.JWT_PROXY_POD_NAME)2 Mock (org.mockito.Mock)2 Mockito.lenient (org.mockito.Mockito.lenient)2