Search in sources :

Example 1 with ResourceRule

use of org.simbasecurity.core.domain.ResourceRule in project simba-os by cegeka.

the class RuleDTOAssemblerTest method testAssembleSingleRule_ResourceRule.

@Test
public void testAssembleSingleRule_ResourceRule() {
    ResourceRule resourceRule = createResourceRule();
    ResourceRuleDTO ruleData = (ResourceRuleDTO) RuleDTOAssembler.assemble(resourceRule);
    assertNotNull(ruleData);
    assertEquals(resourceRule.getName(), ruleData.getName());
    assertEquals(resourceRule.getResourceName(), ruleData.getResourceName());
    assertEquals(true, ruleData.isCreateAllowed());
    assertEquals(true, ruleData.isDeleteAllowed());
    assertEquals(true, ruleData.isReadAllowed());
    assertEquals(true, ruleData.isWriteAllowed());
    assertEquals(0, ruleData.getId());
    assertEquals(0, ruleData.getVersion());
}
Also used : ResourceRule(org.simbasecurity.core.domain.ResourceRule) ResourceRuleDTO(org.simbasecurity.core.service.manager.dto.ResourceRuleDTO) Test(org.junit.Test)

Example 2 with ResourceRule

use of org.simbasecurity.core.domain.ResourceRule in project simba-os by cegeka.

the class RuleDatabaseRepositoryTest method canFindRulesLinkedViaGroup.

@Test
public void canFindRulesLinkedViaGroup() {
    ResourceRule resourceRuleEntity = setupWithGroups();
    Collection<ResourceRule> retrievedRules = ruleDatabaseRepository.findResourceRules(USER_VIA_GROUP, "resname2");
    assertEquals(1, retrievedRules.size());
    assertEquals(resourceRuleEntity, retrievedRules.iterator().next());
}
Also used : ResourceRule(org.simbasecurity.core.domain.ResourceRule) Test(org.junit.Test)

Example 3 with ResourceRule

use of org.simbasecurity.core.domain.ResourceRule in project simba-os by cegeka.

the class RuleDatabaseRepositoryTest method setupWithGroups.

private ResourceRule setupWithGroups() {
    User user = new UserEntity(USER_VIA_GROUP);
    Role role = new RoleEntity("role2");
    Group group = new GroupEntity("groupName", "cn");
    Policy policy = new PolicyEntity("policy2");
    ResourceRule resourceRuleEntity = new ResourceRuleEntity("resrule2");
    resourceRuleEntity.setResourceName("resname2");
    urlRuleEntityViaGroup = new URLRuleEntity("urlrule2");
    persistAndRefresh(user, role, policy, resourceRuleEntity, urlRuleEntityViaGroup);
    persistAndRefresh(user, group, role, policy, resourceRuleEntity, urlRuleEntityViaGroup);
    policy.addRule(resourceRuleEntity);
    policy.addRule(urlRuleEntityViaGroup);
    role.addPolicy(policy);
    group.addRole(role);
    user.addGroup(group);
    return resourceRuleEntity;
}
Also used : Role(org.simbasecurity.core.domain.Role) RoleEntity(org.simbasecurity.core.domain.RoleEntity) Policy(org.simbasecurity.core.domain.Policy) Group(org.simbasecurity.core.domain.Group) User(org.simbasecurity.core.domain.User) GroupEntity(org.simbasecurity.core.domain.GroupEntity) PolicyEntity(org.simbasecurity.core.domain.PolicyEntity) ResourceRule(org.simbasecurity.core.domain.ResourceRule) ResourceRuleEntity(org.simbasecurity.core.domain.ResourceRuleEntity) UserEntity(org.simbasecurity.core.domain.UserEntity) URLRuleEntity(org.simbasecurity.core.domain.URLRuleEntity)

Example 4 with ResourceRule

use of org.simbasecurity.core.domain.ResourceRule in project simba-os by cegeka.

the class RuleDTOAssemblerTest method testAssembleMultipleRules.

@Test
public void testAssembleMultipleRules() {
    Rule resourceRule = createResourceRule();
    Rule urlRule = createUrlRule();
    Collection<RuleDTO> ruleDataList = RuleDTOAssembler.assemble(Arrays.asList(resourceRule, urlRule));
    assertNotNull(ruleDataList);
    assertEquals(2, ruleDataList.size());
}
Also used : URLRuleDTO(org.simbasecurity.core.service.manager.dto.URLRuleDTO) RuleDTO(org.simbasecurity.core.service.manager.dto.RuleDTO) ResourceRuleDTO(org.simbasecurity.core.service.manager.dto.ResourceRuleDTO) ResourceRule(org.simbasecurity.core.domain.ResourceRule) URLRule(org.simbasecurity.core.domain.URLRule) Rule(org.simbasecurity.core.domain.Rule) Test(org.junit.Test)

Aggregations

ResourceRule (org.simbasecurity.core.domain.ResourceRule)4 Test (org.junit.Test)3 ResourceRuleDTO (org.simbasecurity.core.service.manager.dto.ResourceRuleDTO)2 Group (org.simbasecurity.core.domain.Group)1 GroupEntity (org.simbasecurity.core.domain.GroupEntity)1 Policy (org.simbasecurity.core.domain.Policy)1 PolicyEntity (org.simbasecurity.core.domain.PolicyEntity)1 ResourceRuleEntity (org.simbasecurity.core.domain.ResourceRuleEntity)1 Role (org.simbasecurity.core.domain.Role)1 RoleEntity (org.simbasecurity.core.domain.RoleEntity)1 Rule (org.simbasecurity.core.domain.Rule)1 URLRule (org.simbasecurity.core.domain.URLRule)1 URLRuleEntity (org.simbasecurity.core.domain.URLRuleEntity)1 User (org.simbasecurity.core.domain.User)1 UserEntity (org.simbasecurity.core.domain.UserEntity)1 RuleDTO (org.simbasecurity.core.service.manager.dto.RuleDTO)1 URLRuleDTO (org.simbasecurity.core.service.manager.dto.URLRuleDTO)1