Search in sources :

Example 1 with AuditLog

use of io.imunity.furms.domain.audit_log.AuditLog in project furms by unity-idm.

the class GenericGroupAuditLogServiceIntegrationTest method shouldDetectGroupUpdate.

@Test
void shouldDetectGroupUpdate() {
    GenericGroupId genericGroupId = new GenericGroupId(UUID.randomUUID());
    GenericGroup genericGroup = GenericGroup.builder().id(genericGroupId).communityId("communityId").name("name").description("description").build();
    when(genericGroupRepository.findBy(genericGroupId)).thenReturn(Optional.of(genericGroup));
    service.update(genericGroup);
    ArgumentCaptor<AuditLog> argument = ArgumentCaptor.forClass(AuditLog.class);
    Mockito.verify(auditLogRepository).create(argument.capture());
    assertEquals(Operation.GENERIC_GROUPS_MANAGEMENT, argument.getValue().operationCategory);
    assertEquals(Action.UPDATE, argument.getValue().action);
}
Also used : GenericGroupId(io.imunity.furms.domain.generic_groups.GenericGroupId) GenericGroup(io.imunity.furms.domain.generic_groups.GenericGroup) AuditLog(io.imunity.furms.domain.audit_log.AuditLog) AuditLogServiceImplTest(io.imunity.furms.core.audit_log.AuditLogServiceImplTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with AuditLog

use of io.imunity.furms.domain.audit_log.AuditLog in project furms by unity-idm.

the class GenericGroupAuditLogServiceIntegrationTest method shouldDetectGroupDeletion.

@Test
void shouldDetectGroupDeletion() {
    GenericGroupId groupId = new GenericGroupId(UUID.randomUUID());
    when(genericGroupRepository.existsBy("communityId", groupId)).thenReturn(true);
    GenericGroup genericGroup = GenericGroup.builder().id(groupId).build();
    when(genericGroupRepository.findBy(groupId)).thenReturn(Optional.of(genericGroup));
    service.delete("communityId", groupId);
    ArgumentCaptor<AuditLog> argument = ArgumentCaptor.forClass(AuditLog.class);
    Mockito.verify(auditLogRepository).create(argument.capture());
    assertEquals(Operation.GENERIC_GROUPS_MANAGEMENT, argument.getValue().operationCategory);
    assertEquals(Action.DELETE, argument.getValue().action);
}
Also used : GenericGroupId(io.imunity.furms.domain.generic_groups.GenericGroupId) GenericGroup(io.imunity.furms.domain.generic_groups.GenericGroup) AuditLog(io.imunity.furms.domain.audit_log.AuditLog) AuditLogServiceImplTest(io.imunity.furms.core.audit_log.AuditLogServiceImplTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with AuditLog

use of io.imunity.furms.domain.audit_log.AuditLog in project furms by unity-idm.

the class PolicyDocumentAuditLogServiceIntegrationTest method shouldDetectPolicyDocumentCreation.

@Test
void shouldDetectPolicyDocumentCreation() {
    PolicyId policyId = new PolicyId(UUID.randomUUID());
    PolicyDocument policyDocument = PolicyDocument.builder().id(policyId).build();
    when(repository.create(policyDocument)).thenReturn(policyId);
    when(repository.findById(policyId)).thenReturn(Optional.of(policyDocument));
    service.create(policyDocument);
    ArgumentCaptor<AuditLog> argument = ArgumentCaptor.forClass(AuditLog.class);
    Mockito.verify(auditLogRepository).create(argument.capture());
    assertEquals(Operation.POLICY_DOCUMENTS_MANAGEMENT, argument.getValue().operationCategory);
    assertEquals(Action.CREATE, argument.getValue().action);
}
Also used : PolicyDocument(io.imunity.furms.domain.policy_documents.PolicyDocument) PolicyId(io.imunity.furms.domain.policy_documents.PolicyId) AuditLog(io.imunity.furms.domain.audit_log.AuditLog) AuditLogServiceImplTest(io.imunity.furms.core.audit_log.AuditLogServiceImplTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with AuditLog

use of io.imunity.furms.domain.audit_log.AuditLog in project furms by unity-idm.

the class PolicyDocumentAuditLogServiceIntegrationTest method shouldDetectPolicyDocumentUpdate.

@Test
void shouldDetectPolicyDocumentUpdate() {
    PolicyId policyId = new PolicyId(UUID.randomUUID());
    PolicyDocument policyDocument = PolicyDocument.builder().id(policyId).build();
    when(repository.findById(policyId)).thenReturn(Optional.of(policyDocument));
    when(repository.update(policyDocument, false)).thenReturn(policyId);
    service.update(policyDocument);
    ArgumentCaptor<AuditLog> argument = ArgumentCaptor.forClass(AuditLog.class);
    Mockito.verify(auditLogRepository).create(argument.capture());
    assertEquals(Operation.POLICY_DOCUMENTS_MANAGEMENT, argument.getValue().operationCategory);
    assertEquals(Action.UPDATE, argument.getValue().action);
}
Also used : PolicyDocument(io.imunity.furms.domain.policy_documents.PolicyDocument) PolicyId(io.imunity.furms.domain.policy_documents.PolicyId) AuditLog(io.imunity.furms.domain.audit_log.AuditLog) AuditLogServiceImplTest(io.imunity.furms.core.audit_log.AuditLogServiceImplTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with AuditLog

use of io.imunity.furms.domain.audit_log.AuditLog in project furms by unity-idm.

the class PolicyDocumentAuditLogServiceIntegrationTest method shouldDetectPolicyDocumentAcceptation.

@Test
void shouldDetectPolicyDocumentAcceptation() {
    FenixUserId userId = new FenixUserId("userId");
    PolicyId policyId = new PolicyId(UUID.randomUUID());
    PolicyDocument policyDocument = PolicyDocument.builder().id(policyId).revision(1).siteId("siteId").build();
    PolicyAcceptance policyAcceptance = PolicyAcceptance.builder().policyDocumentId(policyId).policyDocumentRevision(1).build();
    FURMSUser user = FURMSUser.builder().id(new PersistentId("id")).email("email").fenixUserId(userId).build();
    when(usersDAO.findById(userId)).thenReturn(Optional.of(user));
    when(repository.findById(policyId)).thenReturn(Optional.of(policyDocument));
    service.addUserPolicyAcceptance("siteId", userId, policyAcceptance);
    ArgumentCaptor<AuditLog> argument = ArgumentCaptor.forClass(AuditLog.class);
    Mockito.verify(auditLogRepository).create(argument.capture());
    assertEquals(Operation.POLICY_ACCEPTANCE, argument.getValue().operationCategory);
    assertEquals(Action.ACCEPT, argument.getValue().action);
}
Also used : PolicyAcceptance(io.imunity.furms.domain.policy_documents.PolicyAcceptance) FenixUserId(io.imunity.furms.domain.users.FenixUserId) PolicyDocument(io.imunity.furms.domain.policy_documents.PolicyDocument) FURMSUser(io.imunity.furms.domain.users.FURMSUser) PolicyId(io.imunity.furms.domain.policy_documents.PolicyId) AuditLog(io.imunity.furms.domain.audit_log.AuditLog) PersistentId(io.imunity.furms.domain.users.PersistentId) AuditLogServiceImplTest(io.imunity.furms.core.audit_log.AuditLogServiceImplTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

AuditLog (io.imunity.furms.domain.audit_log.AuditLog)104 Test (org.junit.jupiter.api.Test)57 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)56 AuditLogServiceImplTest (io.imunity.furms.core.audit_log.AuditLogServiceImplTest)51 FURMSUser (io.imunity.furms.domain.users.FURMSUser)51 AuditLogEvent (io.imunity.furms.domain.audit_log.AuditLogEvent)48 EventListener (org.springframework.context.event.EventListener)47 PersistentId (io.imunity.furms.domain.users.PersistentId)24 RoleAssignmentAuditLogServiceTest (io.imunity.furms.core.users.audit_log.RoleAssignmentAuditLogServiceTest)18 FenixUserId (io.imunity.furms.domain.users.FenixUserId)13 Project (io.imunity.furms.domain.projects.Project)7 Site (io.imunity.furms.domain.sites.Site)7 BigDecimal (java.math.BigDecimal)7 PolicyDocument (io.imunity.furms.domain.policy_documents.PolicyDocument)6 PolicyId (io.imunity.furms.domain.policy_documents.PolicyId)6 DBIntegrationTest (io.imunity.furms.db.DBIntegrationTest)5 Community (io.imunity.furms.domain.communities.Community)5 GenericGroupId (io.imunity.furms.domain.generic_groups.GenericGroupId)5 LocalDateTime (java.time.LocalDateTime)5 UUID (java.util.UUID)5