use of gov.ca.cwds.test.support.JsonIdentityAuthParams in project cals-api by ca-cwds.
the class RestClientTestRule method prepareForTesting.
private void prepareForTesting() {
if (TestModeUtils.isIntegrationTestsMode()) {
try {
String principal = fixture("security/default-login-principal.json");
defaultAuthParams = new JsonIdentityAuthParams(principal);
tokenProvider = new PerryV2DevModeTokenProvider(client, TestModeUtils.perryUrl(), TestModeUtils.loginFormTargetUrl());
} catch (Exception e) {
LOG.warn("Cannot generate token");
LOG.error(e.getMessage(), e);
}
}
}
use of gov.ca.cwds.test.support.JsonIdentityAuthParams in project cals-api by ca-cwds.
the class FacilityChildAuthorizationTest method getFacilityChildrenDTO.
private FacilityChildrenDto getFacilityChildrenDTO(String principal) {
String pathInfo = FACILITIES + "/{" + FACILITY_ID + "}/" + CHILDREN + "?" + TestSecurityFilter.PATH_TO_PRINCIPAL_FIXTURE + '=' + principal;
pathInfo = pathInfo.replace("{" + FACILITY_ID + "}", "412252222");
JsonIdentityAuthParams params = new JsonIdentityAuthParams(fixture(principal));
WebTarget target = clientTestRule.target(pathInfo, params);
Invocation.Builder invocation = target.request(MediaType.APPLICATION_JSON);
return invocation.get(FacilityChildrenDto.class);
}
use of gov.ca.cwds.test.support.JsonIdentityAuthParams in project cals-api by ca-cwds.
the class FacilityComplaintResourceTest method getFacilityComplaintsResponse.
private Response getFacilityComplaintsResponse(String principalJsonPath) {
String pathInfo = FACILITIES + "/" + FACILITY_ID + "/" + Constants.API.COMPLAINTS + '?' + TestSecurityFilter.PATH_TO_PRINCIPAL_FIXTURE + '=' + principalJsonPath;
JsonIdentityAuthParams params = new JsonIdentityAuthParams(fixture(principalJsonPath));
WebTarget target = clientTestRule.target(pathInfo, params);
return target.request(MediaType.APPLICATION_JSON).get();
}
use of gov.ca.cwds.test.support.JsonIdentityAuthParams in project cals-api by ca-cwds.
the class FacilityComplaintResourceTest method getFacilityComplaintResponse.
private Response getFacilityComplaintResponse(String principalJsonPath) {
String pathInfo = FACILITIES + "/" + FACILITY_ID + "/" + API.COMPLAINTS + "/" + COMPLAINT_ID + '?' + TestSecurityFilter.PATH_TO_PRINCIPAL_FIXTURE + '=' + principalJsonPath;
JsonIdentityAuthParams params = new JsonIdentityAuthParams(fixture(principalJsonPath));
WebTarget target = clientTestRule.target(pathInfo, params);
return target.request(MediaType.APPLICATION_JSON).get();
}
use of gov.ca.cwds.test.support.JsonIdentityAuthParams in project cals-api by ca-cwds.
the class FacilityResourceTest method testUnauthorizedCallGetFacilityByFacilityId.
@Test
public void testUnauthorizedCallGetFacilityByFacilityId() throws Exception {
String targetString = Constants.API.FACILITIES + "/" + FACILITY_ID + '?' + TestSecurityFilter.PATH_TO_PRINCIPAL_FIXTURE + '=' + PRINCIPAL_NO_PRIVILAGES_JSON;
JsonIdentityAuthParams params = new JsonIdentityAuthParams(fixture(PRINCIPAL_NO_PRIVILAGES_JSON));
WebTarget target = clientTestRule.target(targetString, params);
Invocation.Builder invocation = target.request(MediaType.APPLICATION_JSON);
Response response = invocation.get();
assertEquals(HttpStatus.SC_FORBIDDEN, response.getStatus());
}
Aggregations