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());
}
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());
}
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;
}
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());
}
Aggregations