use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project che-server by eclipse-che.
the class ExternalServerIngressBuilderTest method assertIngressSpec.
private void assertIngressSpec(String path, String host, Ingress ingress) {
assertEquals(ingress.getSpec().getRules().get(0).getHost(), host);
HTTPIngressPath httpIngressPath = ingress.getSpec().getRules().get(0).getHttp().getPaths().get(0);
assertEquals(httpIngressPath.getPath(), path);
assertEquals(httpIngressPath.getPathType(), INGRESS_PATH_TYPE);
assertEquals(httpIngressPath.getBackend().getService().getName(), SERVICE_NAME);
assertEquals(httpIngressPath.getBackend().getService().getPort().getName(), SERVICE_PORT_NAME);
assertEquals(ingress.getMetadata().getName(), NAME);
assertTrue(ingress.getMetadata().getAnnotations().containsKey("annotation-key"));
assertEquals(ingress.getMetadata().getAnnotations().get("annotation-key"), "annotation-value");
Annotations.Deserializer ingressAnnotations = Annotations.newDeserializer(ingress.getMetadata().getAnnotations());
Map<String, ServerConfigImpl> servers = ingressAnnotations.servers();
ServerConfig serverConfig = servers.get("http-server");
assertEquals(serverConfig, SERVER_CONFIG);
assertEquals(ingressAnnotations.machineName(), MACHINE_NAME);
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project che-server by eclipse-che.
the class JwtProxyProvisionerTest method shouldThrowAnExceptionIfServersHaveDifferentValueForCookiesAuthEnabled.
@Test(expectedExceptions = InfrastructureException.class, expectedExceptionsMessageRegExp = "Secure servers which expose the same port should have " + "the same `cookiesAuthEnabled` value\\.")
public void shouldThrowAnExceptionIfServersHaveDifferentValueForCookiesAuthEnabled() throws Exception {
// given
ServerConfigImpl server1 = new ServerConfigImpl("4401/tcp", "ws", "/", ImmutableMap.of(SECURE_SERVER_COOKIES_AUTH_ENABLED_ATTRIBUTE, "true"));
ServerConfigImpl server2 = new ServerConfigImpl("4401/tcp", "http", "/", ImmutableMap.of(SECURE_SERVER_COOKIES_AUTH_ENABLED_ATTRIBUTE, "false"));
ServerConfigImpl server3 = new ServerConfigImpl("4401/tcp", "ws", "/", emptyMap());
ServicePort port = new ServicePort();
port.setTargetPort(new IntOrString(4401));
// when
jwtProxyProvisioner.expose(k8sEnv, podWithName(), "machine", "terminal", port, "TCP", false, ImmutableMap.of("server1", server1, "server2", server2, "server3", server3));
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project che-server by eclipse-che.
the class JwtProxyProvisionerTest method multiHostStrategiesUsedForServerRequiringSubdomain.
@Test
public void multiHostStrategiesUsedForServerRequiringSubdomain() throws Exception {
// given
JwtProxyConfigBuilder configBuilder = mock(JwtProxyConfigBuilder.class);
when(configBuilderFactory.create(any())).thenReturn(configBuilder);
jwtProxyProvisioner = new JwtProxyProvisioner(signatureKeyManager, configBuilderFactory, serviceExposureStrategyProvider, cookiePathStrategy, multiHostCookiePathStrategy, "eclipse/che-jwtproxy", "10m", "128mb", "0.02", "0.5", "Always", runtimeId);
ServerConfigImpl server1 = new ServerConfigImpl("4401/tcp", "http", "/", emptyMap());
ServicePort port = new ServicePort();
port.setTargetPort(new IntOrString(4401));
// when
jwtProxyProvisioner.expose(k8sEnv, podWithName(), "machine", null, port, "TCP", true, ImmutableMap.of("server1", server1));
// then
verify(configBuilder).addVerifierProxy(eq(4400), eq("http://127.0.0.1:4401"), eq(emptySet()), eq(false), eq("/"), isNull());
verify(externalServiceExposureStrategy, never()).getExternalPath(any(), any());
verify(cookiePathStrategy, never()).get(any(), any());
verify(multiHostExternalServiceExposureStrategy).getExternalPath(any(), any());
verify(multiHostCookiePathStrategy).get(any(), any());
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project che-server by eclipse-che.
the class JwtProxyProvisionerTest method shouldProvisionJwtProxyRelatedObjectsIntoKubernetesEnvironment.
@Test
public void shouldProvisionJwtProxyRelatedObjectsIntoKubernetesEnvironment() throws Exception {
// given
ServerConfigImpl secureServer = new ServerConfigImpl("4401/tcp", "ws", "/", emptyMap());
ServicePort port = new ServicePort();
port.setTargetPort(new IntOrString(4401));
// when
jwtProxyProvisioner.expose(k8sEnv, podWithName(), "machine", "terminal", port, "TCP", false, ImmutableMap.of("server", secureServer));
// then
InternalMachineConfig jwtProxyMachine = k8sEnv.getMachines().get(JwtProxyProvisioner.JWT_PROXY_MACHINE_NAME);
assertNotNull(jwtProxyMachine);
ConfigMap configMap = k8sEnv.getConfigMaps().get(jwtProxyProvisioner.getConfigMapName());
assertNotNull(configMap);
assertEquals(configMap.getData().get(JWT_PROXY_PUBLIC_KEY_FILE), PUBLIC_KEY_HEADER + Base64.getEncoder().encodeToString("publickey".getBytes()) + PUBLIC_KEY_FOOTER);
assertNotNull(configMap.getData().get(JWT_PROXY_CONFIG_FILE));
Pod jwtProxyPod = k8sEnv.getInjectablePodsCopy().getOrDefault("machine", emptyMap()).get("che-jwtproxy");
assertNotNull(jwtProxyPod);
assertEquals(1, jwtProxyPod.getSpec().getContainers().size());
Container jwtProxyContainer = jwtProxyPod.getSpec().getContainers().get(0);
assertEquals(jwtProxyContainer.getArgs().size(), 2);
assertEquals(jwtProxyContainer.getArgs().get(0), "-config");
assertEquals(jwtProxyContainer.getArgs().get(1), JWT_PROXY_CONFIG_FOLDER + "/" + JWT_PROXY_CONFIG_FILE);
assertEquals(jwtProxyContainer.getEnv().size(), 1);
EnvVar xdgHome = jwtProxyContainer.getEnv().get(0);
assertEquals(xdgHome.getName(), "XDG_CONFIG_HOME");
assertEquals(xdgHome.getValue(), JWT_PROXY_CONFIG_FOLDER);
Service jwtProxyService = k8sEnv.getServices().get(jwtProxyProvisioner.getServiceName());
assertNotNull(jwtProxyService);
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project che-server by eclipse-che.
the class JwtProxyProvisionerTest method shouldBindToLocalhostWhenNoServiceForServerExists.
@Test
public void shouldBindToLocalhostWhenNoServiceForServerExists() throws Exception {
// given
JwtProxyConfigBuilder configBuilder = mock(JwtProxyConfigBuilder.class);
when(configBuilderFactory.create(any())).thenReturn(configBuilder);
jwtProxyProvisioner = new JwtProxyProvisioner(signatureKeyManager, configBuilderFactory, serviceExposureStrategyProvider, cookiePathStrategy, multiHostCookiePathStrategy, "eclipse/che-jwtproxy", "10m", "128mb", "0.02", "0.5", "Always", runtimeId);
ServerConfigImpl server1 = new ServerConfigImpl("4401/tcp", "http", "/", emptyMap());
ServicePort port = new ServicePort();
port.setTargetPort(new IntOrString(4401));
// when
jwtProxyProvisioner.expose(k8sEnv, podWithName(), "machine", null, port, "TCP", false, ImmutableMap.of("server1", server1));
// then
verify(configBuilder).addVerifierProxy(eq(4400), eq("http://127.0.0.1:4401"), eq(emptySet()), eq(false), eq("/"), isNull());
}
Aggregations