Search in sources :

Example 1 with Case

use of gov.ca.cwds.testapp.domain.Case in project perry by ca-cwds.

the class ApiSecurityTest method testArgUnauthorizedCompositeObject.

@Test(expected = UnauthorizedException.class)
public void testArgUnauthorizedCompositeObject() throws Exception {
    CaseDTO caseDTO = new CaseDTO();
    Case caseObject = new Case(2L, "name");
    caseDTO.setCaseObject(caseObject);
    testService.testCompositeObject(caseDTO);
}
Also used : CaseDTO(gov.ca.cwds.testapp.domain.CaseDTO) Case(gov.ca.cwds.testapp.domain.Case) Test(org.junit.Test)

Example 2 with Case

use of gov.ca.cwds.testapp.domain.Case in project perry by ca-cwds.

the class ApiSecurityTest method testArgAuthorizedCompositeObject.

@Test
public void testArgAuthorizedCompositeObject() throws Exception {
    CaseDTO caseDTO = new CaseDTO();
    Case caseObject = new Case(1L, "name");
    caseDTO.setCaseObject(caseObject);
    testService.testCompositeObject(caseDTO);
}
Also used : CaseDTO(gov.ca.cwds.testapp.domain.CaseDTO) Case(gov.ca.cwds.testapp.domain.Case) Test(org.junit.Test)

Example 3 with Case

use of gov.ca.cwds.testapp.domain.Case in project perry by ca-cwds.

the class BaseAuthorizerTest method check_success_whenOriginalClassInput.

@Test
public void check_success_whenOriginalClassInput() {
    // given
    final Case input = new Case(1L, "name");
    // when
    final boolean actualValue = concreteAuthorizer.check(input);
    // then
    assertThat(actualValue, is(true));
}
Also used : Case(gov.ca.cwds.testapp.domain.Case) Test(org.junit.Test)

Example 4 with Case

use of gov.ca.cwds.testapp.domain.Case in project perry by ca-cwds.

the class AbacPermissionTest method implies_returnFalse_whenNoAuthorizerInInput.

@Test
public void implies_returnFalse_whenNoAuthorizerInInput() {
    // given
    final AbacPermission input = new AbacPermission() {

        {
            setSecuredObject(new Case(1L, "name"));
        }
    };
    // when
    final boolean actualResult = testSubject.implies(input);
    // then
    assertThat(actualResult, is(false));
}
Also used : Case(gov.ca.cwds.testapp.domain.Case) Test(org.junit.Test)

Example 5 with Case

use of gov.ca.cwds.testapp.domain.Case in project perry by ca-cwds.

the class AbacPermissionTest method implies_returnTrue_whenAuthorizedObjectInInput.

@Test
public void implies_returnTrue_whenAuthorizedObjectInInput() {
    // given
    final AbacPermission input = new AbacPermission() {

        {
            setSecuredObject(new Case(1L, "name"));
            Whitebox.setInternalState(this, "authorizer", new CaseAuthorizer());
        }
    };
    // when
    final boolean actualResult = testSubject.implies(input);
    // then
    assertThat(actualResult, is(true));
}
Also used : CaseAuthorizer(gov.ca.cwds.security.authorizer.CaseAuthorizer) Case(gov.ca.cwds.testapp.domain.Case) Test(org.junit.Test)

Aggregations

Case (gov.ca.cwds.testapp.domain.Case)11 Test (org.junit.Test)8 CaseDTO (gov.ca.cwds.testapp.domain.CaseDTO)7 Authorize (gov.ca.cwds.security.annotations.Authorize)3 CaseAuthorizer (gov.ca.cwds.security.authorizer.CaseAuthorizer)2 ArrayList (java.util.ArrayList)1