Search in sources :

Example 6 with UserEntity

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

the class CreateEIDUserCommandTest method execute_UpdateExistingUser.

@Test
public void execute_UpdateExistingUser() throws Exception {
    User user = new UserEntity(INSZ);
    when(chainContextMock.getSAMLUser()).thenReturn(samlUser);
    when(userServiceMock.findByName(INSZ)).thenReturn(user);
    State state = createEIDUserCommand.execute(chainContextMock);
    assertEquals(State.CONTINUE, state);
    verify(chainContextMock).setUserPrincipal(INSZ);
    assertEquals(INSZ, user.getUserName());
    assertEquals(FIRSTNAME, user.getFirstName());
    assertEquals(LASTNAME, user.getName());
    assertEquals(Language.fromISO639Code(NL), user.getLanguage());
}
Also used : User(org.simbasecurity.core.domain.User) State(org.simbasecurity.core.chain.Command.State) UserEntity(org.simbasecurity.core.domain.UserEntity) Test(org.junit.Test)

Example 7 with UserEntity

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

the class RuleDatabaseRepositoryTest method setUp.

@Before
public void setUp() {
    UserEntity user = new UserEntity(USER_NAME);
    RoleEntity role = new RoleEntity(ROLE_NAME);
    policy = new PolicyEntity(POLICY_NAME);
    resourceRuleEntity = new ResourceRuleEntity(RESOURCE_RULE_NAME);
    resourceRuleEntity.setResourceName(RESOURCE_NAME);
    urlRuleEntity = new URLRuleEntity("urlrule");
    persistAndRefresh(user, role, policy, resourceRuleEntity, urlRuleEntity);
    policy.addRule(resourceRuleEntity);
    policy.addRule(urlRuleEntity);
    role.addPolicy(policy);
    user.addRole(role);
}
Also used : RoleEntity(org.simbasecurity.core.domain.RoleEntity) PolicyEntity(org.simbasecurity.core.domain.PolicyEntity) ResourceRuleEntity(org.simbasecurity.core.domain.ResourceRuleEntity) UserEntity(org.simbasecurity.core.domain.UserEntity) URLRuleEntity(org.simbasecurity.core.domain.URLRuleEntity) Before(org.junit.Before)

Example 8 with UserEntity

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

the class GroupDatabaseRepositoryTest method find.

@Test
public void find() {
    UserEntity user = new UserEntity("Jan");
    user.addGroup(group);
    persistAndRefresh(user);
    Collection<Group> result = groupDatabaseRepository.find(user);
    assertThat(result).containsOnly(group);
}
Also used : Group(org.simbasecurity.core.domain.Group) UserEntity(org.simbasecurity.core.domain.UserEntity) Test(org.junit.Test)

Aggregations

UserEntity (org.simbasecurity.core.domain.UserEntity)8 User (org.simbasecurity.core.domain.User)5 Test (org.junit.Test)3 Before (org.junit.Before)2 Group (org.simbasecurity.core.domain.Group)2 PolicyEntity (org.simbasecurity.core.domain.PolicyEntity)2 ResourceRuleEntity (org.simbasecurity.core.domain.ResourceRuleEntity)2 Role (org.simbasecurity.core.domain.Role)2 RoleEntity (org.simbasecurity.core.domain.RoleEntity)2 URLRuleEntity (org.simbasecurity.core.domain.URLRuleEntity)2 SSOToken (org.simbasecurity.api.service.thrift.SSOToken)1 State (org.simbasecurity.core.chain.Command.State)1 GroupEntity (org.simbasecurity.core.domain.GroupEntity)1 Policy (org.simbasecurity.core.domain.Policy)1 ResourceRule (org.simbasecurity.core.domain.ResourceRule)1 SessionEntity (org.simbasecurity.core.domain.SessionEntity)1