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