Search in sources :

Example 1 with SystemConfigurationAuditType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationAuditType in project midpoint by Evolveum.

the class AuditDeltaOperationResultTest method test140StoringCleanedUpSuccessResults.

@Test
public void test140StoringCleanedUpSuccessResults() throws Exception {
    // this is like default without any settings
    OperationResult result = createOperationResult();
    given("clear audit and audit configuration set to TOP");
    clearAudit();
    auditService.applyAuditConfiguration(new SystemConfigurationAuditType(prismContext).eventRecording(new SystemConfigurationAuditEventRecordingType(prismContext).deltaSuccessExecutionResult(OperationResultDetailLevel.CLEANED_UP)));
    when("audit event with delta operation executions is stored");
    createAuditRecordWithDeltas(result);
    then("success result for delta preserved completely");
    QAuditEventRecord a = QAuditEventRecordMapping.get().defaultAlias();
    assertThat(selectOne(a)).isNotNull();
    QAuditDelta d = QAuditDeltaMapping.get().defaultAlias();
    List<MAuditDelta> deltaRows = select(d);
    assertThat(deltaRows).hasSize(2).extracting(row -> (OperationResultType) parseFullObject(row.fullResult)).anyMatch(ort -> // warning is preserved fully
    ort.getPartialResults().size() == 3 && ort.getStatus() == OperationResultStatusType.WARNING).anyMatch(ort -> ort.getPartialResults().size() == 2 && ort.getStatus() == OperationResultStatusType.SUCCESS);
}
Also used : AfterClass(org.testng.annotations.AfterClass) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Test(org.testng.annotations.Test) com.evolveum.midpoint.repo.sqale.audit.qmodel(com.evolveum.midpoint.repo.sqale.audit.qmodel) UUID(java.util.UUID) NullTaskImpl(com.evolveum.midpoint.task.api.test.NullTaskImpl) Collectors(java.util.stream.Collectors) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) OperationResultStatus(com.evolveum.midpoint.schema.result.OperationResultStatus) List(java.util.List) InstanceOfAssertFactory(org.assertj.core.api.InstanceOfAssertFactory) ListAssert(org.assertj.core.api.ListAssert) Assertions(org.assertj.core.api.Assertions) ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation) NotNull(org.jetbrains.annotations.NotNull) AuditEventRecord(com.evolveum.midpoint.audit.api.AuditEventRecord) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 2 with SystemConfigurationAuditType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationAuditType in project midpoint by Evolveum.

the class AuditDeltaOperationResultTest method test130StoringOnlyTopSuccessResults.

@Test
public void test130StoringOnlyTopSuccessResults() throws Exception {
    OperationResult result = createOperationResult();
    given("clear audit and audit configuration set to TOP");
    clearAudit();
    auditService.applyAuditConfiguration(new SystemConfigurationAuditType(prismContext).eventRecording(new SystemConfigurationAuditEventRecordingType(prismContext).deltaSuccessExecutionResult(OperationResultDetailLevel.TOP)));
    when("audit event with delta operation executions is stored");
    createAuditRecordWithDeltas(result);
    then("success result for delta preserved completely");
    QAuditEventRecord a = QAuditEventRecordMapping.get().defaultAlias();
    assertThat(selectOne(a)).isNotNull();
    QAuditDelta d = QAuditDeltaMapping.get().defaultAlias();
    List<MAuditDelta> deltaRows = select(d);
    assertThat(deltaRows).hasSize(2).extracting(row -> (OperationResultType) parseFullObject(row.fullResult)).anyMatch(ort -> // warning is preserved fully
    ort.getPartialResults().size() == 3 && ort.getStatus() == OperationResultStatusType.WARNING).anyMatch(ort -> // no subresults for success
    ort.getPartialResults().isEmpty() && ort.getStatus() == OperationResultStatusType.SUCCESS);
}
Also used : AfterClass(org.testng.annotations.AfterClass) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Test(org.testng.annotations.Test) com.evolveum.midpoint.repo.sqale.audit.qmodel(com.evolveum.midpoint.repo.sqale.audit.qmodel) UUID(java.util.UUID) NullTaskImpl(com.evolveum.midpoint.task.api.test.NullTaskImpl) Collectors(java.util.stream.Collectors) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) OperationResultStatus(com.evolveum.midpoint.schema.result.OperationResultStatus) List(java.util.List) InstanceOfAssertFactory(org.assertj.core.api.InstanceOfAssertFactory) ListAssert(org.assertj.core.api.ListAssert) Assertions(org.assertj.core.api.Assertions) ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation) NotNull(org.jetbrains.annotations.NotNull) AuditEventRecord(com.evolveum.midpoint.audit.api.AuditEventRecord) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 3 with SystemConfigurationAuditType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationAuditType in project midpoint by Evolveum.

the class AuditDeltaOperationResultTest method test120StoringNoneSuccessResults.

@Test
public void test120StoringNoneSuccessResults() throws Exception {
    OperationResult result = createOperationResult();
    given("clear audit and audit configuration set to NONE");
    clearAudit();
    auditService.applyAuditConfiguration(new SystemConfigurationAuditType(prismContext).eventRecording(new SystemConfigurationAuditEventRecordingType(prismContext).deltaSuccessExecutionResult(OperationResultDetailLevel.NONE)));
    when("audit event with delta operation executions is stored");
    createAuditRecordWithDeltas(result);
    then("success result for delta preserved completely");
    QAuditEventRecord a = QAuditEventRecordMapping.get().defaultAlias();
    assertThat(selectOne(a)).isNotNull();
    QAuditDelta d = QAuditDeltaMapping.get().defaultAlias();
    List<MAuditDelta> deltaRows = select(d);
    assertThat(deltaRows).hasSize(2).anyMatch(row -> row.fullResult == null && row.status == OperationResultStatusType.SUCCESS).filteredOn(row -> row.fullResult != null).extracting(row -> (OperationResultType) parseFullObject(row.fullResult)).singleElement().matches(ort -> // warning is preserved fully
    ort.getPartialResults().size() == 3 && ort.getStatus() == OperationResultStatusType.WARNING);
}
Also used : AfterClass(org.testng.annotations.AfterClass) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Test(org.testng.annotations.Test) com.evolveum.midpoint.repo.sqale.audit.qmodel(com.evolveum.midpoint.repo.sqale.audit.qmodel) UUID(java.util.UUID) NullTaskImpl(com.evolveum.midpoint.task.api.test.NullTaskImpl) Collectors(java.util.stream.Collectors) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) OperationResultStatus(com.evolveum.midpoint.schema.result.OperationResultStatus) List(java.util.List) InstanceOfAssertFactory(org.assertj.core.api.InstanceOfAssertFactory) ListAssert(org.assertj.core.api.ListAssert) Assertions(org.assertj.core.api.Assertions) ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation) NotNull(org.jetbrains.annotations.NotNull) AuditEventRecord(com.evolveum.midpoint.audit.api.AuditEventRecord) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 4 with SystemConfigurationAuditType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationAuditType in project midpoint by Evolveum.

the class AuditDeltaOperationResultTest method test110StoringFullSuccessResults.

@Test
public void test110StoringFullSuccessResults() throws Exception {
    OperationResult result = createOperationResult();
    given("clear audit and audit configuration set to FULL");
    clearAudit();
    auditService.applyAuditConfiguration(new SystemConfigurationAuditType(prismContext).eventRecording(new SystemConfigurationAuditEventRecordingType(prismContext).deltaSuccessExecutionResult(OperationResultDetailLevel.FULL)));
    when("audit event with delta operation executions is stored");
    createAuditRecordWithDeltas(result);
    then("success result for delta preserved completely");
    QAuditEventRecord a = QAuditEventRecordMapping.get().defaultAlias();
    assertThat(selectOne(a)).isNotNull();
    QAuditDelta d = QAuditDeltaMapping.get().defaultAlias();
    List<MAuditDelta> deltaRows = select(d);
    assertThat(deltaRows).hasSize(2).extracting(row -> (OperationResultType) parseFullObject(row.fullResult)).allMatch(// both results have all subresults
    ort -> ort.getPartialResults().size() == 3);
}
Also used : AfterClass(org.testng.annotations.AfterClass) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Test(org.testng.annotations.Test) com.evolveum.midpoint.repo.sqale.audit.qmodel(com.evolveum.midpoint.repo.sqale.audit.qmodel) UUID(java.util.UUID) NullTaskImpl(com.evolveum.midpoint.task.api.test.NullTaskImpl) Collectors(java.util.stream.Collectors) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) OperationResultStatus(com.evolveum.midpoint.schema.result.OperationResultStatus) List(java.util.List) InstanceOfAssertFactory(org.assertj.core.api.InstanceOfAssertFactory) ListAssert(org.assertj.core.api.ListAssert) Assertions(org.assertj.core.api.Assertions) ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation) NotNull(org.jetbrains.annotations.NotNull) AuditEventRecord(com.evolveum.midpoint.audit.api.AuditEventRecord) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Aggregations

AuditEventRecord (com.evolveum.midpoint.audit.api.AuditEventRecord)4 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)4 SqaleRepoBaseTest (com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)4 com.evolveum.midpoint.repo.sqale.audit.qmodel (com.evolveum.midpoint.repo.sqale.audit.qmodel)4 ObjectDeltaOperation (com.evolveum.midpoint.schema.ObjectDeltaOperation)4 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)4 OperationResultStatus (com.evolveum.midpoint.schema.result.OperationResultStatus)4 NullTaskImpl (com.evolveum.midpoint.task.api.test.NullTaskImpl)4 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)4 com.evolveum.midpoint.xml.ns._public.common.common_3 (com.evolveum.midpoint.xml.ns._public.common.common_3)4 List (java.util.List)4 UUID (java.util.UUID)4 Collectors (java.util.stream.Collectors)4 Assertions (org.assertj.core.api.Assertions)4 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)4 InstanceOfAssertFactory (org.assertj.core.api.InstanceOfAssertFactory)4 ListAssert (org.assertj.core.api.ListAssert)4 NotNull (org.jetbrains.annotations.NotNull)4 AfterClass (org.testng.annotations.AfterClass)4 Test (org.testng.annotations.Test)4