Search in sources :

Example 6 with CreateClientRequest

use of keywhiz.api.CreateClientRequest in project keywhiz by square.

the class AutomationClientResourceIntegrationTest method deleteClient.

@Test
public void deleteClient() throws Exception {
    String json = mapper.writeValueAsString(new CreateClientRequest("ShortLived"));
    Request post = new Request.Builder().post(RequestBody.create(KeywhizClient.JSON, json)).url(testUrl("/automation/clients")).addHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON).addHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).build();
    Response response = mutualSslClient.newCall(post).execute();
    assertThat(response.code()).isEqualTo(200);
    long clientId = mapper.readValue(response.body().string(), ClientDetailResponse.class).id;
    Request delete = new Request.Builder().delete().url(testUrl("/automation/clients/" + clientId)).build();
    response = mutualSslClient.newCall(delete).execute();
    assertThat(response.code()).isEqualTo(200);
    Request lookup = new Request.Builder().get().url(testUrl("/automation/clients/" + clientId)).addHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON).build();
    response = mutualSslClient.newCall(lookup).execute();
    assertThat(response.code()).isEqualTo(404);
}
Also used : ClientDetailResponse(keywhiz.api.ClientDetailResponse) Response(okhttp3.Response) CreateClientRequest(keywhiz.api.CreateClientRequest) Request(okhttp3.Request) CreateClientRequest(keywhiz.api.CreateClientRequest) ClientDetailResponse(keywhiz.api.ClientDetailResponse) Test(org.junit.Test)

Aggregations

CreateClientRequest (keywhiz.api.CreateClientRequest)6 ClientDetailResponse (keywhiz.api.ClientDetailResponse)5 Test (org.junit.Test)5 Request (okhttp3.Request)3 Response (okhttp3.Response)3 AutomationClient (keywhiz.api.model.AutomationClient)2 Client (keywhiz.api.model.Client)2 RequestBody (okhttp3.RequestBody)1