KubernetesEndpointComponent extends AbstractEndpointComponent { @Override protected Endpoint createEndpoint(String resourcePath, Map<String, String> parameters, TestContext context) { KubernetesClient client = new KubernetesClient(); if (resourcePath.startsWith("https: client.getEndpointConfiguration().getKubernetesClientConfig().setMasterUrl(resourcePath); } else { client.getEndpointConfiguration().getKubernetesClientConfig().setMasterUrl("https: } if (parameters.containsKey("version")) { client.getEndpointConfiguration().getKubernetesClientConfig().setApiVersion(parameters.remove("version")); } if (parameters.containsKey("username")) { client.getEndpointConfiguration().getKubernetesClientConfig().setUsername(parameters.remove("username")); } if (parameters.containsKey("password")) { client.getEndpointConfiguration().getKubernetesClientConfig().setPassword(parameters.remove("password")); } if (parameters.containsKey("namespace")) { client.getEndpointConfiguration().getKubernetesClientConfig().setNamespace(parameters.remove("namespace")); } if (parameters.containsKey("cert-file")) { client.getEndpointConfiguration().getKubernetesClientConfig().setCaCertFile(parameters.remove("cert-file")); } enrichEndpointConfiguration(client.getEndpointConfiguration(), getEndpointConfigurationParameters(parameters, KubernetesEndpointConfiguration.class), context); return client; } KubernetesEndpointComponent();   }
@Test public void testCreateClientEndpoint() throws Exception { KubernetesEndpointComponent component = new KubernetesEndpointComponent(); Endpoint endpoint = component.createEndpoint("k8s:localhost:8443/", context); Assert.assertEquals(endpoint.getClass(), KubernetesClient.class); Assert.assertEquals(((KubernetesClient)endpoint).getEndpointConfiguration().getKubernetesClientConfig().getMasterUrl(), "https: endpoint = component.createEndpoint("k8s:http: Assert.assertEquals(endpoint.getClass(), KubernetesClient.class); Assert.assertEquals(((KubernetesClient)endpoint).getEndpointConfiguration().getKubernetesClientConfig().getMasterUrl(), "http: Assert.assertEquals(((KubernetesClient) endpoint).getEndpointConfiguration().getTimeout(), 5000L); }
@Test public void testCreateClientEndpointWithParameters() throws Exception { KubernetesEndpointComponent component = new KubernetesEndpointComponent(); Endpoint endpoint = component.createEndpoint("k8s:localhost:8443?namespace=myNamespace&timeout=10000", context); Assert.assertEquals(endpoint.getClass(), KubernetesClient.class); Assert.assertEquals(((KubernetesClient)endpoint).getEndpointConfiguration().getKubernetesClientConfig().getMasterUrl(), "https: Assert.assertEquals(((KubernetesClient)endpoint).getEndpointConfiguration().getKubernetesClientConfig().getNamespace(), "myNamespace"); Assert.assertEquals(((KubernetesClient) endpoint).getEndpointConfiguration().getTimeout(), 10000L); }