Search in sources :

Example 1 with AdministerSecurityAction

use of org.pentaho.platform.security.policy.rolebased.actions.AdministerSecurityAction in project pentaho-platform by pentaho.

the class AuthorizationActionServiceTest method testDoValidateAuth.

@Test
public void testDoValidateAuth() {
    IAuthorizationPolicy policy = mock(IAuthorizationPolicy.class);
    List<IAuthorizationAction> actions = new ArrayList();
    actions.add(new AdministerSecurityAction());
    doReturn(actions).when(authorizationActionService).getActionList();
    doReturn(policy).when(authorizationActionService).getPolicy();
    doReturn(true).when(policy).isAllowed("org.pentaho.security.administerSecurity");
    boolean isAllowed = authorizationActionService.validateAuth("org.pentaho.security.administerSecurity");
    assertEquals(isAllowed, true);
    isAllowed = authorizationActionService.validateAuth("invalid-auth");
    assertEquals(isAllowed, false);
}
Also used : IAuthorizationPolicy(org.pentaho.platform.api.engine.IAuthorizationPolicy) IAuthorizationAction(org.pentaho.platform.api.engine.IAuthorizationAction) AdministerSecurityAction(org.pentaho.platform.security.policy.rolebased.actions.AdministerSecurityAction) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 IAuthorizationAction (org.pentaho.platform.api.engine.IAuthorizationAction)1 IAuthorizationPolicy (org.pentaho.platform.api.engine.IAuthorizationPolicy)1 AdministerSecurityAction (org.pentaho.platform.security.policy.rolebased.actions.AdministerSecurityAction)1