Search in sources :

Example 41 with Response

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

the class SessionLoginResourceIntegrationTest method invalidCredentialsAreUnauthorized.

@Test
public void invalidCredentialsAreUnauthorized() throws Exception {
    Request request = buildLoginPost("username", "badpassword");
    Response response = client.newCall(request).execute();
    assertThat(response.code()).isEqualTo(401);
}
Also used : Response(okhttp3.Response) Request(okhttp3.Request) Test(org.junit.Test)

Example 42 with Response

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

the class SessionLoginResourceIntegrationTest method respondsToLogin.

@Test
public void respondsToLogin() throws Exception {
    Request post = new Request.Builder().post(RequestBody.create(MediaType.parse("text/plain"), "")).url(testUrl("/admin/login")).build();
    Response response = client.newCall(post).execute();
    assertThat(response.code()).isNotEqualTo(404);
}
Also used : Response(okhttp3.Response) Request(okhttp3.Request) Test(org.junit.Test)

Example 43 with Response

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

the class SessionLoginResourceIntegrationTest method missingPasswordIsBadRequest.

@Test
public void missingPasswordIsBadRequest() throws Exception {
    Request request = buildLoginPost("username", 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 44 with Response

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

the class SessionLoginResourceIntegrationTest method insufficientRolesAreUnauthorized.

@Test
public void insufficientRolesAreUnauthorized() throws Exception {
    Request request = buildLoginPost("username", "password");
    Response response = client.newCall(request).execute();
    assertThat(response.code()).isEqualTo(401);
}
Also used : Response(okhttp3.Response) Request(okhttp3.Request) Test(org.junit.Test)

Example 45 with Response

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

the class SessionLogoutResourceIntegrationTest method sendsExpiredCookie.

@Test
public void sendsExpiredCookie() throws Exception {
    Request request = new Request.Builder().post(RequestBody.create(MediaType.parse("text/plain"), "")).url(testUrl("/admin/logout")).build();
    Response response = client.newCall(request).execute();
    assertThat(response.code()).isEqualTo(303);
    List<String> cookies = response.headers(HttpHeaders.SET_COOKIE);
    assertThat(cookies).hasSize(1);
    NewCookie cookie = NewCookie.valueOf(cookies.get(0));
    assertThat(cookie.getName()).isEqualTo("session");
    assertThat(cookie.getValue()).isEqualTo("expired");
    assertThat(cookie.getVersion()).isEqualTo(1);
    assertThat(cookie.getPath()).isEqualTo("/admin");
    assertThat(cookie.isSecure()).isTrue();
    assertThat(cookie.isHttpOnly()).isTrue();
    assertThat(cookie.getExpiry()).isEqualTo(new Date(0));
}
Also used : Response(okhttp3.Response) Request(okhttp3.Request) Date(java.util.Date) NewCookie(javax.ws.rs.core.NewCookie) Test(org.junit.Test)

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