Search in sources :

Example 1 with PolicyDocument

use of io.imunity.furms.domain.policy_documents.PolicyDocument 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 2 with PolicyDocument

use of io.imunity.furms.domain.policy_documents.PolicyDocument 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 3 with PolicyDocument

use of io.imunity.furms.domain.policy_documents.PolicyDocument 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)

Example 4 with PolicyDocument

use of io.imunity.furms.domain.policy_documents.PolicyDocument in project furms by unity-idm.

the class PolicyDocumentAuditLogServiceIntegrationTest method shouldDetectPolicyDocumentDeletion.

@Test
void shouldDetectPolicyDocumentDeletion() {
    PolicyId policyId = new PolicyId(UUID.randomUUID());
    PolicyDocument policyDocument = PolicyDocument.builder().id(policyId).build();
    when(repository.findById(policyId)).thenReturn(Optional.of(policyDocument));
    service.delete("siteId", policyId);
    ArgumentCaptor<AuditLog> argument = ArgumentCaptor.forClass(AuditLog.class);
    Mockito.verify(auditLogRepository).create(argument.capture());
    assertEquals(Operation.POLICY_DOCUMENTS_MANAGEMENT, argument.getValue().operationCategory);
    assertEquals(Action.DELETE, 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 PolicyDocument

use of io.imunity.furms.domain.policy_documents.PolicyDocument in project furms by unity-idm.

the class PolicyDocumentServiceImplTest method shouldUpdate.

@Test
void shouldUpdate() {
    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);
    orderVerifier.verify(validator).validateUpdate(policyDocument);
    orderVerifier.verify(repository).update(policyDocument, false);
    orderVerifier.verify(publisher).publishEvent(new PolicyDocumentUpdatedEvent(policyDocument, policyDocument));
}
Also used : PolicyDocumentUpdatedEvent(io.imunity.furms.domain.policy_documents.PolicyDocumentUpdatedEvent) PolicyDocument(io.imunity.furms.domain.policy_documents.PolicyDocument) AssignedPolicyDocument(io.imunity.furms.domain.policy_documents.AssignedPolicyDocument) PolicyId(io.imunity.furms.domain.policy_documents.PolicyId) Test(org.junit.jupiter.api.Test)

Aggregations

PolicyDocument (io.imunity.furms.domain.policy_documents.PolicyDocument)74 PolicyId (io.imunity.furms.domain.policy_documents.PolicyId)57 Test (org.junit.jupiter.api.Test)52 AssignedPolicyDocument (io.imunity.furms.domain.policy_documents.AssignedPolicyDocument)23 FenixUserId (io.imunity.furms.domain.users.FenixUserId)21 PolicyAcceptance (io.imunity.furms.domain.policy_documents.PolicyAcceptance)19 Site (io.imunity.furms.domain.sites.Site)17 SiteExternalId (io.imunity.furms.domain.sites.SiteExternalId)17 SiteId (io.imunity.furms.domain.sites.SiteId)13 FURMSUser (io.imunity.furms.domain.users.FURMSUser)13 PersistentId (io.imunity.furms.domain.users.PersistentId)12 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)12 UserAcceptedPolicyEvent (io.imunity.furms.domain.policy_documents.UserAcceptedPolicyEvent)11 InfraService (io.imunity.furms.domain.services.InfraService)11 FurmsAuthorize (io.imunity.furms.core.config.security.method.FurmsAuthorize)8 Optional (java.util.Optional)7 AuditLogServiceImplTest (io.imunity.furms.core.audit_log.AuditLogServiceImplTest)6 DBIntegrationTest (io.imunity.furms.db.DBIntegrationTest)6 AuditLog (io.imunity.furms.domain.audit_log.AuditLog)6 LocalDateTime (java.time.LocalDateTime)6