Search in sources :

Example 16 with ApiClient

use of io.kubernetes.client.openapi.ApiClient in project java by kubernetes-client.

the class ClientBuilderTest method testKubeconfigAddsSchemeHttp.

@Test
public void testKubeconfigAddsSchemeHttp() throws Exception {
    String path = withEnvironmentVariable("KUBECONFIG", KUBECONFIG_HTTP_FILE_PATH).execute(() -> {
        final ApiClient client = ClientBuilder.standard().build();
        return client.getBasePath();
    });
    assertThat(path, is("http://localhost"));
}
Also used : ApiClient(io.kubernetes.client.openapi.ApiClient) Test(org.junit.Test)

Example 17 with ApiClient

use of io.kubernetes.client.openapi.ApiClient in project java by kubernetes-client.

the class ClientBuilderTest method testCredentialProviderInvoked.

@Test
public void testCredentialProviderInvoked() throws IOException {
    final Authentication provider = mock(Authentication.class);
    final ApiClient client = ClientBuilder.standard().setAuthentication(provider).build();
    verify(provider).provide(client);
}
Also used : KubeconfigAuthentication(io.kubernetes.client.util.credentials.KubeconfigAuthentication) Authentication(io.kubernetes.client.util.credentials.Authentication) ClientCertificateAuthentication(io.kubernetes.client.util.credentials.ClientCertificateAuthentication) ApiClient(io.kubernetes.client.openapi.ApiClient) Test(org.junit.Test)

Example 18 with ApiClient

use of io.kubernetes.client.openapi.ApiClient in project java by kubernetes-client.

the class ClientBuilderTest method testBasePathTrailingSlash.

@Test
public void testBasePathTrailingSlash() throws Exception {
    final ApiClient client = ClientBuilder.standard().setBasePath("http://localhost/").build();
    assertThat(client.getBasePath(), is("http://localhost"));
}
Also used : ApiClient(io.kubernetes.client.openapi.ApiClient) Test(org.junit.Test)

Example 19 with ApiClient

use of io.kubernetes.client.openapi.ApiClient in project java by kubernetes-client.

the class ClientBuilderTest method testInvalidKubeconfig.

@Test
public void testInvalidKubeconfig() throws Exception {
    String path = withEnvironmentVariable("KUBECONFIG", "/non-existent").and("HOME", "/none-existent").and("HOMEDRIVE", null).and("USERPROFILE", null).execute(() -> {
        final ApiClient client = ClientBuilder.standard().build();
        return client.getBasePath();
    });
    assertThat(path, is(Config.DEFAULT_FALLBACK_HOST));
}
Also used : ApiClient(io.kubernetes.client.openapi.ApiClient) Test(org.junit.Test)

Example 20 with ApiClient

use of io.kubernetes.client.openapi.ApiClient in project java by kubernetes-client.

the class ClientCertificateAuthenticationTest method testValidCertificates.

@Test
public void testValidCertificates() throws Exception {
    final ApiClient client = new ApiClient();
    final byte[] certificate = Files.readAllBytes(Paths.get(CLIENT_CERT_PATH));
    final byte[] key = Files.readAllBytes(Paths.get(CLIENT_KEY_PATH));
    new ClientCertificateAuthentication(certificate, key).provide(client);
}
Also used : ApiClient(io.kubernetes.client.openapi.ApiClient) Test(org.junit.Test)

Aggregations

ApiClient (io.kubernetes.client.openapi.ApiClient)61 Test (org.junit.Test)28 CoreV1Api (io.kubernetes.client.openapi.apis.CoreV1Api)13 V1Pod (io.kubernetes.client.openapi.models.V1Pod)12 IOException (java.io.IOException)11 V1PodList (io.kubernetes.client.openapi.models.V1PodList)9 ClientBuilder (io.kubernetes.client.util.ClientBuilder)6 V1ObjectMeta (io.kubernetes.client.openapi.models.V1ObjectMeta)5 Before (org.junit.Before)5 ApiException (io.kubernetes.client.openapi.ApiException)4 SharedInformerFactory (io.kubernetes.client.informer.SharedInformerFactory)3 V1Job (io.kubernetes.client.openapi.models.V1Job)3 V1JobList (io.kubernetes.client.openapi.models.V1JobList)3 V1Namespace (io.kubernetes.client.openapi.models.V1Namespace)3 OkHttpClient (okhttp3.OkHttpClient)3 NodeMetrics (io.kubernetes.client.custom.NodeMetrics)2 PodMetrics (io.kubernetes.client.custom.PodMetrics)2 V1Patch (io.kubernetes.client.custom.V1Patch)2 LeaderElectionConfig (io.kubernetes.client.extended.leaderelection.LeaderElectionConfig)2 LeaderElector (io.kubernetes.client.extended.leaderelection.LeaderElector)2