List of usage examples for com.squareup.okhttp Response code
int code
To view the source code for com.squareup.okhttp Response code.
Click Source Link
From source file:keywhiz.service.resources.AutomationClientResourceIntegrationTest.java
License:Apache License
@Test public void listClients() throws Exception { Request get = new Request.Builder().get().url(testUrl("/automation/clients")) .addHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON).build(); Response httpResponse = mutualSslClient.newCall(get).execute(); assertThat(httpResponse.code()).isEqualTo(200); }
From source file:keywhiz.service.resources.AutomationClientResourceIntegrationTest.java
License:Apache License
@Test public void addClients() throws Exception { CreateClientRequest request = new CreateClientRequest("User1"); String requestJSON = mapper.writeValueAsString(request); RequestBody body = RequestBody.create(KeywhizClient.JSON, requestJSON); Request post = new Request.Builder().post(body).url(testUrl("/automation/clients")) .addHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON) .addHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).build(); Response httpResponse = mutualSslClient.newCall(post).execute(); assertThat(httpResponse.code()).isEqualTo(200); }
From source file:keywhiz.service.resources.AutomationClientResourceIntegrationTest.java
License:Apache License
@Test public void addClientRedundant() throws Exception { CreateClientRequest request = new CreateClientRequest("CN=User1"); String json = mapper.writeValueAsString(request); 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 httpResponse = mutualSslClient.newCall(post).execute(); assertThat(httpResponse.code()).isEqualTo(409); }
From source file:keywhiz.service.resources.AutomationClientResourceIntegrationTest.java
License:Apache License
@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); }
From source file:keywhiz.service.resources.AutomationEnrollClientGroupResourceIntegrationTest.java
License:Apache License
@Test public void enrollClient() throws Exception { //Enroll "CN=User4" in "Blackops" Request post = new Request.Builder().put(RequestBody.create(MediaType.parse("text/plain"), "")) .url(testUrl("/automation/clients/772/groups/916")).build(); Response httpResponse = mutualSslClient.newCall(post).execute(); assertThat(httpResponse.code()).isEqualTo(200); }
From source file:keywhiz.service.resources.AutomationEnrollClientGroupResourceIntegrationTest.java
License:Apache License
@Test public void evictClient() throws Exception { //Evict "CN=User4" from "Web" Request delete = new Request.Builder().delete().url(testUrl("/automation/clients/772/groups/918")).build(); Response httpResponse = mutualSslClient.newCall(delete).execute(); assertThat(httpResponse.code()).isEqualTo(200); }
From source file:keywhiz.service.resources.AutomationEnrollClientGroupResourceIntegrationTest.java
License:Apache License
@Test public void evictClientNotFound() throws Exception { //Evict non-existent client from "Web" Request delete = new Request.Builder().delete().url(testUrl("/automation/clients/2/groups/918")).build(); Response httpResponse = mutualSslClient.newCall(delete).execute(); assertThat(httpResponse.code()).isEqualTo(404); }
From source file:keywhiz.service.resources.AutomationEnrollClientGroupResourceIntegrationTest.java
License:Apache License
@Test public void evictGroupNotFound() throws Exception { //Evict non-existent client from "Web" Request delete = new Request.Builder().delete().url(testUrl("/automation/clients/772/groups/5")).build(); Response httpResponse = mutualSslClient.newCall(delete).execute(); assertThat(httpResponse.code()).isEqualTo(404); }
From source file:keywhiz.service.resources.AutomationGroupResourceIntegrationTest.java
License:Apache License
@Test public void findGroup() throws Exception { Request get = new Request.Builder().get().url(testUrl("/automation/groups?name=Web")) .addHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON).build(); Response response = mutualSslClient.newCall(get).execute(); assertThat(response.code()).isEqualTo(200); GroupDetailResponse groupResponse = mapper.readValue(response.body().string(), GroupDetailResponse.class); assertThat(groupResponse.getId()).isEqualTo(918); }
From source file:keywhiz.service.resources.AutomationGroupResourceIntegrationTest.java
License:Apache License
@Test public void findAllGroups() throws Exception { Request get = new Request.Builder().get().url(testUrl("/automation/groups")) .addHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON).build(); Response response = mutualSslClient.newCall(get).execute(); assertThat(response.code()).isEqualTo(200); List<GroupDetailResponse> groups = mapper.readValue(response.body().string(), new TypeReference<List<GroupDetailResponse>>() { });/*from w ww . j av a 2s .co m*/ assertThat(groups).extracting("name").contains("Blackops", "Security", "Web", "iOS"); }