Search in sources :

Example 6 with PerryAccount

use of gov.ca.cwds.security.realm.PerryAccount in project api-core by ca-cwds.

the class PlacementHomeCreateAuthorizerTest method checkResourceMgmtAuthorized.

@Test
public void checkResourceMgmtAuthorized() {
    // given
    final PerryAccount perryAccount = initPerryAccountWithPrivileges("Resource Mgmt Placement Facility Maint");
    perryAccount.setCountyCwsCode("1126");
    perryAccount.setCountyCode("99");
    perryAccount.setCountyName("State of California");
    mockStatic(PerrySubject.class);
    when(PerrySubject.getPerryAccount()).thenReturn(perryAccount);
    final PlacementHome placementHome = initPlacementHome();
    // when
    final boolean actual = testSubject.checkInstance(placementHome);
    // then
    assertThat(actual, is(true));
}
Also used : PlacementHome(gov.ca.cwds.data.legacy.cms.entity.PlacementHome) PerryAccount(gov.ca.cwds.security.realm.PerryAccount) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 7 with PerryAccount

use of gov.ca.cwds.security.realm.PerryAccount in project api-core by ca-cwds.

the class PlacementHomeCreateAuthorizerTest method checkCWSCaseManagementUnauthorized.

@Test
public void checkCWSCaseManagementUnauthorized() {
    // given
    final PerryAccount perryAccount = initPerryAccountWithPrivileges("CWS Case Management System");
    perryAccount.setCountyCwsCode("1068");
    perryAccount.setCountyCode("01");
    perryAccount.setCountyName("Alameda");
    mockStatic(PerrySubject.class);
    when(PerrySubject.getPerryAccount()).thenReturn(perryAccount);
    final PlacementHome placementHome = initPlacementHome();
    // when
    final boolean actual = testSubject.checkInstance(placementHome);
    // then
    assertThat(actual, is(false));
}
Also used : PlacementHome(gov.ca.cwds.data.legacy.cms.entity.PlacementHome) PerryAccount(gov.ca.cwds.security.realm.PerryAccount) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 8 with PerryAccount

use of gov.ca.cwds.security.realm.PerryAccount in project api-core by ca-cwds.

the class StaffPrivilegeUtilTest method toStaffPersonPrivilegeTypes_success_whenAllStateLevels.

@Test
public void toStaffPersonPrivilegeTypes_success_whenAllStateLevels() {
    // given
    final PerryAccount input = initPerryAccountWithPrivileges("CWS Case Management System", "Sensitive Persons", "Sealed", "...some noise");
    input.setCountyName("State of California");
    // when
    final Set<StaffPrivilegeType> actual = StaffPrivilegeUtil.toStaffPersonPrivilegeTypes(input);
    // then
    assertThat(actual.size(), is(3));
    assertThat(actual, containsInAnyOrder(SOCIAL_WORKER_ONLY, STATE_SENSITIVE, STATE_SEALED));
}
Also used : StaffPrivilegeType(gov.ca.cwds.authorizer.StaffPrivilegeType) PerryAccount(gov.ca.cwds.security.realm.PerryAccount) Test(org.junit.Test)

Example 9 with PerryAccount

use of gov.ca.cwds.security.realm.PerryAccount in project api-core by ca-cwds.

the class StaffPrivilegeUtilTest method toStaffPersonPrivilegeTypes_success_whenAllCountyLevels.

@Test
public void toStaffPersonPrivilegeTypes_success_whenAllCountyLevels() {
    // given
    final PerryAccount input = initPerryAccountWithPrivileges("CWS Case Management System", "Sensitive Persons", "Sealed", "...some noise");
    input.setCountyName("any county name");
    // when
    final Set<StaffPrivilegeType> actual = StaffPrivilegeUtil.toStaffPersonPrivilegeTypes(input);
    // then
    assertThat(actual.size(), is(3));
    assertThat(actual, containsInAnyOrder(SOCIAL_WORKER_ONLY, COUNTY_SENSITIVE, COUNTY_SEALED));
}
Also used : StaffPrivilegeType(gov.ca.cwds.authorizer.StaffPrivilegeType) PerryAccount(gov.ca.cwds.security.realm.PerryAccount) Test(org.junit.Test)

Example 10 with PerryAccount

use of gov.ca.cwds.security.realm.PerryAccount in project api-core by ca-cwds.

the class StaffPrivilegeUtilTest method toStaffPersonPrivilegeTypes_empty_whenNoPerryPrivileges.

@Test
public void toStaffPersonPrivilegeTypes_empty_whenNoPerryPrivileges() {
    // given
    final PerryAccount input = new PerryAccount();
    // when
    final Set<StaffPrivilegeType> actual = StaffPrivilegeUtil.toStaffPersonPrivilegeTypes(input);
    // then
    assertThat(actual.isEmpty(), is(true));
}
Also used : StaffPrivilegeType(gov.ca.cwds.authorizer.StaffPrivilegeType) PerryAccount(gov.ca.cwds.security.realm.PerryAccount) Test(org.junit.Test)

Aggregations

PerryAccount (gov.ca.cwds.security.realm.PerryAccount)28 Test (org.junit.Test)18 StaffPrivilegeType (gov.ca.cwds.authorizer.StaffPrivilegeType)10 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)8 DroolsException (gov.ca.cwds.drools.DroolsException)3 DataAccessBundle (gov.ca.cwds.cms.data.access.service.lifecycle.DataAccessBundle)2 PlacementHome (gov.ca.cwds.data.legacy.cms.entity.PlacementHome)2 SubstituteCareProvider (gov.ca.cwds.data.legacy.cms.entity.SubstituteCareProvider)2 HashSet (java.util.HashSet)2 AuthorizationException (org.apache.shiro.authz.AuthorizationException)1 Subject (org.apache.shiro.subject.Subject)1