use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project devspaces-images by redhat-developer.
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 devspaces-images by redhat-developer.
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 devspaces-images by redhat-developer.
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 devspaces-images by redhat-developer.
the class JwtProxySecureServerExposerTest method shouldExposeSecureServersWithNewJwtProxyServicePort.
@Test
public void shouldExposeSecureServersWithNewJwtProxyServicePort() throws Exception {
// given
ServicePort machineServicePort = new ServicePort();
machineServicePort.setTargetPort(new IntOrString(8080));
machineServicePort.setProtocol("TCP");
Map<String, ServerConfig> servers = ImmutableMap.of("server1", new ServerConfigImpl("8080/tcp", "http", "/api", ImmutableMap.of("secure", "true")), "server2", new ServerConfigImpl("8080/tcp", "ws", "/connect", ImmutableMap.of("secure", "true")));
ServicePort jwtProxyServicePort = new ServicePort();
doReturn(jwtProxyServicePort).when(jwtProxyProvisioner).expose(any(), any(), anyString(), anyString(), any(), anyString(), anyBoolean(), any());
when(jwtProxyProvisioner.getServiceName()).thenReturn(JWT_PROXY_SERVICE_NAME);
when(externalServerExposer.getStrategyConformingServers(eq(servers))).thenReturn(servers);
// when
secureServerExposer.expose(k8sEnv, null, MACHINE_NAME, MACHINE_SERVICE_NAME, null, machineServicePort, servers);
// then
verify(jwtProxyProvisioner).expose(eq(k8sEnv), any(), anyString(), eq(MACHINE_SERVICE_NAME), eq(machineServicePort), eq("TCP"), eq(false), any());
verify(externalServerExposer).expose(eq(k8sEnv), eq(MACHINE_NAME), eq(JWT_PROXY_SERVICE_NAME), isNull(), eq(jwtProxyServicePort), eq(servers));
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project devspaces-images by redhat-developer.
the class JwtProxySecureServerExposerTest method shouldUseMultiHostStrategyForSubdomainRequiringServers.
@Test
public void shouldUseMultiHostStrategyForSubdomainRequiringServers() throws Exception {
// given
ServicePort machineServicePort = new ServicePort();
machineServicePort.setTargetPort(new IntOrString(8080));
machineServicePort.setProtocol("TCP");
Map<String, ServerConfig> servers = ImmutableMap.of("server1", new ServerConfigImpl("8080/tcp", "http", "/api", ImmutableMap.of("secure", "true")), "server2", new ServerConfigImpl("8080/tcp", "ws", "/connect", ImmutableMap.of("secure", "true")));
Map<String, ServerConfig> conformingServers = Collections.singletonMap("server1", servers.get("server1"));
Map<String, ServerConfig> subdomainServers = Collections.singletonMap("server2", servers.get("server2"));
ServicePort jwtProxyServicePort = new ServicePort();
doReturn(jwtProxyServicePort).when(jwtProxyProvisioner).expose(any(), any(), anyString(), anyString(), any(), anyString(), anyBoolean(), any());
when(jwtProxyProvisioner.getServiceName()).thenReturn(JWT_PROXY_SERVICE_NAME);
when(externalServerExposer.getStrategyConformingServers(eq(servers))).thenReturn(conformingServers);
when(externalServerExposer.getServersRequiringSubdomain(eq(servers))).thenReturn(subdomainServers);
// when
secureServerExposer.expose(k8sEnv, null, MACHINE_NAME, MACHINE_SERVICE_NAME, null, machineServicePort, servers);
// then
verify(jwtProxyProvisioner).expose(eq(k8sEnv), any(), anyString(), eq(MACHINE_SERVICE_NAME), eq(machineServicePort), eq("TCP"), eq(false), any());
verify(jwtProxyProvisioner).expose(eq(k8sEnv), any(), anyString(), eq(MACHINE_SERVICE_NAME), eq(machineServicePort), eq("TCP"), eq(true), any());
verify(externalServerExposer).expose(eq(k8sEnv), eq(MACHINE_NAME), eq(JWT_PROXY_SERVICE_NAME), isNull(), eq(jwtProxyServicePort), eq(conformingServers));
verify(externalServerExposer).expose(eq(k8sEnv), eq(MACHINE_NAME), eq(JWT_PROXY_SERVICE_NAME), isNull(), eq(jwtProxyServicePort), eq(subdomainServers));
}
Aggregations