use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment 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))));
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment in project che-server by eclipse-che.
the class ProxySettingsProvisionerTest method shouldApplyProxySettingsToInitContainers.
@Test
public void shouldApplyProxySettingsToInitContainers() throws Exception {
Map<String, Pod> pods = new HashMap<>();
Pod pod1 = buildPod("pod1", buildContainers(3));
pod1.getSpec().setInitContainers(Arrays.asList(buildContainers(2)));
pods.put("pod1", pod1);
KubernetesEnvironment k8sEnv = KubernetesEnvironment.builder().setPods(pods).build();
provisioner.provision(k8sEnv, runtimeId);
assertTrue(k8sEnv.getPodsData().values().stream().flatMap(pod -> Stream.concat(pod.getSpec().getContainers().stream(), pod.getSpec().getInitContainers().stream())).allMatch(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 che-server by eclipse-che.
the class IngressServerExposerTest method shouldReplaceServerNamePlaceholders.
@Test
public void shouldReplaceServerNamePlaceholders() {
// given
Map<String, String> annotations = new HashMap<>();
annotations.put("ssl", "true");
annotations.put("websocket-service", SERVICE_NAME_PLACEHOLDER);
IngressServerExposer<KubernetesEnvironment> exposer = new IngressServerExposer<>(serviceExposureStrategy, annotations, null, "");
KubernetesEnvironment env = KubernetesEnvironment.builder().build();
Map<String, ServerConfig> externalServers = new HashMap<>();
externalServers.put("ide", new ServerConfigImpl("6543", "http", "/", emptyMap()));
// when
exposer.expose(env, "editor", "ide", "server123", new ServicePort(), externalServers);
// then
Collection<Ingress> ingresses = env.getIngresses().values();
assertEquals(ingresses.size(), 1);
Ingress ingress = ingresses.iterator().next();
assertEquals(ingress.getMetadata().getAnnotations().get("ssl"), "true");
assertEquals(ingress.getMetadata().getAnnotations().get("websocket-service"), "ide");
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment in project che-server by eclipse-che.
the class PassThroughProxyProvisionerTest method shouldConfigureProxyWithExcludes.
// PassThroughProxyProvisioner shares much of the codebase with the JwtProxyProvisioner. We only
// test the different behavior here, while the majority of the tests are present in the
// JwtProxyProvisionerTest
@Test
public void shouldConfigureProxyWithExcludes() throws Exception {
// given
KubernetesEnvironment k8sEnv = KubernetesEnvironment.builder().build();
JwtProxyConfigBuilderFactory configBuilderFactory = mock(JwtProxyConfigBuilderFactory.class);
JwtProxyConfigBuilder configBuilder = mock(JwtProxyConfigBuilder.class);
when(configBuilderFactory.create(any())).thenReturn(configBuilder);
ServiceExposureStrategyProvider exposureStrategyProvider = mock(ServiceExposureStrategyProvider.class);
when(exposureStrategyProvider.get()).thenReturn(mock(ExternalServiceExposureStrategy.class));
when(exposureStrategyProvider.getMultiHostStrategy()).thenReturn(mock(ExternalServiceExposureStrategy.class));
PassThroughProxyProvisioner passThroughProxyProvisioner = new PassThroughProxyProvisioner(configBuilderFactory, exposureStrategyProvider, new CookiePathStrategy(MULTI_HOST_STRATEGY), new MultiHostCookiePathStrategy(), "eclipse/che-jwtproxy", "10m", "128mb", "0.02", "0.5", "Always", runtimeId);
Map<String, String> attrs = new HashMap<>();
ServerConfig.setCookiesAuthEnabled(attrs, true);
ServerConfig.setSecure(attrs, true);
ServerConfigImpl server1 = new ServerConfigImpl("4401/tcp", "http", "/", attrs);
ServicePort port = new ServicePort();
port.setTargetPort(new IntOrString(8080));
// when
passThroughProxyProvisioner.expose(k8sEnv, podWithName(), "machine", "terminal", port, "TCP", false, ImmutableMap.of("server1", server1));
// then
verify(configBuilder).addVerifierProxy(eq(4400), eq("http://terminal:8080"), eq(singleton("/")), eq(false), eq("/"), isNull());
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment in project che-server by eclipse-che.
the class PreviewUrlExposerTest method shouldDoNothingWhenNoCommandWithPreviewUrlDefined.
@Test
public void shouldDoNothingWhenNoCommandWithPreviewUrlDefined() throws InternalInfrastructureException {
CommandImpl command = new CommandImpl("a", "a", "a");
KubernetesEnvironment env = KubernetesEnvironment.builder().setCommands(singletonList(new CommandImpl(command))).build();
previewUrlExposer.expose(env);
assertEquals(env.getCommands().get(0), command);
assertTrue(env.getServices().isEmpty());
assertTrue(env.getIngresses().isEmpty());
}
Aggregations