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);
}
Aggregations