Search in sources :

Example 21 with PerryAccount

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

the class StaffPrivilegeUtilTest method toStaffPersonPrivilegeTypes_success_whenCountySealed.

@Test
public void toStaffPersonPrivilegeTypes_success_whenCountySealed() {
    // given
    final PerryAccount input = initPerryAccountWithPrivileges("Sealed");
    // when
    final Set<StaffPrivilegeType> actual = StaffPrivilegeUtil.toStaffPersonPrivilegeTypes(input);
    // then
    assertThat(actual.size(), is(1));
    assertThat(actual, contains(COUNTY_SEALED));
}
Also used : StaffPrivilegeType(gov.ca.cwds.authorizer.StaffPrivilegeType) PerryAccount(gov.ca.cwds.security.realm.PerryAccount) Test(org.junit.Test)

Example 22 with PerryAccount

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

the class PerryAccountUtils method initPerryAccountWithPrivileges.

public static PerryAccount initPerryAccountWithPrivileges(String... privileges) {
    final PerryAccount perryAccount = new PerryAccount();
    final HashSet<String> privilegeSet = new HashSet<>();
    privilegeSet.addAll(Arrays.asList(privileges));
    perryAccount.setPrivileges(privilegeSet);
    return perryAccount;
}
Also used : PerryAccount(gov.ca.cwds.security.realm.PerryAccount) HashSet(java.util.HashSet)

Example 23 with PerryAccount

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

the class ClientResultReadAuthorizerTest method initUserAccount.

private void initUserAccount(String userCountyCwsCode, String userCountyName, String... privileges) {
    final PerryAccount perryAccount = initPerryAccountWithPrivileges(privileges);
    perryAccount.setCountyCwsCode(userCountyCwsCode);
    perryAccount.setCountyName(userCountyName);
    mockStatic(PerrySubject.class);
    when(PerrySubject.getPerryAccount()).thenReturn(perryAccount);
}
Also used : PerryAccount(gov.ca.cwds.security.realm.PerryAccount)

Example 24 with PerryAccount

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

the class SubstituteCareProviderCreateAuthorizerTest 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 SubstituteCareProvider substituteCareProvider = initSCP();
    // when
    final boolean actual = testSubject.checkInstance(substituteCareProvider);
    // then
    assertThat(actual, is(true));
}
Also used : SubstituteCareProvider(gov.ca.cwds.data.legacy.cms.entity.SubstituteCareProvider) PerryAccount(gov.ca.cwds.security.realm.PerryAccount) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 25 with PerryAccount

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

the class SubstituteCareProviderCreateAuthorizerTest 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 SubstituteCareProvider substituteCareProvider = initSCP();
    // when
    final boolean actual = testSubject.checkInstance(substituteCareProvider);
    // then
    assertThat(actual, is(false));
}
Also used : SubstituteCareProvider(gov.ca.cwds.data.legacy.cms.entity.SubstituteCareProvider) PerryAccount(gov.ca.cwds.security.realm.PerryAccount) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

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