add audit journal log for hs_office_partner

This commit is contained in:
Michael Hoennig 2022-10-13 08:34:04 +02:00
parent 472734a516
commit d77d853c80
2 changed files with 36 additions and 13 deletions

View File

@ -16,3 +16,11 @@ create table if not exists hs_office_partner
dateOfDeath date dateOfDeath date
); );
--// --//
-- ============================================================================
--changeset hs-office-partner-MAIN-TABLE-JOURNAL:1 endDelimiter:--//
-- ----------------------------------------------------------------------------
call create_journal('hs_office_partner');
--//

View File

@ -21,10 +21,7 @@ import org.springframework.test.annotation.DirtiesContext;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.HashSet; import java.util.*;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import static net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantEntity.grantDisplaysOf; import static net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantEntity.grantDisplaysOf;
import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.roleNamesOf; import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.roleNamesOf;
@ -390,6 +387,33 @@ class HsOfficePartnerRepositoryIntegrationTest 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_partner';
""");
// when
@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]");
}
@AfterEach
void cleanup() {
context("superuser-alex@hostsharing.net", null);
tempPartners.forEach(tempPartner -> {
System.out.println("DELETING temporary partner: " + tempPartner.toString());
partnerRepo.deleteByUuid(tempPartner.getUuid());
});
}
private HsOfficePartnerEntity givenSomeTemporaryPartnerBessler(final String contact) { private HsOfficePartnerEntity givenSomeTemporaryPartnerBessler(final String contact) {
return jpaAttempt.transacted(() -> { return jpaAttempt.transacted(() -> {
context("superuser-alex@hostsharing.net"); context("superuser-alex@hostsharing.net");
@ -412,15 +436,6 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTest {
return tempPartner; return tempPartner;
} }
@AfterEach
void cleanup() {
context("superuser-alex@hostsharing.net", null);
tempPartners.forEach(tempPartner -> {
System.out.println("DELETING temporary partner: " + tempPartner.toString());
partnerRepo.deleteByUuid(tempPartner.getUuid());
});
}
void exactlyThesePartnersAreReturned(final List<HsOfficePartnerEntity> actualResult, final String... partnerNames) { void exactlyThesePartnersAreReturned(final List<HsOfficePartnerEntity> actualResult, final String... partnerNames) {
assertThat(actualResult) assertThat(actualResult)
.extracting(partnerEntity -> partnerEntity.toString()) .extracting(partnerEntity -> partnerEntity.toString())