Search in sources :

Example 36 with Response

use of org.openclinica.ns.response.v31.Response in project keywhiz by square.

the class SessionLoginResourceIntegrationTest method noFormDataIsBadRequest.

@Test
public void noFormDataIsBadRequest() throws Exception {
    Request request = buildLoginPost(null, null);
    Response response = client.newCall(request).execute();
    assertThat(response.code()).isEqualTo(400);
}
Also used : Response(okhttp3.Response) Request(okhttp3.Request) Test(org.junit.Test)

Example 37 with Response

use of org.openclinica.ns.response.v31.Response in project keywhiz by square.

the class AutomationSecretAccessResourceIntegrationTest method allowAccess.

@Test
public void allowAccess() throws Exception {
    //Allow "Web" to access "Hacking_Password"
    Request put = new Request.Builder().put(RequestBody.create(MediaType.parse("text/plain"), "")).url(testUrl("/automation/secrets/738/groups/918")).build();
    Response response = mutualSslClient.newCall(put).execute();
    assertThat(response.code()).isEqualTo(200);
}
Also used : Response(okhttp3.Response) Request(okhttp3.Request) Test(org.junit.Test)

Example 38 with Response

use of org.openclinica.ns.response.v31.Response in project keywhiz by square.

the class AutomationSecretResourceIntegrationTest method readInvalidSecret.

@Test
public void readInvalidSecret() throws Exception {
    Request get = new Request.Builder().get().url(testUrl("/automation/secrets?name=invalid")).build();
    Response response = mutualSslClient.newCall(get).execute();
    assertThat(response.code()).isEqualTo(404);
}
Also used : Response(okhttp3.Response) CreateSecretRequest(keywhiz.api.CreateSecretRequest) Request(okhttp3.Request) Test(org.junit.Test)

Example 39 with Response

use of org.openclinica.ns.response.v31.Response in project keywhiz by square.

the class AutomationSecretResourceIntegrationTest method addSecrets.

@Test
public void addSecrets() throws Exception {
    CreateSecretRequest request = new CreateSecretRequest("new_secret", "desc", "superSecret", ImmutableMap.of(), 0);
    String body = mapper.writeValueAsString(request);
    Request post = new Request.Builder().post(RequestBody.create(KeywhizClient.JSON, body)).url(testUrl("/automation/secrets")).addHeader("Content-Type", MediaType.APPLICATION_JSON).build();
    Response response = mutualSslClient.newCall(post).execute();
    assertThat(response.code()).isEqualTo(200);
}
Also used : Response(okhttp3.Response) CreateSecretRequest(keywhiz.api.CreateSecretRequest) CreateSecretRequest(keywhiz.api.CreateSecretRequest) Request(okhttp3.Request) Test(org.junit.Test)

Example 40 with Response

use of org.openclinica.ns.response.v31.Response in project keywhiz by square.

the class ClientResourceTest method secretListing.

List<String> secretListing(String client) throws IOException {
    Request get = clientRequest(format("/automation/v2/clients/%s/secrets", client)).get().build();
    Response httpResponse = mutualSslClient.newCall(get).execute();
    assertThat(httpResponse.code()).isEqualTo(200);
    return mapper.readValue(httpResponse.body().byteStream(), new TypeReference<List<String>>() {
    });
}
Also used : Response(okhttp3.Response) Request(okhttp3.Request) TestClients.clientRequest(keywhiz.TestClients.clientRequest) List(java.util.List)

Aggregations

Response (okhttp3.Response)474 Request (okhttp3.Request)350 Test (org.junit.Test)213 IOException (java.io.IOException)175 Response (retrofit2.Response)156 ResponseBody (okhttp3.ResponseBody)136 ServiceResponse (com.microsoft.rest.ServiceResponse)114 Call (okhttp3.Call)102 Observable (rx.Observable)98 MockResponse (okhttp3.mockwebserver.MockResponse)76 RequestBody (okhttp3.RequestBody)70 OkHttpClient (okhttp3.OkHttpClient)65 Callback (okhttp3.Callback)43 List (java.util.List)39 TestClients.clientRequest (keywhiz.TestClients.clientRequest)37 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)32 HttpUrl (okhttp3.HttpUrl)26 Interceptor (okhttp3.Interceptor)26 MediaType (okhttp3.MediaType)26 ANResponse (com.androidnetworking.common.ANResponse)23