Search in sources :

Example 1 with ClientDetailResponseV2

use of keywhiz.api.automation.v2.ClientDetailResponseV2 in project keywhiz by square.

the class ClientResourceTest method modifyClient_success.

@Ignore
@Test
public void modifyClient_success() throws Exception {
    // Create sample client
    create(CreateClientRequestV2.builder().name("client9").build());
    ClientDetailResponseV2 originalClient = lookup("client9");
    // Modify client
    ModifyClientRequestV2 request = ModifyClientRequestV2.forName("client9b");
    ClientDetailResponseV2 clientDetail = modify("client9", request);
    assertThat(clientDetail.name()).isEqualTo("client9b");
    assertThat(clientDetail).isEqualToIgnoringGivenFields(originalClient, "name", "updateDate");
    assertThat(clientDetail.updatedAtSeconds()).isGreaterThan(originalClient.updatedAtSeconds());
}
Also used : ClientDetailResponseV2(keywhiz.api.automation.v2.ClientDetailResponseV2) ModifyClientRequestV2(keywhiz.api.automation.v2.ModifyClientRequestV2) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with ClientDetailResponseV2

use of keywhiz.api.automation.v2.ClientDetailResponseV2 in project keywhiz by square.

the class ClientResourceTest method clientInfo_groupExists.

@Test
public void clientInfo_groupExists() throws Exception {
    // Sample client
    create(CreateClientRequestV2.builder().name("client3").build());
    ClientDetailResponseV2 clientDetail = lookup("client3");
    assertThat(clientDetail.name()).isEqualTo("client3");
    assertThat(clientDetail.description()).isEmpty();
    assertThat(clientDetail.createdBy()).isEqualTo(clientDetail.updatedBy()).isEqualTo("client");
}
Also used : ClientDetailResponseV2(keywhiz.api.automation.v2.ClientDetailResponseV2) Test(org.junit.Test)

Example 3 with ClientDetailResponseV2

use of keywhiz.api.automation.v2.ClientDetailResponseV2 in project keywhiz by square.

the class ClientResourceTest method createClient_duplicate.

@Test
public void createClient_duplicate() throws Exception {
    CreateClientRequestV2 request = CreateClientRequestV2.builder().name("client2").build();
    // Initial request OK
    create(request);
    // Duplicate request fails
    Response httpResponse = create(request);
    assertThat(httpResponse.code()).isEqualTo(409);
    // The client was created by the first request
    ClientDetailResponseV2 clientDetail = lookup("client2");
    assertThat(clientDetail.name()).isEqualTo("client2");
    assertThat(clientDetail.description()).isEmpty();
    assertThat(clientDetail.createdBy()).isEqualTo(clientDetail.updatedBy()).isEqualTo("client");
    assertThat(clientDetail.spiffeId()).isEmpty();
}
Also used : Response(okhttp3.Response) ClientDetailResponseV2(keywhiz.api.automation.v2.ClientDetailResponseV2) CreateClientRequestV2(keywhiz.api.automation.v2.CreateClientRequestV2) Test(org.junit.Test)

Example 4 with ClientDetailResponseV2

use of keywhiz.api.automation.v2.ClientDetailResponseV2 in project keywhiz by square.

the class ClientResourceTest method createClient_success.

@Test
public void createClient_success() throws Exception {
    Response httpResponse = create(CreateClientRequestV2.builder().name("client1").description("description").spiffeId("spiffe//example.org/client1").build());
    assertThat(httpResponse.code()).isEqualTo(201);
    URI location = URI.create(Objects.requireNonNull(httpResponse.header(LOCATION)));
    assertThat(location.getPath()).isEqualTo("/automation/v2/clients/client1");
    ClientDetailResponseV2 clientDetail = lookup("client1");
    assertThat(clientDetail.name()).isEqualTo("client1");
    assertThat(clientDetail.description()).isEqualTo("description");
    assertThat(clientDetail.createdBy()).isEqualTo(clientDetail.updatedBy()).isEqualTo("client");
    assertThat(clientDetail.spiffeId()).isEqualTo("spiffe//example.org/client1");
}
Also used : Response(okhttp3.Response) ClientDetailResponseV2(keywhiz.api.automation.v2.ClientDetailResponseV2) URI(java.net.URI) Test(org.junit.Test)

Aggregations

ClientDetailResponseV2 (keywhiz.api.automation.v2.ClientDetailResponseV2)4 Test (org.junit.Test)4 Response (okhttp3.Response)2 URI (java.net.URI)1 CreateClientRequestV2 (keywhiz.api.automation.v2.CreateClientRequestV2)1 ModifyClientRequestV2 (keywhiz.api.automation.v2.ModifyClientRequestV2)1 Ignore (org.junit.Ignore)1