use of io.imunity.furms.domain.sites.Site in project furms by unity-idm.
the class PolicyDocumentServiceImplTest method shouldSendUpdateSitePolicyDocument.
@Test
void shouldSendUpdateSitePolicyDocument() {
PolicyId policyId = new PolicyId(UUID.randomUUID());
SiteExternalId externalId = new SiteExternalId("id");
PolicyDocument policyDocument = PolicyDocument.builder().id(policyId).siteId("siteId").build();
Site site = Site.builder().policyId(policyId).externalId(externalId).build();
when(repository.update(policyDocument, true)).thenReturn(policyId);
when(repository.findById(policyId)).thenReturn(Optional.of(policyDocument));
when(siteRepository.findById("siteId")).thenReturn(Optional.of(site));
service.updateWithRevision(policyDocument);
Mockito.verify(siteAgentPolicyDocumentService).updatePolicyDocument(externalId, policyDocument);
}
use of io.imunity.furms.domain.sites.Site in project furms by unity-idm.
the class PolicyDocumentServiceImplTest method shouldUpdateUsersPolicyAcceptances.
@Test
void shouldUpdateUsersPolicyAcceptances() {
FenixUserId userId = new FenixUserId("userId");
PolicyId policyId = new PolicyId(UUID.randomUUID());
PolicyAcceptance policyAcceptance = PolicyAcceptance.builder().policyDocumentId(policyId).policyDocumentRevision(1).build();
FURMSUser furmsUser = FURMSUser.builder().email("email").fenixUserId(userId).build();
PolicyDocument policyDocument = PolicyDocument.builder().id((policyId)).siteId("siteId").revision(1).build();
Site site = Site.builder().id("siteId").externalId(new SiteExternalId("id")).build();
AssignedPolicyDocument servicePolicyDocument = AssignedPolicyDocument.builder().build();
when(usersDAO.findById(userId)).thenReturn(Optional.of(furmsUser));
when(repository.findById(policyId)).thenReturn(Optional.of(policyDocument));
when(repository.findAllAssignPoliciesBySiteId("siteId")).thenReturn(Set.of(servicePolicyDocument));
when(siteRepository.findById("siteId")).thenReturn(Optional.of(site));
when(userRepository.isUserInstalledOnSite(userId, "siteId")).thenReturn(true);
when(policyDocumentDAO.getPolicyAcceptances(userId)).thenReturn(Set.of(policyAcceptance));
service.addUserPolicyAcceptance("siteId", userId, policyAcceptance);
Mockito.verify(siteAgentPolicyDocumentService).updateUsersPolicyAcceptances(site.getExternalId(), new UserPolicyAcceptancesWithServicePolicies(furmsUser, Set.of(policyAcceptance), Optional.empty(), Set.of(servicePolicyDocument)));
}
use of io.imunity.furms.domain.sites.Site in project furms by unity-idm.
the class SiteAuditLogServiceIntegrationTest method shouldDetectSupportAddition.
@Test
void shouldDetectSupportAddition() {
// given
String siteId = UUID.randomUUID().toString();
PersistentId userId = new PersistentId("userId");
Site site = Site.builder().name("name").build();
when(repository.findById(siteId)).thenReturn(Optional.of(site));
when(usersDAO.findById(userId)).thenReturn(Optional.of(FURMSUser.builder().id(userId).email("email").build()));
// when
service.addSupport(siteId, userId);
// then
ArgumentCaptor<AuditLog> argument = ArgumentCaptor.forClass(AuditLog.class);
Mockito.verify(auditLogRepository).create(argument.capture());
assertEquals(Operation.ROLE_ASSIGNMENT, argument.getValue().operationCategory);
assertEquals(Action.GRANT, argument.getValue().action);
}
use of io.imunity.furms.domain.sites.Site in project furms by unity-idm.
the class SiteAuditLogServiceIntegrationTest method shouldDetectUserRemoval.
@Test
void shouldDetectUserRemoval() {
// given
String siteId = UUID.randomUUID().toString();
PersistentId userId = new PersistentId("userId");
Site site = Site.builder().name("name").build();
when(service.findById(siteId)).thenReturn(Optional.of(site));
when(usersDAO.findById(userId)).thenReturn(Optional.of(FURMSUser.builder().id(userId).email("email").build()));
// when
service.removeSiteUser(siteId, userId);
ArgumentCaptor<AuditLog> argument = ArgumentCaptor.forClass(AuditLog.class);
Mockito.verify(auditLogRepository).create(argument.capture());
assertEquals(Operation.ROLE_ASSIGNMENT, argument.getValue().operationCategory);
assertEquals(Action.REVOKE, argument.getValue().action);
}
use of io.imunity.furms.domain.sites.Site in project furms by unity-idm.
the class SiteAuditLogServiceIntegrationTest method shouldDetectInfraServiceCreation.
@Test
void shouldDetectInfraServiceCreation() {
// given
Site request = Site.builder().id("id").name("name").build();
when(repository.isNamePresent(request.getName())).thenReturn(false);
when(repository.create(eq(request), any())).thenReturn(request.getId());
when(repository.findById(request.getId())).thenReturn(Optional.of(request));
// when
service.create(request);
ArgumentCaptor<AuditLog> argument = ArgumentCaptor.forClass(AuditLog.class);
Mockito.verify(auditLogRepository).create(argument.capture());
assertEquals(Operation.SITES_MANAGEMENT, argument.getValue().operationCategory);
assertEquals(Action.CREATE, argument.getValue().action);
}
Aggregations