use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project che-server by eclipse-che.
the class ConfigMapServerResolverTest method shouldSetEndpointOrigin.
@Test
public void shouldSetEndpointOrigin() {
// given
ConfigMap serverConfigMap = new ConfigMapBuilder().withNewMetadata().addToAnnotations(Annotations.newSerializer().machineName("m1").server("svr", new ServerConfigImpl().withPort("8080").withProtocol("http").withPath("/kachny").withAttributes(ImmutableMap.of(ServerConfig.ENDPOINT_ORIGIN, "/kachny"))).annotations()).endMetadata().build();
ConfigMapServerResolver serverResolver = new ConfigMapServerResolver(emptyList(), singletonList(serverConfigMap), "che.host", nativeServerResolver);
// when
Map<String, ServerImpl> resolvedServers = serverResolver.resolve("m1");
// then
ServerImpl svr = resolvedServers.get("svr");
assertNotNull(svr);
assertEquals("/kachny", ServerConfig.getEndpointOrigin(svr.getAttributes()));
assertEquals("http://che.host/kachny/kachny/", svr.getUrl());
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project che-server by eclipse-che.
the class IngressServerResolverTest method testResolvingServersWhenThereIsMatchedIngressForMachineAndServerPathIsNull.
@Test
public void testResolvingServersWhenThereIsMatchedIngressForMachineAndServerPathIsNull() {
Ingress ingress = createIngress("matched", "machine", Pair.of("http-server", new ServerConfigImpl("3054", "http", null, ATTRIBUTES_MAP)));
ServerResolver serverResolver = new IngressServerResolver(new NoopPathTransformInverter(), emptyList(), singletonList(ingress));
Map<String, ServerImpl> resolved = serverResolver.resolve("machine");
assertEquals(resolved.size(), 1);
assertEquals(resolved.get("http-server"), new ServerImpl().withUrl("http://" + INGRESS_IP + INGRESS_RULE_PATH_PREFIX + "/").withStatus(ServerStatus.UNKNOWN).withAttributes(defaultAttributeAnd(Constants.SERVER_PORT_ATTRIBUTE, "3054", ServerConfig.ENDPOINT_ORIGIN, INGRESS_PATH_PREFIX + "/")));
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project che-server by eclipse-che.
the class JwtProxyProvisionerTest method shouldUseCookiesAuthEnabledFromServersConfigs.
@Test
public void shouldUseCookiesAuthEnabledFromServersConfigs() 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", "500m", "Always", runtimeId);
ServerConfigImpl server1 = new ServerConfigImpl("4401/tcp", "http", "/", ImmutableMap.of(SECURE_SERVER_COOKIES_AUTH_ENABLED_ATTRIBUTE, "true"));
ServerConfigImpl server2 = new ServerConfigImpl("4401/tcp", "ws", "/", ImmutableMap.of(SECURE_SERVER_COOKIES_AUTH_ENABLED_ATTRIBUTE, "true"));
ServicePort port = new ServicePort();
port.setTargetPort(new IntOrString(4401));
// when
jwtProxyProvisioner.expose(k8sEnv, podWithName(), "machine", "terminal", port, "TCP", false, ImmutableMap.of("server1", server1));
// then
verify(configBuilder).addVerifierProxy(any(), any(), any(), eq(true), any(), any());
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project che-server by eclipse-che.
the class JwtProxyProvisionerTest method shouldFalseValueAsDefaultForCookiesAuthEnabledAttribute.
@Test
public void shouldFalseValueAsDefaultForCookiesAuthEnabledAttribute() 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", "terminal", port, "TCP", false, ImmutableMap.of("server1", server1));
// then
verify(configBuilder).addVerifierProxy(eq(4400), eq("http://terminal:4401"), eq(emptySet()), eq(false), eq("/"), isNull());
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl 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());
}
Aggregations