Search in sources :

Example 21 with ApiClient

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

the class ClientCertificateAuthenticationTest method testInvalidCertificates.

@Test(expected = RuntimeException.class)
public void testInvalidCertificates() {
    final ApiClient client = new ApiClient();
    new ClientCertificateAuthentication(new byte[] {}, new byte[] {}).provide(client);
}
Also used : ApiClient(io.kubernetes.client.openapi.ApiClient) Test(org.junit.Test)

Example 22 with ApiClient

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

the class ClientCertificateAuthenticationTest method testValidCertificatesChain.

@Test
public void testValidCertificatesChain() throws Exception {
    try {
        final ApiClient client = new ApiClient();
        final byte[] certificate = Files.readAllBytes(Paths.get(CLIENT_CERT_CHAIN_PATH));
        final byte[] key = Files.readAllBytes(Paths.get(CLIENT_CERT_CHAIN_KEY_PATH));
        new ClientCertificateAuthentication(certificate, key).provide(client);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
Also used : ApiClient(io.kubernetes.client.openapi.ApiClient) Test(org.junit.Test)

Example 23 with ApiClient

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

the class ClientCertificateAuthenticationTest method testValidECCertificates.

@Test
public void testValidECCertificates() throws Exception {
    try {
        final ApiClient client = new ApiClient();
        final byte[] certificate = Files.readAllBytes(Paths.get(CLIENT_EC_CERT_PATH));
        final byte[] key = Files.readAllBytes(Paths.get(CLIENT_EC_KEY_PATH));
        new ClientCertificateAuthentication(certificate, key).provide(client);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
Also used : ApiClient(io.kubernetes.client.openapi.ApiClient) Test(org.junit.Test)

Example 24 with ApiClient

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

the class TokenFileAuthenticationTest method setup.

@Before
public void setup() throws IOException {
    final ApiClient client = new ApiClient();
    client.setBasePath("http://localhost:" + wireMockRule.port());
    this.auth = new TokenFileAuthentication(SERVICEACCOUNT_TOKEN1_PATH);
    this.auth.provide(client);
    Configuration.setDefaultApiClient(client);
}
Also used : ApiClient(io.kubernetes.client.openapi.ApiClient) Before(org.junit.Before)

Example 25 with ApiClient

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

the class UsernamePasswordAuthenticationTest method testUsernamePasswordProvided.

@Test
public void testUsernamePasswordProvided() {
    final ApiClient client = new ApiClient();
    new UsernamePasswordAuthentication(USERNAME, PASSWORD).provide(client);
    assertThat(getApiKeyAuthFromClient(client).getApiKeyPrefix(), is("Basic"));
    assertThat(getApiKeyAuthFromClient(client).getApiKey(), is(ByteString.of(USERNAME_PASSWORD_BYTES).base64()));
}
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