From 472734a516da10b5262b9f47ee104ba953c30b50 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Thu, 13 Oct 2022 08:23:08 +0200 Subject: [PATCH] add audit journal log for hs_office_person --- .../db/changelog/210-hs-office-person.sql | 8 ++++++++ ...OfficePersonRepositoryIntegrationTest.java | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/main/resources/db/changelog/210-hs-office-person.sql b/src/main/resources/db/changelog/210-hs-office-person.sql index 09aff623..946a205e 100644 --- a/src/main/resources/db/changelog/210-hs-office-person.sql +++ b/src/main/resources/db/changelog/210-hs-office-person.sql @@ -17,3 +17,11 @@ create table if not exists hs_office_person familyName varchar(48) ); --// + + +-- ============================================================================ +--changeset hs-office-person-MAIN-TABLE-JOURNAL:1 endDelimiter:--// +-- ---------------------------------------------------------------------------- + +call create_journal('hs_office_person'); +--// diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRepositoryIntegrationTest.java index 745f7482..aef0afb9 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRepositoryIntegrationTest.java @@ -20,6 +20,7 @@ import org.springframework.test.annotation.DirtiesContext; import javax.persistence.EntityManager; import javax.servlet.http.HttpServletRequest; +import java.util.Arrays; import java.util.List; import java.util.function.Supplier; @@ -265,6 +266,24 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTest { } } + @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 + where targettable = 'hs_office_person'; + """); + + // when + @SuppressWarnings("unchecked") final List customerLogEntries = query.getResultList(); + + // then + assertThat(customerLogEntries).map(Arrays::toString) + .contains("[creating RBAC test person First GmbH, hs_office_person, INSERT]"); + } + @AfterEach void cleanup() { context("superuser-alex@hostsharing.net", null);