use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment 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))));
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment in project devspaces-images by redhat-developer.
the class GatewayTlsProvisionerTest method provisionTlsForGatewayRouteConfigmaps.
@Test(dataProvider = "tlsProvisionData")
public void provisionTlsForGatewayRouteConfigmaps(ServerConfigImpl server, boolean tlsEnabled, String expectedProtocol) throws Exception {
// given
Map<String, String> composedAnnotations = new HashMap<>(annotations);
composedAnnotations.putAll(Annotations.newSerializer().server("server", server).machineName(machine).annotations());
ConfigMap routeConfigMap = new ConfigMapBuilder().withNewMetadata().withName("route").withAnnotations(composedAnnotations).endMetadata().build();
GatewayTlsProvisioner<KubernetesEnvironment> gatewayTlsProvisioner = new GatewayTlsProvisioner<>(tlsEnabled, gatewayConfigmapLabels, tlsProvisionerProvider);
lenient().when(k8sEnv.getConfigMaps()).thenReturn(singletonMap("route", routeConfigMap));
// when
gatewayTlsProvisioner.provision(k8sEnv, runtimeIdentity);
// then
Map<String, ServerConfigImpl> servers = Annotations.newDeserializer(routeConfigMap.getMetadata().getAnnotations()).servers();
assertEquals(servers.get("server").getProtocol(), expectedProtocol);
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment in project devspaces-images by redhat-developer.
the class GatewayTlsProvisionerTest method throwExceptionWhenMultipleServersInGatewayRouteConfigAnnotations.
@Test(expectedExceptions = InfrastructureException.class)
public void throwExceptionWhenMultipleServersInGatewayRouteConfigAnnotations() throws InfrastructureException {
// given
Map<String, String> composedAnnotations = new HashMap<>(annotations);
composedAnnotations.putAll(Annotations.newSerializer().server("server1", httpServer).server("server2", wsServer).machineName(machine).annotations());
ConfigMap routeConfigMap = new ConfigMapBuilder().withNewMetadata().withName("route").withAnnotations(composedAnnotations).endMetadata().build();
when(k8sEnv.getConfigMaps()).thenReturn(singletonMap("route", routeConfigMap));
GatewayTlsProvisioner<KubernetesEnvironment> gatewayTlsProvisioner = new GatewayTlsProvisioner<>(true, gatewayConfigmapLabels, tlsProvisionerProvider);
// when
gatewayTlsProvisioner.provision(k8sEnv, runtimeIdentity);
// then exception
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment in project devspaces-images by redhat-developer.
the class PreviewUrlExposerTest method shouldDoNothingWhenNoCommandsDefined.
@Test
public void shouldDoNothingWhenNoCommandsDefined() throws InternalInfrastructureException {
KubernetesEnvironment env = KubernetesEnvironment.builder().build();
previewUrlExposer.expose(env);
assertTrue(env.getCommands().isEmpty());
assertTrue(env.getServices().isEmpty());
assertTrue(env.getIngresses().isEmpty());
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment in project devspaces-images by redhat-developer.
the class GatewayServerExposerTest method testExposeServiceWithGatewayConfigmap.
@Test
public void testExposeServiceWithGatewayConfigmap() {
// given
KubernetesEnvironment k8sEnv = KubernetesEnvironment.builder().build();
// when
serverExposer.expose(k8sEnv, machineName, serviceName, serverId, servicePort, servers);
// then
Map<String, ConfigMap> configMaps = k8sEnv.getConfigMaps();
assertTrue(configMaps.containsKey(serviceName + "-" + serverId));
ConfigMap serverConfigMap = configMaps.get("service-server");
// data should be empty at this point
assertTrue(serverConfigMap.getData() == null || serverConfigMap.getData().isEmpty());
assertEquals(serverConfigMap.getMetadata().getLabels(), GATEWAY_CONFIGMAP_LABELS);
Map<String, String> annotations = serverConfigMap.getMetadata().getAnnotations();
Annotations.Deserializer deserializer = Annotations.newDeserializer(annotations);
assertEquals(deserializer.machineName(), machineName);
Map<String, ServerConfigImpl> exposedServers = deserializer.servers();
assertTrue(exposedServers.containsKey("serverOne"));
ServerConfig s1 = exposedServers.get("serverOne");
assertEquals(s1.getAttributes().get(s1attrs.keySet().iterator().next()), s1attrs.values().iterator().next());
assertEquals(s1.getAttributes().get(ServerConfigImpl.SERVICE_NAME_ATTRIBUTE), "service");
assertEquals(s1.getAttributes().get(ServerConfigImpl.SERVICE_PORT_ATTRIBUTE), "1234");
assertEquals(s1.getPort(), "1111");
assertEquals(s1.getProtocol(), "ws");
assertNull(s1.getPath());
assertEquals(s1.getEndpointOrigin(), "/service/server/");
}
Aggregations