use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project che-server by eclipse-che.
the class RouteServerResolverTest method testResolvingServersWhenThereIsMatchedRouteForTheSpecifiedMachine.
@Test
public void testResolvingServersWhenThereIsMatchedRouteForTheSpecifiedMachine() {
Route route = createRoute("matched", "machine", ImmutableMap.of("http-server", new ServerConfigImpl("3054", "http", "/api", ATTRIBUTES_MAP)));
RouteServerResolver serverResolver = new RouteServerResolver(emptyList(), singletonList(route));
Map<String, ServerImpl> resolved = serverResolver.resolve("machine");
assertEquals(resolved.size(), 1);
assertEquals(resolved.get("http-server"), new ServerImpl().withUrl("http://localhost/api").withStatus(UNKNOWN).withAttributes(defaultAttributeAnd(Constants.SERVER_PORT_ATTRIBUTE, "3054", ServerConfig.ENDPOINT_ORIGIN, "/")));
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project che-server by eclipse-che.
the class RouteServerResolverTest method testResolvingServersWhenThereIsMatchedRouteForMachineAndServerPathIsEmpty.
@Test
public void testResolvingServersWhenThereIsMatchedRouteForMachineAndServerPathIsEmpty() {
Route route = createRoute("matched", "machine", singletonMap("http-server", new ServerConfigImpl("3054", "http", "", ATTRIBUTES_MAP)));
RouteServerResolver serverResolver = new RouteServerResolver(emptyList(), singletonList(route));
Map<String, ServerImpl> resolved = serverResolver.resolve("machine");
assertEquals(resolved.size(), 1);
assertEquals(resolved.get("http-server"), new ServerImpl().withUrl("http://localhost").withStatus(UNKNOWN).withAttributes(defaultAttributeAnd(Constants.SERVER_PORT_ATTRIBUTE, "3054", ServerConfig.ENDPOINT_ORIGIN, "/")));
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project che-server by eclipse-che.
the class RouteServerResolverTest method shouldSetEndpointOrigin.
@Test
public void shouldSetEndpointOrigin() {
// given
Route route = new RouteBuilder().withNewMetadata().addToAnnotations(Annotations.newSerializer().machineName("m1").server("svr", new ServerConfigImpl().withPort("8080").withProtocol("http").withPath("/kachny")).annotations()).endMetadata().withNewSpec().withHost("che.host").endSpec().build();
RouteServerResolver serverResolver = new RouteServerResolver(emptyList(), singletonList(route));
// when
Map<String, ServerImpl> resolvedServers = serverResolver.resolve("m1");
// then
ServerImpl svr = resolvedServers.get("svr");
assertNotNull(svr);
assertEquals("/", ServerConfig.getEndpointOrigin(svr.getAttributes()));
assertEquals("http://che.host/kachny", svr.getUrl());
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project che-server by eclipse-che.
the class RouteTlsProvisionerTest method provisionTlsForRoutes.
@Test
public void provisionTlsForRoutes() throws Exception {
// given
RouteTlsProvisioner tlsProvisioner = new RouteTlsProvisioner(true);
ServerConfigImpl httpServer = new ServerConfigImpl("8080/tpc", "http", "/api", emptyMap());
ServerConfigImpl wsServer = new ServerConfigImpl("8080/tpc", "ws", "/ws", emptyMap());
final Map<String, Route> routes = new HashMap<>();
Route route = createRoute("route", ImmutableMap.of("http-server", httpServer, "ws-server", wsServer));
routes.put("route", route);
when(osEnv.getRoutes()).thenReturn(routes);
// when
tlsProvisioner.provision(osEnv, runtimeIdentity);
// then
assertEquals(route.getSpec().getTls().getTermination(), TERMINATION_EDGE);
assertEquals(route.getSpec().getTls().getInsecureEdgeTerminationPolicy(), TERMINATION_POLICY_REDIRECT);
Map<String, ServerConfigImpl> servers = Annotations.newDeserializer(route.getMetadata().getAnnotations()).servers();
assertEquals(servers.get("http-server").getProtocol(), "https");
assertEquals(servers.get("ws-server").getProtocol(), "wss");
}
use of org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl in project che-server by eclipse-che.
the class OpenShiftExternalServerExposerTest method shouldAddRouteToEnvForExposingSpecifiedServerWithSpecificHost.
@Test
public void shouldAddRouteToEnvForExposingSpecifiedServerWithSpecificHost() {
// given
RouteServerExposer osExternalServerExposer = new RouteServerExposer(LABELS, "open.che.org");
OpenShiftEnvironment osEnv = OpenShiftEnvironment.builder().build();
Map<String, ServerConfig> servers = new HashMap<>();
servers.put("server", new ServerConfigImpl());
// when
osExternalServerExposer.expose(osEnv, "machine123", "service123", null, new ServicePort(null, "servicePort", null, null, "TCP", null), servers);
// then
assertEquals(1, osEnv.getRoutes().size());
Route route = osEnv.getRoutes().values().iterator().next();
assertNotNull(route);
assertEquals(route.getSpec().getTo().getName(), "service123");
assertEquals(route.getSpec().getPort().getTargetPort().getStrVal(), "servicePort");
assertTrue(route.getSpec().getHost().endsWith(".open.che.org"));
assertTrue(route.getSpec().getHost().startsWith("route"));
}
Aggregations