use of io.imunity.furms.domain.users.FURMSUser in project furms by unity-idm.
the class GenericGroupServiceImplTest method shouldFindAllGenericGroupAssignmentWithUser.
@Test
void shouldFindAllGenericGroupAssignmentWithUser() {
GenericGroupId genericGroupId = new GenericGroupId(UUID.randomUUID());
FURMSUser furmsUser = FURMSUser.builder().email("email").fenixUserId(new FenixUserId("userId")).build();
GenericGroupMembership genericGroupMembership = GenericGroupMembership.builder().genericGroupId(genericGroupId).fenixUserId("userId").build();
when(genericGroupRepository.existsBy("communityId", genericGroupId)).thenReturn(true);
when(genericGroupRepository.findAllBy(genericGroupId)).thenReturn(Set.of(genericGroupMembership));
when(usersDAO.getAllUsers()).thenReturn(List.of(furmsUser));
Set<GenericGroupAssignmentWithUser> genericGroupServiceAll = genericGroupService.findAll("communityId", genericGroupId);
assertEquals(1, genericGroupServiceAll.size());
GenericGroupAssignmentWithUser next = genericGroupServiceAll.iterator().next();
assertEquals(furmsUser, next.furmsUser);
assertEquals(genericGroupMembership, next.membership);
}
use of io.imunity.furms.domain.users.FURMSUser in project furms by unity-idm.
the class InvitatoryServiceTest method shouldDetectAndInviteExistingUser.
@Test
void shouldDetectAndInviteExistingUser() {
Role role = Role.FENIX_ADMIN;
ResourceId resourceId = new ResourceId((UUID) null, ResourceType.APP_LEVEL);
PersistentId persistentId = new PersistentId("id");
FenixUserId fenixId = new FenixUserId("fenixId");
FURMSUser furmsUser = FURMSUser.builder().id(persistentId).fenixUserId(fenixId).email("email@email.com").build();
Invitation invitation = Invitation.builder().resourceId(resourceId).role(role).userId(furmsUser.fenixUserId.get()).originator("originator").resourceName("system").email(furmsUser.email).utcExpiredAt(getExpiredAt()).build();
when(usersDAO.findById(persistentId)).thenReturn(Optional.of(furmsUser));
when(usersDAO.getAllUsers()).thenReturn(List.of(furmsUser));
when(usersDAO.getUserAttributes(fenixId)).thenReturn(new UserAttributes(Set.of(), Map.of()));
when(invitationRepository.findBy("email@email.com", role, resourceId)).thenReturn(Optional.empty());
when(authzService.getCurrentAuthNUser()).thenReturn(FURMSUser.builder().email("originator").build());
invitatoryService.inviteUser("email@email.com", resourceId, role, "system");
verify(invitationRepository).create(invitation);
verify(userInvitationNotificationService).notifyUserAboutNewRole(persistentId, invitation.role);
}
use of io.imunity.furms.domain.users.FURMSUser in project furms by unity-idm.
the class InvitatoryServiceTest method shouldInviteNewUser.
@Test
void shouldInviteNewUser() {
Role role = Role.FENIX_ADMIN;
ResourceId resourceId = new ResourceId((UUID) null, ResourceType.APP_LEVEL);
PersistentId persistentId = new PersistentId("id");
InvitationCode code = new InvitationCode("code");
FURMSUser furmsUser = FURMSUser.builder().id(persistentId).fenixUserId(new FenixUserId("fenixId")).email("email@email.com").build();
Invitation invitation = Invitation.builder().resourceId(resourceId).role(role).code(code).resourceName("system").originator("originator").email(furmsUser.email).utcExpiredAt(getExpiredAt()).build();
when(usersDAO.inviteUser(resourceId, role, "email@email.com", getExpiredAt().toInstant(ZoneOffset.UTC))).thenReturn(code);
when(invitationRepository.findBy("email@email.com", role, resourceId)).thenReturn(Optional.empty());
when(authzService.getCurrentAuthNUser()).thenReturn(FURMSUser.builder().email("originator").build());
invitatoryService.inviteUser("email@email.com", resourceId, role, "system");
verify(invitationRepository).create(invitation);
verify(usersDAO).inviteUser(resourceId, role, "email@email.com", getExpiredAt().toInstant(ZoneOffset.UTC));
}
use of io.imunity.furms.domain.users.FURMSUser in project furms by unity-idm.
the class InvitatoryServiceTest method shouldUpdateInvitationRoleForExistingUser.
@Test
void shouldUpdateInvitationRoleForExistingUser() {
Role role = Role.SITE_ADMIN;
ResourceId resourceId = new ResourceId(UUID.randomUUID(), ResourceType.SITE);
InvitationId invitationId = new InvitationId(UUID.randomUUID());
PersistentId persistentId = new PersistentId("id");
FenixUserId fenixId = new FenixUserId("fenixId");
FURMSUser furmsUser = FURMSUser.builder().id(persistentId).fenixUserId(fenixId).email("email@email.com").build();
Invitation invitation = Invitation.builder().id(invitationId).resourceId(resourceId).userId(fenixId).role(role).originator("originator").email("email@email.com").utcExpiredAt(getExpiredAt()).build();
when(invitationRepository.findBy(invitationId)).thenReturn(Optional.of(invitation));
when(usersDAO.getAllUsers()).thenReturn(List.of(furmsUser));
invitatoryService.updateInvitationRole(invitationId, Role.SITE_SUPPORT);
verify(invitationRepository).updateExpiredAtAndRole(invitationId, getExpiredAt(), Role.SITE_SUPPORT);
verify(userInvitationNotificationService).notifyUserAboutNewRole(persistentId, Role.SITE_SUPPORT);
}
use of io.imunity.furms.domain.users.FURMSUser in project furms by unity-idm.
the class InvitatoryServiceTest method shouldInviteExistingUser.
@Test
void shouldInviteExistingUser() {
Role role = Role.FENIX_ADMIN;
ResourceId resourceId = new ResourceId((UUID) null, ResourceType.APP_LEVEL);
PersistentId persistentId = new PersistentId("id");
FenixUserId fenixId = new FenixUserId("fenixId");
FURMSUser furmsUser = FURMSUser.builder().id(persistentId).fenixUserId(fenixId).email("email@email.com").build();
Invitation invitation = Invitation.builder().resourceId(resourceId).role(role).userId(furmsUser.fenixUserId.get()).resourceName("system").originator("originator").email(furmsUser.email).utcExpiredAt(getExpiredAt()).build();
when(usersDAO.findById(persistentId)).thenReturn(Optional.of(furmsUser));
when(usersDAO.getUserAttributes(fenixId)).thenReturn(new UserAttributes(Set.of(), Map.of()));
when(invitationRepository.findBy("email@email.com", role, resourceId)).thenReturn(Optional.empty());
when(authzService.getCurrentAuthNUser()).thenReturn(FURMSUser.builder().email("originator").build());
invitatoryService.inviteUser(persistentId, resourceId, role, "system");
verify(invitationRepository).create(invitation);
verify(userInvitationNotificationService).notifyUserAboutNewRole(persistentId, invitation.role);
}
Aggregations