Search in sources :

Example 1 with JsonIdentityAuthParams

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);
        }
    }
}
Also used : PerryV2DevModeTokenProvider(gov.ca.cwds.test.support.PerryV2DevModeTokenProvider) JsonIdentityAuthParams(gov.ca.cwds.test.support.JsonIdentityAuthParams)

Example 2 with JsonIdentityAuthParams

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);
}
Also used : Invocation(javax.ws.rs.client.Invocation) WebTarget(javax.ws.rs.client.WebTarget) JsonIdentityAuthParams(gov.ca.cwds.test.support.JsonIdentityAuthParams)

Example 3 with JsonIdentityAuthParams

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();
}
Also used : WebTarget(javax.ws.rs.client.WebTarget) JsonIdentityAuthParams(gov.ca.cwds.test.support.JsonIdentityAuthParams)

Example 4 with JsonIdentityAuthParams

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();
}
Also used : WebTarget(javax.ws.rs.client.WebTarget) JsonIdentityAuthParams(gov.ca.cwds.test.support.JsonIdentityAuthParams)

Example 5 with JsonIdentityAuthParams

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());
}
Also used : AssertResponseHelper.assertEqualsResponse(gov.ca.cwds.cals.web.rest.utils.AssertResponseHelper.assertEqualsResponse) Response(javax.ws.rs.core.Response) Invocation(javax.ws.rs.client.Invocation) WebTarget(javax.ws.rs.client.WebTarget) JsonIdentityAuthParams(gov.ca.cwds.test.support.JsonIdentityAuthParams) Test(org.junit.Test) BaseCalsApiIntegrationTest(gov.ca.cwds.cals.BaseCalsApiIntegrationTest)

Aggregations

JsonIdentityAuthParams (gov.ca.cwds.test.support.JsonIdentityAuthParams)8 WebTarget (javax.ws.rs.client.WebTarget)7 Invocation (javax.ws.rs.client.Invocation)5 BaseCalsApiIntegrationTest (gov.ca.cwds.cals.BaseCalsApiIntegrationTest)4 Test (org.junit.Test)4 AssertResponseHelper.assertEqualsResponse (gov.ca.cwds.cals.web.rest.utils.AssertResponseHelper.assertEqualsResponse)3 Response (javax.ws.rs.core.Response)3 FacilityChildrenDto (gov.ca.cwds.cals.service.dto.FacilityChildrenDto)1 PerryV2DevModeTokenProvider (gov.ca.cwds.test.support.PerryV2DevModeTokenProvider)1