Search in sources :

Example 41 with Response

use of retrofit2.Response in project keywhiz by square.

the class XsrfServletFilterIntegrationTest method rejectsForAdminUrlWithoutXsrf.

@Test
public void rejectsForAdminUrlWithoutXsrf() throws Exception {
    noXsrfClient.newCall(buildLoginPost(DbSeedCommand.defaultUser, DbSeedCommand.defaultPassword)).execute();
    Request request = new Request.Builder().url(testUrl("/admin/clients")).get().build();
    Response response = noXsrfClient.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 retrofit2.Response in project keywhiz by square.

the class XsrfServletFilterIntegrationTest method xsrfNotRequiredForLogout.

@Test
public void xsrfNotRequiredForLogout() 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()).isNotEqualTo(401);
}
Also used : Response(okhttp3.Response) Request(okhttp3.Request) Test(org.junit.Test)

Example 43 with Response

use of retrofit2.Response in project keywhiz by square.

the class XsrfServletFilterIntegrationTest method allowsForAdminUrlWithXsrf.

@Test
public void allowsForAdminUrlWithXsrf() throws Exception {
    client.newCall(buildLoginPost(DbSeedCommand.defaultUser, DbSeedCommand.defaultPassword)).execute();
    Request request = new Request.Builder().url(testUrl("/admin/clients")).get().build();
    Response response = client.newCall(request).execute();
    assertThat(response.code()).isNotEqualTo(401);
}
Also used : Response(okhttp3.Response) Request(okhttp3.Request) Test(org.junit.Test)

Example 44 with Response

use of retrofit2.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 45 with Response

use of retrofit2.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)

Aggregations

Response (okhttp3.Response)474 Request (okhttp3.Request)352 Test (org.junit.Test)237 IOException (java.io.IOException)188 Response (retrofit2.Response)156 ResponseBody (okhttp3.ResponseBody)148 ServiceResponse (com.microsoft.rest.ServiceResponse)114 Call (okhttp3.Call)102 MockResponse (okhttp3.mockwebserver.MockResponse)99 Observable (rx.Observable)98 OkHttpClient (okhttp3.OkHttpClient)72 RequestBody (okhttp3.RequestBody)71 Callback (okhttp3.Callback)43 List (java.util.List)40 TestClients.clientRequest (keywhiz.TestClients.clientRequest)37 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)34 Interceptor (okhttp3.Interceptor)29 HttpUrl (okhttp3.HttpUrl)27 MediaType (okhttp3.MediaType)26 Buffer (okio.Buffer)25