Search in sources :

Example 1 with InvitationId

use of io.imunity.furms.domain.invitations.InvitationId in project furms by unity-idm.

the class InvitatoryServiceTest method removeInvitationForNewUser.

@Test
void removeInvitationForNewUser() {
    Role role = Role.FENIX_ADMIN;
    ResourceId resourceId = new ResourceId((UUID) null, ResourceType.APP_LEVEL);
    InvitationCode invitationCode = new InvitationCode("code");
    InvitationId invitationId = new InvitationId(UUID.randomUUID());
    Invitation invitation = Invitation.builder().id(invitationId).resourceId(resourceId).role(role).code(invitationCode).originator("originator").email("email@email.com").utcExpiredAt(getExpiredAt()).build();
    when(invitationRepository.findBy(invitationId)).thenReturn(Optional.of(invitation));
    invitatoryService.removeInvitation(invitationId);
    verify(invitationRepository).deleteBy(invitationId);
    verify(usersDAO).removeInvitation(invitationCode);
}
Also used : Role(io.imunity.furms.domain.authz.roles.Role) ResourceId(io.imunity.furms.domain.authz.roles.ResourceId) InvitationCode(io.imunity.furms.domain.invitations.InvitationCode) Invitation(io.imunity.furms.domain.invitations.Invitation) InvitationId(io.imunity.furms.domain.invitations.InvitationId) Test(org.junit.jupiter.api.Test)

Example 2 with InvitationId

use of io.imunity.furms.domain.invitations.InvitationId in project furms by unity-idm.

the class InvitatoryServiceTest method shouldResendInvitationForNewUser.

@Test
void shouldResendInvitationForNewUser() {
    Role role = Role.FENIX_ADMIN;
    ResourceId resourceId = new ResourceId((UUID) null, ResourceType.APP_LEVEL);
    InvitationCode invitationCode = new InvitationCode("code");
    InvitationId invitationId = new InvitationId(UUID.randomUUID());
    Invitation invitation = Invitation.builder().id(invitationId).resourceId(resourceId).role(role).code(invitationCode).originator("originator").email("email@email.com").utcExpiredAt(getExpiredAt()).build();
    when(invitationRepository.findBy(invitationId)).thenReturn(Optional.of(invitation));
    invitatoryService.resendInvitation(invitationId);
    verify(usersDAO).resendInvitation(invitation, getExpiredAt().toInstant(ZoneOffset.UTC));
}
Also used : Role(io.imunity.furms.domain.authz.roles.Role) ResourceId(io.imunity.furms.domain.authz.roles.ResourceId) InvitationCode(io.imunity.furms.domain.invitations.InvitationCode) Invitation(io.imunity.furms.domain.invitations.Invitation) InvitationId(io.imunity.furms.domain.invitations.InvitationId) Test(org.junit.jupiter.api.Test)

Example 3 with InvitationId

use of io.imunity.furms.domain.invitations.InvitationId in project furms by unity-idm.

the class InvitatoryServiceTest method shouldNotFindInvitationAssociationWithResourceId.

@Test
void shouldNotFindInvitationAssociationWithResourceId() {
    ResourceId resourceId = new ResourceId(UUID.randomUUID(), ResourceType.SITE);
    Invitation invitation = Invitation.builder().id(new InvitationId(UUID.randomUUID())).resourceId(resourceId).build();
    when(invitationRepository.findBy(invitation.id)).thenReturn(Optional.of(invitation));
    boolean associated = invitatoryService.checkAssociation(UUID.randomUUID().toString(), invitation.id);
    assertFalse(associated);
}
Also used : ResourceId(io.imunity.furms.domain.authz.roles.ResourceId) Invitation(io.imunity.furms.domain.invitations.Invitation) InvitationId(io.imunity.furms.domain.invitations.InvitationId) Test(org.junit.jupiter.api.Test)

Example 4 with InvitationId

use of io.imunity.furms.domain.invitations.InvitationId 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);
}
Also used : Role(io.imunity.furms.domain.authz.roles.Role) ResourceId(io.imunity.furms.domain.authz.roles.ResourceId) FenixUserId(io.imunity.furms.domain.users.FenixUserId) Invitation(io.imunity.furms.domain.invitations.Invitation) FURMSUser(io.imunity.furms.domain.users.FURMSUser) InvitationId(io.imunity.furms.domain.invitations.InvitationId) PersistentId(io.imunity.furms.domain.users.PersistentId) Test(org.junit.jupiter.api.Test)

Example 5 with InvitationId

use of io.imunity.furms.domain.invitations.InvitationId in project furms by unity-idm.

the class InvitatoryServiceTest method shouldGetInvitations.

@Test
void shouldGetInvitations() {
    UUID id = UUID.randomUUID();
    Role role = Role.FENIX_ADMIN;
    Invitation invitation = Invitation.builder().id(new InvitationId(UUID.randomUUID())).build();
    when(invitationRepository.findAllBy(role, id)).thenReturn(Set.of(invitation));
    Set<Invitation> invitations = invitatoryService.getInvitations(role, id);
    assertEquals(Set.of(invitation), invitations);
}
Also used : Role(io.imunity.furms.domain.authz.roles.Role) Invitation(io.imunity.furms.domain.invitations.Invitation) UUID(java.util.UUID) InvitationId(io.imunity.furms.domain.invitations.InvitationId) Test(org.junit.jupiter.api.Test)

Aggregations

InvitationId (io.imunity.furms.domain.invitations.InvitationId)27 Test (org.junit.jupiter.api.Test)22 Invitation (io.imunity.furms.domain.invitations.Invitation)20 ResourceId (io.imunity.furms.domain.authz.roles.ResourceId)18 Role (io.imunity.furms.domain.authz.roles.Role)10 FURMSUser (io.imunity.furms.domain.users.FURMSUser)10 FenixUserId (io.imunity.furms.domain.users.FenixUserId)10 PersistentId (io.imunity.furms.domain.users.PersistentId)10 InvitationCode (io.imunity.furms.domain.invitations.InvitationCode)6 InvitationAcceptedEvent (io.imunity.furms.domain.invitations.InvitationAcceptedEvent)4 UserRoleGrantedByInvitationEvent (io.imunity.furms.domain.users.UserRoleGrantedByInvitationEvent)4 Component (com.vaadin.flow.component.Component)3 Checkbox (com.vaadin.flow.component.checkbox.Checkbox)3 DBIntegrationTest (io.imunity.furms.db.DBIntegrationTest)3 Optional (java.util.Optional)3 Set (java.util.Set)3 UUID (java.util.UUID)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3