1
0

audit log with context per task instead of just transaction

This commit is contained in:
Michael Hoennig
2022-10-13 10:36:20 +02:00
parent 2506acc531
commit 560cd9cf9f
15 changed files with 58 additions and 36 deletions

View File

@@ -293,14 +293,13 @@ class HsOfficeBankAccountRepositoryIntegrationTest extends ContextBasedTest {
}).assertSuccessful().returnedValue();
}
@Test
public void auditJournalLogIsAvailable() {
// given
final var query = em.createNativeQuery("""
select c.currenttask, j.targettable, j.targetop
from tx_journal j
join tx_context c on j.txid = c.txid
join tx_context c on j.contextId = c.contextId
where targettable = 'hs_office_bankaccount';
""");
@@ -308,8 +307,9 @@ class HsOfficeBankAccountRepositoryIntegrationTest extends ContextBasedTest {
@SuppressWarnings("unchecked") final List<Object[]> customerLogEntries = query.getResultList();
// then
assertThat(customerLogEntries).map(Arrays::toString)
.contains("[creating RBAC test bankaccount First GmbH, hs_office_bankaccount, INSERT]");
assertThat(customerLogEntries).map(Arrays::toString).contains(
"[creating bankaccount test-data First GmbH, hs_office_bankaccount, INSERT]",
"[creating bankaccount test-data Second e.K., hs_office_bankaccount, INSERT]");
}
@BeforeEach

View File

@@ -271,7 +271,7 @@ class HsOfficeContactRepositoryIntegrationTest extends ContextBasedTest {
final var query = em.createNativeQuery("""
select c.currenttask, j.targettable, j.targetop
from tx_journal j
join tx_context c on j.txid = c.txid
join tx_context c on j.contextId = c.contextId
where targettable = 'hs_office_contact';
""");
@@ -279,8 +279,9 @@ class HsOfficeContactRepositoryIntegrationTest extends ContextBasedTest {
@SuppressWarnings("unchecked") final List<Object[]> customerLogEntries = query.getResultList();
// then
assertThat(customerLogEntries).map(Arrays::toString)
.contains("[creating RBAC test contact first contact, hs_office_contact, INSERT]");
assertThat(customerLogEntries).map(Arrays::toString).contains(
"[creating contact test-data first contact, hs_office_contact, INSERT]",
"[creating contact test-data second contact, hs_office_contact, INSERT]");
}
private HsOfficeContactEntity givenSomeTemporaryContact(

View File

@@ -438,7 +438,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTest {
final var query = em.createNativeQuery("""
select c.currenttask, j.targettable, j.targetop
from tx_journal j
join tx_context c on j.txid = c.txid
join tx_context c on j.contextId = c.contextId
where targettable = 'hs_office_debitor';
""");
@@ -446,8 +446,9 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTest {
@SuppressWarnings("unchecked") final List<Object[]> customerLogEntries = query.getResultList();
// then
assertThat(customerLogEntries).map(Arrays::toString)
.contains("[creating RBAC test debitor FirstGmbH-firstcontact, hs_office_debitor, INSERT]");
assertThat(customerLogEntries).map(Arrays::toString).contains(
"[creating debitor test-data FirstGmbH-firstcontact, hs_office_debitor, INSERT]",
"[creating debitor test-data Seconde.K.-secondcontact, hs_office_debitor, INSERT]");
}
private HsOfficePartnerEntity rawReference(final HsOfficePartnerEntity givenPartner) {

View File

@@ -393,7 +393,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTest {
final var query = em.createNativeQuery("""
select c.currenttask, j.targettable, j.targetop
from tx_journal j
join tx_context c on j.txid = c.txid
join tx_context c on j.contextId = c.contextId
where targettable = 'hs_office_partner';
""");
@@ -401,8 +401,9 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTest {
@SuppressWarnings("unchecked") final List<Object[]> customerLogEntries = query.getResultList();
// then
assertThat(customerLogEntries).map(Arrays::toString)
.contains("[creating RBAC test partner FirstGmbH-firstcontact, hs_office_partner, INSERT]");
assertThat(customerLogEntries).map(Arrays::toString).contains(
"[creating partner test-data FirstGmbH-firstcontact, hs_office_partner, INSERT]",
"[creating partner test-data Seconde.K.-secondcontact, hs_office_partner, INSERT]");
}
@AfterEach

View File

@@ -3,9 +3,7 @@ package net.hostsharing.hsadminng.hs.office.person;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.context.ContextBasedTest;
import net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantRepository;
import net.hostsharing.hsadminng.rbac.rbacgrant.RbacGrantRepository;
import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository;
import net.hostsharing.hsadminng.rbac.rbacrole.RbacRoleRepository;
import net.hostsharing.test.Array;
import net.hostsharing.test.JpaAttempt;
import org.junit.jupiter.api.AfterEach;
@@ -272,7 +270,7 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTest {
final var query = em.createNativeQuery("""
select c.currenttask, j.targettable, j.targetop
from tx_journal j
join tx_context c on j.txid = c.txid
join tx_context c on j.contextId = c.contextId
where targettable = 'hs_office_person';
""");
@@ -280,8 +278,9 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTest {
@SuppressWarnings("unchecked") final List<Object[]> customerLogEntries = query.getResultList();
// then
assertThat(customerLogEntries).map(Arrays::toString)
.contains("[creating RBAC test person First GmbH, hs_office_person, INSERT]");
assertThat(customerLogEntries).map(Arrays::toString).contains(
"[creating person test-data First GmbH, hs_office_person, INSERT]",
"[creating person test-data Second e.K., Sandra, Miller, hs_office_person, INSERT]");
}
@AfterEach

View File

@@ -26,7 +26,6 @@ import static net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantEntity.grantD
import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.roleNamesOf;
import static net.hostsharing.test.JpaAttempt.attempt;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assumptions.assumeThat;
@DataJpaTest
@ComponentScan(basePackageClasses = { HsOfficeRelationshipRepository.class, Context.class, JpaAttempt.class })
@@ -373,7 +372,7 @@ class HsOfficeRelationshipRepositoryIntegrationTest extends ContextBasedTest {
final var query = em.createNativeQuery("""
select c.currenttask, j.targettable, j.targetop
from tx_journal j
join tx_context c on j.txid = c.txid
join tx_context c on j.contextId = c.contextId
where targettable = 'hs_office_relationship';
""");
@@ -381,8 +380,9 @@ class HsOfficeRelationshipRepositoryIntegrationTest extends ContextBasedTest {
@SuppressWarnings("unchecked") final List<Object[]> customerLogEntries = query.getResultList();
// then
assertThat(customerLogEntries).map(Arrays::toString)
.contains("[creating RBAC test relationship FirstGmbH-Smith, hs_office_relationship, INSERT]");
assertThat(customerLogEntries).map(Arrays::toString).contains(
"[creating relationship test-data FirstGmbH-Smith, hs_office_relationship, INSERT]",
"[creating relationship test-data Seconde.K.-Smith, hs_office_relationship, INSERT]");
}
private HsOfficeRelationshipEntity givenSomeTemporaryRelationshipBessler(final String holderPerson, final String contact) {