From a67c57be9d8069c6b2f9873ae39573bb7e21b583 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 15 Jan 2025 15:00:01 +0100 Subject: [PATCH 01/18] introduce Liquibase-Contexts booking, hosting, rbactest, etc. --- .../db/changelog/db.changelog-master.yaml | 43 ++++++++++++++++++- src/test/resources/application.yml | 2 +- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/main/resources/db/changelog/db.changelog-master.yaml b/src/main/resources/db/changelog/db.changelog-master.yaml index b97e3f2d..778bbcfe 100644 --- a/src/main/resources/db/changelog/db.changelog-master.yaml +++ b/src/main/resources/db/changelog/db.changelog-master.yaml @@ -29,6 +29,7 @@ databaseChangeLog: file: db/changelog/0-base/030-historization.sql - include: file: db/changelog/0-base/090-log-slow-queries-extensions.sql + - include: file: db/changelog/1-rbac/1000-rbac-schema.sql - include: @@ -49,26 +50,38 @@ databaseChangeLog: file: db/changelog/1-rbac/1059-rbac-statistics.sql - include: file: db/changelog/1-rbac/1080-rbac-global.sql + - include: file: db/changelog/2-rbactest/200-rbactest-schema.sql + context: rbac-test - include: file: db/changelog/2-rbactest/201-rbactest-customer/2010-rbactest-customer.sql + context: rbac-test - include: file: db/changelog/2-rbactest/201-rbactest-customer/2013-rbactest-customer-rbac.sql + context: rbac-test - include: file: db/changelog/2-rbactest/201-rbactest-customer/2018-rbactest-customer-test-data.sql + context: rbac-test - include: file: db/changelog/2-rbactest/202-rbactest-package/2020-rbactest-package.sql + context: rbac-test - include: file: db/changelog/2-rbactest/202-rbactest-package/2023-rbactest-package-rbac.sql + context: rbac-test - include: file: db/changelog/2-rbactest/202-rbactest-package/2028-rbactest-package-test-data.sql + context: rbac-test - include: file: db/changelog/2-rbactest/203-rbactest-domain/2030-rbactest-domain.sql + context: rbac-test - include: file: db/changelog/2-rbactest/203-rbactest-domain/2033-rbactest-domain-rbac.sql + context: rbac-test - include: file: db/changelog/2-rbactest/203-rbactest-domain/2038-rbactest-domain-test-data.sql + context: rbac-test + - include: file: db/changelog/5-hs-office/500-hs-office-schema.sql - include: @@ -79,18 +92,21 @@ databaseChangeLog: file: db/changelog/5-hs-office/501-contact/5016-hs-office-contact-migration.sql - include: file: db/changelog/5-hs-office/501-contact/5018-hs-office-contact-test-data.sql + context: office-test - include: file: db/changelog/5-hs-office/502-person/5020-hs-office-person.sql - include: file: db/changelog/5-hs-office/502-person/5023-hs-office-person-rbac.sql - include: file: db/changelog/5-hs-office/502-person/5028-hs-office-person-test-data.sql + context: office-test - include: file: db/changelog/5-hs-office/503-relation/5030-hs-office-relation.sql - include: file: db/changelog/5-hs-office/503-relation/5033-hs-office-relation-rbac.sql - include: file: db/changelog/5-hs-office/503-relation/5038-hs-office-relation-test-data.sql + context: office-test - include: file: db/changelog/5-hs-office/504-partner/5040-hs-office-partner.sql - include: @@ -101,18 +117,21 @@ databaseChangeLog: file: db/changelog/5-hs-office/504-partner/5046-hs-office-partner-migration.sql - include: file: db/changelog/5-hs-office/504-partner/5048-hs-office-partner-test-data.sql + context: office-test - include: file: db/changelog/5-hs-office/505-bankaccount/5050-hs-office-bankaccount.sql - include: file: db/changelog/5-hs-office/505-bankaccount/5053-hs-office-bankaccount-rbac.sql - include: file: db/changelog/5-hs-office/505-bankaccount/5058-hs-office-bankaccount-test-data.sql + context: office-test - include: file: db/changelog/5-hs-office/506-debitor/5060-hs-office-debitor.sql - include: file: db/changelog/5-hs-office/506-debitor/5063-hs-office-debitor-rbac.sql - include: file: db/changelog/5-hs-office/506-debitor/5068-hs-office-debitor-test-data.sql + context: office-test - include: file: db/changelog/5-hs-office/507-sepamandate/5070-hs-office-sepamandate.sql - include: @@ -121,12 +140,14 @@ databaseChangeLog: file: db/changelog/5-hs-office/507-sepamandate/5076-hs-office-sepamandate-migration.sql - include: file: db/changelog/5-hs-office/507-sepamandate/5078-hs-office-sepamandate-test-data.sql + context: office-test - include: file: db/changelog/5-hs-office/510-membership/5100-hs-office-membership.sql - include: file: db/changelog/5-hs-office/510-membership/5103-hs-office-membership-rbac.sql - include: file: db/changelog/5-hs-office/510-membership/5108-hs-office-membership-test-data.sql + context: office-test - include: file: db/changelog/5-hs-office/511-coopshares/5110-hs-office-coopshares.sql - include: @@ -135,6 +156,7 @@ databaseChangeLog: file: db/changelog/5-hs-office/511-coopshares/5116-hs-office-coopshares-migration.sql - include: file: db/changelog/5-hs-office/511-coopshares/5118-hs-office-coopshares-test-data.sql + context: office-test - include: file: db/changelog/5-hs-office/512-coopassets/5120-hs-office-coopassets.sql - include: @@ -143,37 +165,56 @@ databaseChangeLog: file: db/changelog/5-hs-office/512-coopassets/5126-hs-office-coopassets-migration.sql - include: file: db/changelog/5-hs-office/512-coopassets/5128-hs-office-coopassets-test-data.sql + context: office-test + - include: file: db/changelog/6-hs-booking/600-hs-booking-schema.sql + context: booking - include: file: db/changelog/6-hs-booking/610-booking-debitor/6100-hs-booking-debitor.sql + context: booking - include: file: db/changelog/6-hs-booking/620-booking-project/6200-hs-booking-project.sql + context: booking - include: file: db/changelog/6-hs-booking/620-booking-project/6203-hs-booking-project-rbac.sql + context: booking - include: file: db/changelog/6-hs-booking/620-booking-project/6208-hs-booking-project-test-data.sql + context: booking-test - include: file: db/changelog/6-hs-booking/630-booking-item/6300-hs-booking-item.sql + context: booking - include: file: db/changelog/6-hs-booking/630-booking-item/6303-hs-booking-item-rbac.sql + context: booking - include: file: db/changelog/6-hs-booking/630-booking-item/6308-hs-booking-item-test-data.sql + context: booking-test + - include: file: db/changelog/7-hs-hosting/700-hs-hosting-schema.sql + context: hosting - include: file: db/changelog/7-hs-hosting/701-hosting-asset/7010-hs-hosting-asset.sql + context: hosting - include: file: db/changelog/7-hs-hosting/701-hosting-asset/7013-hs-hosting-asset-rbac.sql + context: hosting - include: file: db/changelog/7-hs-hosting/701-hosting-asset/7016-hs-hosting-asset-migration.sql + context: hosting - include: file: db/changelog/7-hs-hosting/701-hosting-asset/7018-hs-hosting-asset-test-data.sql + context: hosting-test + - include: file: db/changelog/9-hs-global/9000-statistics.sql + context: hosting + - include: file: db/changelog/9-hs-global/9100-hs-integration-schema.sql - include: file: db/changelog/9-hs-global/9110-integration-kimai.sql - include: - file: db/changelog/9-hs-global/9120-integration-znuny.sql \ No newline at end of file + file: db/changelog/9-hs-global/9120-integration-znuny.sql diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml index 344828e7..4693d1bf 100644 --- a/src/test/resources/application.yml +++ b/src/test/resources/application.yml @@ -37,7 +37,7 @@ spring: liquibase: change-log: classpath:/db/changelog/db.changelog-master.yaml - contexts: tc,test,dev,pg_stat_statements + contexts: tc,test,dev,pg_stat_statements,rbac-test,office,office-test,booking,booking-test,hosting,hosting-test # keep this in sync with main/.../application.yml springdoc: -- 2.39.5 From 2d1b5ce046d139e0f76db76beae963df7a9b6ecc Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Thu, 16 Jan 2025 12:14:47 +0100 Subject: [PATCH 02/18] activate Actuator configprops+env and add ActuatorSanitizer to hide secret values --- .../hsadminng/config/ActuatorSanitizer.java | 105 ++++++++++++++++++ src/main/resources/application.yml | 57 +++++++++- .../config/ActuatorSanitizerUnitTest.java | 95 ++++++++++++++++ 3 files changed, 251 insertions(+), 6 deletions(-) create mode 100644 src/main/java/net/hostsharing/hsadminng/config/ActuatorSanitizer.java create mode 100644 src/test/java/net/hostsharing/hsadminng/config/ActuatorSanitizerUnitTest.java diff --git a/src/main/java/net/hostsharing/hsadminng/config/ActuatorSanitizer.java b/src/main/java/net/hostsharing/hsadminng/config/ActuatorSanitizer.java new file mode 100644 index 00000000..9967a78f --- /dev/null +++ b/src/main/java/net/hostsharing/hsadminng/config/ActuatorSanitizer.java @@ -0,0 +1,105 @@ +package net.hostsharing.hsadminng.config; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.actuate.endpoint.SanitizableData; +import org.springframework.boot.actuate.endpoint.SanitizingFunction; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Set; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +// HOWTO: exclude sensitive values, like passwords and other secrets, from being show by actuator endpoints: +// either use: add your custom keys to management.endpoint.additionalKeysToSanitize, +// or, if you need more heuristics, amend this code down here. +@Component +public class ActuatorSanitizer implements SanitizingFunction { + + private static final String[] REGEX_PARTS = {"*", "$", "^", "+"}; + + private static final Set DEFAULT_KEYS_TO_SANITIZE = Set.of( + "password", "secret", "token", ".*credentials.*", "vcap_services", "^vcap\\.services.*$", "sun.java.command", "^spring[._]application[._]json$" + ); + + private static final Set URI_USERINFO_KEYS = Set.of( + "uri", "uris", "url", "urls", "address", "addresses" + ); + + private static final Pattern URI_USERINFO_PATTERN = Pattern.compile("^\\[?[A-Za-z][A-Za-z0-9\\+\\.\\-]+://.+:(.*)@.+$"); + + private final List keysToSanitize = new ArrayList<>(); + + public ActuatorSanitizer(@Value("${management.endpoint.additionalKeysToSanitize:}") final List additionalKeysToSanitize) { + addKeysToSanitize(DEFAULT_KEYS_TO_SANITIZE); + addKeysToSanitize(URI_USERINFO_KEYS); + addKeysToSanitize(additionalKeysToSanitize); + } + + @Override + public SanitizableData apply(final SanitizableData data) { + if (data.getValue() == null) { + return data; + } + + for (final Pattern pattern : keysToSanitize) { + if (pattern.matcher(data.getKey()).matches()) { + if (keyIsUriWithUserInfo(pattern)) { + return data.withValue(sanitizeUris(data.getValue().toString())); + } + + return data.withValue(SanitizableData.SANITIZED_VALUE); + } + } + + return data; + } + + private void addKeysToSanitize(final Collection keysToSanitize) { + for (final String key : keysToSanitize) { + this.keysToSanitize.add(getPattern(key)); + } + } + + private Pattern getPattern(final String value) { + if (isRegex(value)) { + return Pattern.compile(value, Pattern.CASE_INSENSITIVE); + } + return Pattern.compile(".*" + value + "$", Pattern.CASE_INSENSITIVE); + } + + private boolean isRegex(final String value) { + for (final String part : REGEX_PARTS) { + if (value.contains(part)) { + return true; + } + } + return false; + } + + private boolean keyIsUriWithUserInfo(final Pattern pattern) { + for (String uriKey : URI_USERINFO_KEYS) { + if (pattern.matcher(uriKey).matches()) { + return true; + } + } + return false; + } + + private Object sanitizeUris(final String value) { + return Arrays.stream(value.split(",")).map(this::sanitizeUri).collect(Collectors.joining(",")); + } + + private String sanitizeUri(final String value) { + final var matcher = URI_USERINFO_PATTERN.matcher(value); + final var password = matcher.matches() ? matcher.group(1) : null; + if (password != null) { + return StringUtils.replace(value, ":" + password + "@", ":" + SanitizableData.SANITIZED_VALUE + "@"); + } + return value; + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index f6a6fe88..526a2a58 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -8,8 +8,23 @@ management: endpoints: web: exposure: - # HOWTO: view _clickable_ Spring Actuator (Micrometer) Metrics endpoints: http://localhost:8081/actuator/metric-links - include: info, health, metrics, metric-links, mappings, openapi, swaggerui + # HOWTO: view _clickable_ Spring Actuator (Micrometer) Metrics endpoints: + # http://localhost:8081/actuator/metric-links + + # HOWTO: view all configured endpoints of the running application: + # http://localhost:8081/actuator/mappings + + # HOWTO: view the effective application configuration properties: + # http://localhost:8081/actuator/configprops + + include: info, health, metrics, metric-links, mappings, openapi, swaggerui, configprops, env + endpoint: + env: + # TODO.spec: check this, maybe set to when_authorized? + show-values: always + configprops: + # TODO.spec: check this, maybe set to when_authorized? + show-values: always observations: annotations: enabled: true @@ -18,7 +33,7 @@ spring: datasource: driver-class-name: org.postgresql.Driver password: password - url: jdbc:postgresql://localhost:5432/postgres + url: ${HSADMINNG_POSTGRES_JDBC_URL} username: postgres sql: @@ -30,13 +45,13 @@ spring: hibernate: dialect: net.hostsharing.hsadminng.config.PostgresCustomDialect + liquibase: + contexts: dev,office + # keep this in sync with test/.../application.yml springdoc: use-management-port: true -liquibase: - contexts: dev - hsadminng: postgres: leakproof: @@ -51,3 +66,33 @@ metrics: server: requests: true +--- + +# the 'dev-all' profile automatically creates the PgSql users and runs only the office module +spring: + config: + activate: + on-profile: dev-all + liquibase: + contexts: dev,office,booking,hosting + +--- + +# the 'dev-office' profile automatically creates the PgSql users and runs only the office module +spring: + config: + activate: + on-profile: dev-office + liquibase: + contexts: dev,office + +--- + +# the 'prod-office' profile expects that the PgSql users are already created and runs only the office module +spring: + config: + activate: + on-profile: prod-office + liquibase: + contexts: office + diff --git a/src/test/java/net/hostsharing/hsadminng/config/ActuatorSanitizerUnitTest.java b/src/test/java/net/hostsharing/hsadminng/config/ActuatorSanitizerUnitTest.java new file mode 100644 index 00000000..a804251e --- /dev/null +++ b/src/test/java/net/hostsharing/hsadminng/config/ActuatorSanitizerUnitTest.java @@ -0,0 +1,95 @@ +package net.hostsharing.hsadminng.config; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.boot.actuate.endpoint.SanitizableData; +import org.springframework.core.env.PropertySource; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +class ActuatorSanitizerTest { + + private ActuatorSanitizer actuatorSanitizer; + + @BeforeEach + void setUp() { + // Initialize with additional keys for testing + final var additionalKeys = List.of("customSecret", "^custom[._]regex.*$"); + actuatorSanitizer = new ActuatorSanitizer(additionalKeys); + } + + @Test + void testSanitizesDefaultKeys() { + final var data = createSanitizableData("password", "my-secret-password"); + final var sanitizedData = actuatorSanitizer.apply(data); + + assertThat(sanitizedData.getValue()).isEqualTo(SanitizableData.SANITIZED_VALUE); + } + + @Test + void testSanitizesCustomKey() { + final var data = createSanitizableData("customSecret", "my-custom-secret"); + final var sanitizedData = actuatorSanitizer.apply(data); + + assertThat(sanitizedData.getValue()).isEqualTo(SanitizableData.SANITIZED_VALUE); + } + + @Test + void testSanitizesCustomRegexKey() { + final var data = createSanitizableData("custom.regex.key", "my-custom-regex-value"); + final var sanitizedData = actuatorSanitizer.apply(data); + + assertThat(sanitizedData.getValue()).isEqualTo(SanitizableData.SANITIZED_VALUE); + } + + @Test + void testSanitizesUriWithUserInfo() { + final var data = createSanitizableData("uri", "http://user:password@host.com"); + final var sanitizedData = actuatorSanitizer.apply(data); + + assertThat(sanitizedData.getValue()).isEqualTo("http://user:******@host.com"); + } + + @Test + void testDoesNotSanitizeIrrelevantKey() { + final var data = createSanitizableData("irrelevantKey", "non-sensitive-value"); + final var sanitizedData = actuatorSanitizer.apply(data); + + assertThat(sanitizedData.getValue()).isEqualTo("non-sensitive-value"); + } + + @Test + void testHandlesNullValue() { + final var data = createSanitizableData("password", null); + final var sanitizedData = actuatorSanitizer.apply(data); + + assertThat(sanitizedData.getValue()).isNull(); + } + + @Test + void testHandlesMultipleUris() { + final var data = createSanitizableData( + "uris", + "http://user1:password1@host1.com,http://user2:geheim@host2.com,http://user2@host2.com"); + final var sanitizedData = actuatorSanitizer.apply(data); + + assertThat(sanitizedData.getValue()).isEqualTo( + "http://user1:******@host1.com,http://user2:******@host2.com,http://user2@host2.com"); + } + + /** + * Utility method to create a SanitizableData instance for testing. + */ + private SanitizableData createSanitizableData(final String key, final String value) { + final var dummyPropertySource = new PropertySource<>("testSource") { + + @Override + public Object getProperty(String name) { + return null; // No real property resolution needed for this test + } + }; + return new SanitizableData(dummyPropertySource, key, value); + } +} -- 2.39.5 From 2a62215b34dd13be28bdfd49c1188af067f60251 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Thu, 16 Jan 2025 12:49:36 +0100 Subject: [PATCH 03/18] migrate LIQUIBASE_COMMAND_CONTEXT_FILTER to spring.liquibase.contexts and mark default profile --- .tc-environment | 1 - .unset-environment | 1 - src/main/resources/application.yml | 6 +++--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.tc-environment b/.tc-environment index 595d0096..c1816e80 100644 --- a/.tc-environment +++ b/.tc-environment @@ -4,5 +4,4 @@ export HSADMINNG_POSTGRES_ADMIN_PASSWORD= export HSADMINNG_POSTGRES_RESTRICTED_USERNAME=restricted export HSADMINNG_SUPERUSER=superuser-alex@hostsharing.net export HSADMINNG_MIGRATION_DATA_PATH=migration -export LIQUIBASE_COMMAND_CONTEXT_FILTER= export LANG=en_US.UTF-8 diff --git a/.unset-environment b/.unset-environment index fbc180cc..6f00ada4 100644 --- a/.unset-environment +++ b/.unset-environment @@ -4,5 +4,4 @@ unset HSADMINNG_POSTGRES_ADMIN_PASSWORD unset HSADMINNG_POSTGRES_RESTRICTED_USERNAME unset HSADMINNG_SUPERUSER unset HSADMINNG_MIGRATION_DATA_PATH -unset LIQUIBASE_COMMAND_CONTEXT_FILTER diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 526a2a58..1ea27053 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -46,7 +46,7 @@ spring: dialect: net.hostsharing.hsadminng.config.PostgresCustomDialect liquibase: - contexts: dev,office + contexts: default,dev,office,pg_stat_statements # default just as a marker to show from which profile it comes # keep this in sync with test/.../application.yml springdoc: @@ -74,7 +74,7 @@ spring: activate: on-profile: dev-all liquibase: - contexts: dev,office,booking,hosting + contexts: dev,office,booking,hosting,pg_stat_statements --- @@ -84,7 +84,7 @@ spring: activate: on-profile: dev-office liquibase: - contexts: dev,office + contexts: dev,office,pg_stat_statements --- -- 2.39.5 From c79476b53aff0013af1e333057d9c7667a0b5f11 Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Thu, 9 Jan 2025 10:21:48 +0100 Subject: [PATCH 04/18] post new contact: process postalAddress --- .../hsadminng/hs/office/contact/HsOfficeContactController.java | 1 + .../hsadminng/hs/office/relation/HsOfficeRelationController.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactController.java index 9b676af6..0a041763 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactController.java @@ -131,6 +131,7 @@ public class HsOfficeContactController implements HsOfficeContactsApi { @SuppressWarnings("unchecked") final BiConsumer RESOURCE_TO_ENTITY_POSTMAPPER = (resource, entity) -> { + entity.putPostalAddress(from(resource.getPostalAddress())); entity.putEmailAddresses(from(resource.getEmailAddresses())); entity.putPhoneNumbers(from(resource.getPhoneNumbers())); }; diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationController.java index 83eda5a0..4a92bd7f 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationController.java @@ -185,6 +185,7 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi { @SuppressWarnings("unchecked") final BiConsumer CONTACT_RESOURCE_TO_ENTITY_POSTMAPPER = (resource, entity) -> { + entity.putPostalAddress(from(resource.getPostalAddress())); entity.putEmailAddresses(from(resource.getEmailAddresses())); entity.putPhoneNumbers(from(resource.getPhoneNumbers())); }; -- 2.39.5 From 05dfa8456f406a7a70484ad13bf2c666bb026f45 Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Thu, 16 Jan 2025 08:54:19 +0100 Subject: [PATCH 05/18] improve test for adding contact with postal address --- .../HsOfficeContactControllerAcceptanceTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactControllerAcceptanceTest.java index 48d12f44..f683f7a0 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactControllerAcceptanceTest.java @@ -110,6 +110,14 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu .body(""" { "caption": "Temp Contact", + "postalAddress": { + "name": "Herr Test Contact", + "firm": "Test Contact GmbH", + "street": "Am Schieferbruch 3", + "zipcode": "12345", + "city": "Dachstadt", + "country": "Germany" + }, "emailAddresses": { "main": "test@example.org" } @@ -124,6 +132,8 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu .body("uuid", isUuidValid()) .body("caption", is("Temp Contact")) .body("emailAddresses", is(Map.of("main", "test@example.org"))) + .body("postalAddress", hasEntry("name", "Herr Test Contact") + .body("postalAddress", hasEntry("street", "Am Schieferbruch 3") .header("Location", startsWith("http://localhost")) .extract().header("Location"); // @formatter:on -- 2.39.5 From 07c3c5f9b601fa32952d8e61dc99ade0a4e3e526 Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Thu, 16 Jan 2025 09:42:07 +0100 Subject: [PATCH 06/18] fix previous commit --- .../contact/HsOfficeContactControllerAcceptanceTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactControllerAcceptanceTest.java index f683f7a0..da6a380f 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactControllerAcceptanceTest.java @@ -132,8 +132,8 @@ class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanu .body("uuid", isUuidValid()) .body("caption", is("Temp Contact")) .body("emailAddresses", is(Map.of("main", "test@example.org"))) - .body("postalAddress", hasEntry("name", "Herr Test Contact") - .body("postalAddress", hasEntry("street", "Am Schieferbruch 3") + .body("postalAddress", hasEntry("name", "Herr Test Contact")) + .body("postalAddress", hasEntry("street", "Am Schieferbruch 3")) .header("Location", startsWith("http://localhost")) .extract().header("Location"); // @formatter:on -- 2.39.5 From 45110a2da28be3261b9078f9041768a4acf933eb Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Thu, 16 Jan 2025 09:47:08 +0100 Subject: [PATCH 07/18] improve Test for addRelation with postalAddress --- ...HsOfficeRelationControllerAcceptanceTest.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java index 0ed4b82f..8e33c35a 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java @@ -18,13 +18,14 @@ import org.springframework.boot.test.web.server.LocalServerPort; import org.springframework.test.context.ActiveProfiles; import org.springframework.transaction.annotation.Transactional; +import java.util.Map; import java.util.UUID; import static net.hostsharing.hsadminng.rbac.test.IsValidUuidMatcher.isUuidValid; import static net.hostsharing.hsadminng.test.JsonMatcher.lenientlyEquals; import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.startsWith; +import static org.hamcrest.Matchers.*; +import static org.hamcrest.Matchers.hasEntry; @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, @@ -291,6 +292,14 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean }, "contact": { "caption": "Temp Contact", + "postalAddress": { + "name": "Herr Test Contact", + "firm": "Test Contact GmbH", + "street": "Am Schieferbruch 3", + "zipcode": "12345", + "city": "Dachstadt", + "country": "Germany" + }, "emailAddresses": { "main": "test@example.org" } @@ -315,6 +324,9 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean .body("holder.givenName", is("Temp")) .body("holder.familyName", is("Person")) .body("contact.caption", is("Temp Contact")) + .body("contact.emailAddresses", is(Map.of("main", "test@example.org"))) + .body("contact.postalAddress", hasEntry("name", "Herr Test Contact")) + .body("contact.postalAddress", hasEntry("street", "Am Schieferbruch 3")) .header("Location", startsWith("http://localhost")) .extract().header("Location"); // @formatter:on -- 2.39.5 From 56034c5dcf94e048ae78a97a667c4d2065c0e835 Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Mon, 13 Jan 2025 16:26:34 +0100 Subject: [PATCH 08/18] add view for list subscriptions --- .../9-hs-global/9130-integration-mlmmj.sql | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/main/resources/db/changelog/9-hs-global/9130-integration-mlmmj.sql diff --git a/src/main/resources/db/changelog/9-hs-global/9130-integration-mlmmj.sql b/src/main/resources/db/changelog/9-hs-global/9130-integration-mlmmj.sql new file mode 100644 index 00000000..a7ab0d9e --- /dev/null +++ b/src/main/resources/db/changelog/9-hs-global/9130-integration-mlmmj.sql @@ -0,0 +1,14 @@ + +--liquibase formatted sql + +-- ============================================================================ +--changeset timotheus.pokorra:hs-global-integration-znuny endDelimiter:--// +CREATE OR REPLACE VIEW hs_integration.subscription AS + SELECT DISTINCT + relation.mark as subscription, + contact.emailaddresses->>'main' as email + FROM hs_office.contact AS contact + JOIN hs_office.relation AS relation ON relation.contactuuid = contact.uuid AND relation.type = 'SUBSCRIBER' + ORDER BY subscription, email; + +--// -- 2.39.5 From 7eda0127ca285437163602058a22bd9a07dbd6be Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Thu, 16 Jan 2025 08:36:30 +0100 Subject: [PATCH 09/18] add sql file for mlmmj integration view to db changelog --- src/main/resources/db/changelog/db.changelog-master.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/resources/db/changelog/db.changelog-master.yaml b/src/main/resources/db/changelog/db.changelog-master.yaml index 778bbcfe..19cb724f 100644 --- a/src/main/resources/db/changelog/db.changelog-master.yaml +++ b/src/main/resources/db/changelog/db.changelog-master.yaml @@ -218,3 +218,5 @@ databaseChangeLog: file: db/changelog/9-hs-global/9110-integration-kimai.sql - include: file: db/changelog/9-hs-global/9120-integration-znuny.sql + - include: + file: db/changelog/9-hs-global/9130-integration-mlmmj.sql -- 2.39.5 From efb824d0ba664a4a0735ba751806df3391e2f92d Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Thu, 16 Jan 2025 15:03:22 +0100 Subject: [PATCH 10/18] add several Spring profiles and Spring profile documentation --- README.md | 34 ++++++++++++++++++++++++++++++ src/main/resources/application.yml | 29 +++++++++++++++++++++---- 2 files changed, 59 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e9f40f79..23ae7758 100644 --- a/README.md +++ b/README.md @@ -622,6 +622,40 @@ also try this (assumed you've sourced .aliases): howto ``` +### How to Run the Application With Other Profiles, e.g. production: + +Add `--args='--spring.profiles.active=...` with the wanted profile selector: + +```sh +gw bootRun --args='--spring.profiles.active=prod' +``` + +Currently, the difference between 'dev' and 'prod' is only that 'dev' creates the PostgreSQL users, +and 'prod' expects these to be already created in the + +All other differences are currently controlled by environment-variables. + + +### How to Do a Clean Run of the Application + +If you frequently need to run with a fresh database and a clean build, you can use this: + +```sh +gw clean && pg-sql-reset && sleep 5 && gw bootRun --args='--spring.profiles.active=dev-office' 2>&1 | tee log +``` + + +### How to Run Just the Office Module (including dependents): + +At the end of `src/main/resources/application.yml` you can find customized profiles between the sections separated by `---`. + +For example for a dev environment, run: + +```sh +gw bootRun --args='--spring.profiles.active=dev-office' +``` + + ### How to Configure .pgpass for the Default PostgreSQL Database? To access the default database schema as used during development, add this line to your `.pgpass` file in your users home directory: diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 1ea27053..4943eb60 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -46,7 +46,8 @@ spring: dialect: net.hostsharing.hsadminng.config.PostgresCustomDialect liquibase: - contexts: default,dev,office,pg_stat_statements # default just as a marker to show from which profile it comes + # default just as a marker to show from which profile it comes + contexts: default,dev,rbac-test,office,office-test,booking,booking-test,hosting,hosting-test,pg_stat_statements # keep this in sync with test/.../application.yml springdoc: @@ -68,7 +69,7 @@ metrics: --- -# the 'dev-all' profile automatically creates the PgSql users and runs only the office module +# the 'dev-all' profile automatically creates the PgSql users and runs all modules without test-data spring: config: activate: @@ -78,7 +79,17 @@ spring: --- -# the 'dev-office' profile automatically creates the PgSql users and runs only the office module +# the 'dev-all' profile automatically creates the PgSql users and runs all modules with test-data +spring: + config: + activate: + on-profile: dev-all-test + liquibase: + contexts: dev,rbac-test,office,office-test,booking,booking-test,hosting,hosting-test,pg_stat_statements + +--- + +# the 'dev-office' profile automatically creates the PgSql users and runs only the office module without test-data spring: config: activate: @@ -88,7 +99,17 @@ spring: --- -# the 'prod-office' profile expects that the PgSql users are already created and runs only the office module +# the 'dev-office' profile automatically creates the PgSql users and runs only the office module with test-data +spring: + config: + activate: + on-profile: dev-office-test + liquibase: + contexts: dev,rbac-test,office,office-test,pg_stat_statements + +--- + +# the 'prod-office' profile expects that the PgSql users are already created and runs only the office module without test-data spring: config: activate: -- 2.39.5 From a8fb7ce95c144140328ece71f40a0d01031a4b63 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Sat, 18 Jan 2025 16:03:34 +0100 Subject: [PATCH 11/18] fix readme and gw-test/gw-check --- .aliases | 4 ++-- README.md | 39 ++++++++++++++++++++------------------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/.aliases b/.aliases index eb60c71d..b7aa5c04 100644 --- a/.aliases +++ b/.aliases @@ -90,8 +90,8 @@ alias pg-sql-restore='gunzip --stdout | docker exec -i hsadmin-ng-postgres psql alias fp='grep -r '@Accepts' src | sed -e 's/^.*@/@/g' | sort -u | wc -l' alias gw-spotless='./gradlew spotlessApply -x pitest -x test -x :processResources' -alias gw-test='. .aliases; ./gradlew test' -alias gw-check='. .aliases; gw test check -x pitest' +alias gw-test='. .aliases; . .tc-environment; ./gradlew test' +alias gw-check='. .aliases; . .tc-environment; gw test check -x pitest' alias howto=bin/howto alias cas-curl=bin/cas-curl diff --git a/README.md b/README.md index 23ae7758..ef1fee8a 100644 --- a/README.md +++ b/README.md @@ -72,12 +72,22 @@ If you have at least Docker and the Java JDK installed in appropriate versions a # if the container has been built already and you want to keep the data, run this: pg-sql-start -Next, compile and run the application without CAS-authentication on `localhost:8080`: +Next, compile and run the application on `localhost:8080` and the management server on `localhost:8081`: + # this disables CAS-authentication, for using the REST-API with CAS-authentication, see `bin/cas-curl`. export HSADMINNG_CAS_SERVER= - gw bootRun -For using the REST-API with CAS-authentication, see `bin/cas-curl`. + # this runs the application with test-data and all modules: + gw bootRun --args='--spring.profiles.active=dev,complete,test-data' + +The meaning of these profiles is: + +- **dev**: the PostgreSQL users are created via Liquibase +- **complete**: all modules are started +- **test-data**: some test data inserted + +Running just `gw bootRun` would just run the *office* module, not insert any test-data and +require the PostgreSQL users created in the database (see env-vars in `.aliases`). Now we can access the REST API, e.g. using curl: @@ -627,13 +637,14 @@ howto Add `--args='--spring.profiles.active=...` with the wanted profile selector: ```sh -gw bootRun --args='--spring.profiles.active=prod' +gw bootRun --args='--spring.profiles.active=external-db,only-office,without-test-data' ``` -Currently, the difference between 'dev' and 'prod' is only that 'dev' creates the PostgreSQL users, -and 'prod' expects these to be already created in the +These profiles mean: -All other differences are currently controlled by environment-variables. +- **external-db**: an external PostgreSQL database is used with the PostgreSQL users already created as specified in the environment +- **only-office**: only the Office module is started, but neither the Booking nor the Hosting modules +- **without-test-data**: no test-data is inserted ### How to Do a Clean Run of the Application @@ -641,18 +652,8 @@ All other differences are currently controlled by environment-variables. If you frequently need to run with a fresh database and a clean build, you can use this: ```sh -gw clean && pg-sql-reset && sleep 5 && gw bootRun --args='--spring.profiles.active=dev-office' 2>&1 | tee log -``` - - -### How to Run Just the Office Module (including dependents): - -At the end of `src/main/resources/application.yml` you can find customized profiles between the sections separated by `---`. - -For example for a dev environment, run: - -```sh -gw bootRun --args='--spring.profiles.active=dev-office' +export HSADMINNG_CAS_SERVER= +gw clean && pg-sql-reset && sleep 5 && gw bootRun' 2>&1 | tee log ``` -- 2.39.5 From 3c6ed0e6ff2d7ae62aaa1a26933482f31e32c5ac Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Sat, 18 Jan 2025 16:04:19 +0100 Subject: [PATCH 12/18] set proper profiles --- .../debitor/HsBookingDebitorRepository.java | 4 +- .../BookingItemCreatedEventRepository.java | 2 + .../booking/item/HsBookingItemController.java | 2 + .../item/HsBookingItemRbacRepository.java | 2 + .../item/HsBookingItemRealRepository.java | 2 + .../booking/item/HsBookingItemRepository.java | 3 + .../project/HsBookingProjectController.java | 2 + .../HsBookingProjectRbacRepository.java | 2 + .../HsBookingProjectRealRepository.java | 2 + .../project/HsBookingProjectRepository.java | 2 + .../asset/HsHostingAssetController.java | 2 + .../asset/HsHostingAssetPropsController.java | 2 + .../asset/HsHostingAssetRbacRepository.java | 3 +- .../asset/HsHostingAssetRealRepository.java | 2 + .../asset/HsHostingAssetRepository.java | 2 + .../HsBookingItemCreatedListener.java | 2 + src/main/resources/application.yml | 55 +-------------- .../db/changelog/1-rbac/1050-rbac-base.sql | 2 +- .../db/changelog/1-rbac/1080-rbac-global.sql | 4 +- .../2018-rbactest-customer-test-data.sql | 2 +- .../2028-rbactest-package-test-data.sql | 2 +- .../2038-rbactest-domain-test-data.sql | 2 +- .../5018-hs-office-contact-test-data.sql | 2 +- .../5028-hs-office-person-test-data.sql | 2 +- .../5038-hs-office-relation-test-data.sql | 2 +- .../5048-hs-office-partner-test-data.sql | 2 +- .../5058-hs-office-bankaccount-test-data.sql | 2 +- .../5068-hs-office-debitor-test-data.sql | 2 +- .../5078-hs-office-sepamandate-test-data.sql | 2 +- .../5108-hs-office-membership-test-data.sql | 2 +- .../5118-hs-office-coopshares-test-data.sql | 2 +- .../5128-hs-office-coopassets-test-data.sql | 2 +- .../6208-hs-booking-project-test-data.sql | 2 +- .../6308-hs-booking-item-test-data.sql | 2 +- .../7018-hs-hosting-asset-test-data.sql | 2 +- .../db/changelog/db.changelog-master.yaml | 68 +++++++++---------- .../config/ActuatorSanitizerUnitTest.java | 2 +- ...asAuthenticationFilterIntegrationTest.java | 2 +- .../WebSecurityConfigIntegrationTest.java | 2 +- ...HsBookingItemControllerAcceptanceTest.java | 2 +- .../item/HsBookingItemControllerRestTest.java | 2 +- ...ookingProjectControllerAcceptanceTest.java | 2 +- ...sHostingAssetControllerAcceptanceTest.java | 2 +- .../HsHostingAssetControllerRestTest.java | 2 +- ...ingAssetPropsControllerAcceptanceTest.java | 2 +- .../hs/migration/ImportHostingAssets.java | 2 + .../hs/migration/ImportOfficeData.java | 2 + 47 files changed, 102 insertions(+), 117 deletions(-) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/booking/debitor/HsBookingDebitorRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/booking/debitor/HsBookingDebitorRepository.java index 8d0bbe30..7273c444 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/booking/debitor/HsBookingDebitorRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/booking/debitor/HsBookingDebitorRepository.java @@ -2,12 +2,14 @@ package net.hostsharing.hsadminng.hs.booking.debitor; import io.micrometer.core.annotation.Timed; import org.springframework.data.repository.Repository; +import org.springframework.context.annotation.Profile; import java.util.List; import java.util.Optional; import java.util.UUID; -public interface HsBookingDebitorRepository extends Repository { +@Profile("!only-office") +public interface HsBookingDebitorRepository extends Repository { @Timed("app.booking.debitor.repo.findByUuid") Optional findByUuid(UUID id); diff --git a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/BookingItemCreatedEventRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/BookingItemCreatedEventRepository.java index f94f1458..2ae18218 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/BookingItemCreatedEventRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/BookingItemCreatedEventRepository.java @@ -1,10 +1,12 @@ package net.hostsharing.hsadminng.hs.booking.item; import io.micrometer.core.annotation.Timed; +import org.springframework.context.annotation.Profile; import org.springframework.data.repository.Repository; import java.util.UUID; +@Profile("!only-office") public interface BookingItemCreatedEventRepository extends Repository { @Timed("app.booking.items.repo.save") diff --git a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemController.java b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemController.java index 6facc03f..6b563041 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemController.java @@ -16,6 +16,7 @@ import net.hostsharing.hsadminng.mapper.StrictMapper; import net.hostsharing.hsadminng.persistence.EntityManagerWrapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; +import org.springframework.context.annotation.Profile; import org.springframework.http.ResponseEntity; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.RestController; @@ -30,6 +31,7 @@ import static java.util.Optional.ofNullable; import static net.hostsharing.hsadminng.mapper.PostgresDateRange.toPostgresDateRange; @RestController +@Profile("!only-office") public class HsBookingItemController implements HsBookingItemsApi { @Autowired diff --git a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRbacRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRbacRepository.java index 392b7077..6715e610 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRbacRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRbacRepository.java @@ -1,12 +1,14 @@ package net.hostsharing.hsadminng.hs.booking.item; import io.micrometer.core.annotation.Timed; +import org.springframework.context.annotation.Profile; import org.springframework.data.repository.Repository; import java.util.List; import java.util.Optional; import java.util.UUID; +@Profile("!only-office") public interface HsBookingItemRbacRepository extends HsBookingItemRepository, Repository { diff --git a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRealRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRealRepository.java index 706b1349..ef4c205b 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRealRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRealRepository.java @@ -1,12 +1,14 @@ package net.hostsharing.hsadminng.hs.booking.item; import io.micrometer.core.annotation.Timed; +import org.springframework.context.annotation.Profile; import org.springframework.data.repository.Repository; import java.util.List; import java.util.Optional; import java.util.UUID; +@Profile("!only-office") public interface HsBookingItemRealRepository extends HsBookingItemRepository, Repository { diff --git a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRepository.java index 67cb8efc..310027cb 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRepository.java @@ -1,10 +1,13 @@ package net.hostsharing.hsadminng.hs.booking.item; +import org.springframework.context.annotation.Profile; + import java.util.List; import java.util.Optional; import java.util.UUID; +@Profile("!only-office") public interface HsBookingItemRepository { Optional findByUuid(final UUID bookingItemUuid); diff --git a/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectController.java b/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectController.java index 98b856b9..11c135dd 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectController.java @@ -9,6 +9,7 @@ import net.hostsharing.hsadminng.hs.booking.generated.api.v1.model.HsBookingProj import net.hostsharing.hsadminng.hs.booking.generated.api.v1.model.HsBookingProjectResource; import net.hostsharing.hsadminng.mapper.StrictMapper; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Profile; import org.springframework.http.ResponseEntity; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.RestController; @@ -20,6 +21,7 @@ import java.util.UUID; import java.util.function.BiConsumer; @RestController +@Profile("!only-office") public class HsBookingProjectController implements HsBookingProjectsApi { @Autowired diff --git a/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRbacRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRbacRepository.java index 63065bb2..a9360b34 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRbacRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRbacRepository.java @@ -1,12 +1,14 @@ package net.hostsharing.hsadminng.hs.booking.project; import io.micrometer.core.annotation.Timed; +import org.springframework.context.annotation.Profile; import org.springframework.data.repository.Repository; import java.util.List; import java.util.Optional; import java.util.UUID; +@Profile("!only-office") public interface HsBookingProjectRbacRepository extends HsBookingProjectRepository, Repository { diff --git a/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRealRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRealRepository.java index 66b978b5..cc2e9a28 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRealRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRealRepository.java @@ -1,12 +1,14 @@ package net.hostsharing.hsadminng.hs.booking.project; import io.micrometer.core.annotation.Timed; +import org.springframework.context.annotation.Profile; import org.springframework.data.repository.Repository; import java.util.List; import java.util.Optional; import java.util.UUID; +@Profile("!only-office") public interface HsBookingProjectRealRepository extends HsBookingProjectRepository, Repository { diff --git a/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRepository.java index 0b9c7871..1f652196 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRepository.java @@ -1,11 +1,13 @@ package net.hostsharing.hsadminng.hs.booking.project; import io.micrometer.core.annotation.Timed; +import org.springframework.context.annotation.Profile; import java.util.List; import java.util.Optional; import java.util.UUID; +@Profile("!only-office") public interface HsBookingProjectRepository { @Timed("app.booking.projects.repo.findByUuid") diff --git a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetController.java b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetController.java index f9a45f70..7d12d714 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetController.java @@ -15,6 +15,7 @@ import net.hostsharing.hsadminng.mapper.KeyValueMap; import net.hostsharing.hsadminng.mapper.StrictMapper; import net.hostsharing.hsadminng.persistence.EntityManagerWrapper; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Profile; import org.springframework.http.ResponseEntity; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.RestController; @@ -27,6 +28,7 @@ import java.util.UUID; import java.util.function.BiConsumer; @RestController +@Profile("!only-office") public class HsHostingAssetController implements HsHostingAssetsApi { @Autowired diff --git a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetPropsController.java b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetPropsController.java index b4c56f4c..d843ff87 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetPropsController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetPropsController.java @@ -4,6 +4,7 @@ import io.micrometer.core.annotation.Timed; import net.hostsharing.hsadminng.hs.hosting.asset.validators.HostingAssetEntityValidatorRegistry; import net.hostsharing.hsadminng.hs.hosting.generated.api.v1.api.HsHostingAssetPropsApi; import net.hostsharing.hsadminng.hs.hosting.generated.api.v1.model.HsHostingAssetTypeResource; +import org.springframework.context.annotation.Profile; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RestController; @@ -12,6 +13,7 @@ import java.util.Map; @RestController +@Profile("!only-office") public class HsHostingAssetPropsController implements HsHostingAssetPropsApi { @Override diff --git a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRbacRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRbacRepository.java index 75a9863f..bdb6a65e 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRbacRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRbacRepository.java @@ -1,6 +1,7 @@ package net.hostsharing.hsadminng.hs.hosting.asset; import io.micrometer.core.annotation.Timed; +import org.springframework.context.annotation.Profile; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; @@ -8,7 +9,7 @@ import java.util.List; import java.util.Optional; import java.util.UUID; - +@Profile("!only-office") public interface HsHostingAssetRbacRepository extends HsHostingAssetRepository, Repository { @Timed("app.hostingAsset.repo.findByUuid.rbac") diff --git a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRealRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRealRepository.java index 64fc44bd..4853b665 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRealRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRealRepository.java @@ -1,6 +1,7 @@ package net.hostsharing.hsadminng.hs.hosting.asset; import io.micrometer.core.annotation.Timed; +import org.springframework.context.annotation.Profile; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; @@ -9,6 +10,7 @@ import java.util.List; import java.util.Optional; import java.util.UUID; +@Profile("!only-office") public interface HsHostingAssetRealRepository extends HsHostingAssetRepository, Repository { @Timed("app.hostingAsset.repo.findByUuid.real") diff --git a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRepository.java index a473accc..c87f6a2c 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRepository.java @@ -1,11 +1,13 @@ package net.hostsharing.hsadminng.hs.hosting.asset; import io.micrometer.core.annotation.Timed; +import org.springframework.context.annotation.Profile; import java.util.List; import java.util.Optional; import java.util.UUID; +@Profile("!only-office") public interface HsHostingAssetRepository { @Timed("app.hosting.assets.repo.findByUuid") diff --git a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/factories/HsBookingItemCreatedListener.java b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/factories/HsBookingItemCreatedListener.java index 73291368..d26ebe55 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/factories/HsBookingItemCreatedListener.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/factories/HsBookingItemCreatedListener.java @@ -13,9 +13,11 @@ import net.hostsharing.hsadminng.mapper.StrictMapper; import net.hostsharing.hsadminng.persistence.EntityManagerWrapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationListener; +import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Component; @Component +@Profile("!only-office") public class HsBookingItemCreatedListener implements ApplicationListener { @Autowired diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 4943eb60..60fd285e 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -30,6 +30,7 @@ management: enabled: true spring: + datasource: driver-class-name: org.postgresql.Driver password: password @@ -46,8 +47,7 @@ spring: dialect: net.hostsharing.hsadminng.config.PostgresCustomDialect liquibase: - # default just as a marker to show from which profile it comes - contexts: default,dev,rbac-test,office,office-test,booking,booking-test,hosting,hosting-test,pg_stat_statements + contexts: ${spring.profiles.active} # keep this in sync with test/.../application.yml springdoc: @@ -66,54 +66,3 @@ metrics: http: server: requests: true - ---- - -# the 'dev-all' profile automatically creates the PgSql users and runs all modules without test-data -spring: - config: - activate: - on-profile: dev-all - liquibase: - contexts: dev,office,booking,hosting,pg_stat_statements - ---- - -# the 'dev-all' profile automatically creates the PgSql users and runs all modules with test-data -spring: - config: - activate: - on-profile: dev-all-test - liquibase: - contexts: dev,rbac-test,office,office-test,booking,booking-test,hosting,hosting-test,pg_stat_statements - ---- - -# the 'dev-office' profile automatically creates the PgSql users and runs only the office module without test-data -spring: - config: - activate: - on-profile: dev-office - liquibase: - contexts: dev,office,pg_stat_statements - ---- - -# the 'dev-office' profile automatically creates the PgSql users and runs only the office module with test-data -spring: - config: - activate: - on-profile: dev-office-test - liquibase: - contexts: dev,rbac-test,office,office-test,pg_stat_statements - ---- - -# the 'prod-office' profile expects that the PgSql users are already created and runs only the office module without test-data -spring: - config: - activate: - on-profile: prod-office - liquibase: - contexts: office - diff --git a/src/main/resources/db/changelog/1-rbac/1050-rbac-base.sql b/src/main/resources/db/changelog/1-rbac/1050-rbac-base.sql index bdcd9368..04bd36d2 100644 --- a/src/main/resources/db/changelog/1-rbac/1050-rbac-base.sql +++ b/src/main/resources/db/changelog/1-rbac/1050-rbac-base.sql @@ -870,7 +870,7 @@ $$; -- ============================================================================ ---changeset michael.hoennig:rbac-base-PGSQL-ROLES context:dev,tc endDelimiter:--// +--changeset michael.hoennig:rbac-base-PGSQL-ROLES context:!external-db endDelimiter:--// -- ---------------------------------------------------------------------------- do $$ diff --git a/src/main/resources/db/changelog/1-rbac/1080-rbac-global.sql b/src/main/resources/db/changelog/1-rbac/1080-rbac-global.sql index 28575733..22ff2310 100644 --- a/src/main/resources/db/changelog/1-rbac/1080-rbac-global.sql +++ b/src/main/resources/db/changelog/1-rbac/1080-rbac-global.sql @@ -170,7 +170,7 @@ commit; -- ============================================================================ ---changeset michael.hoennig:rbac-global-ADMIN-USERS context:dev,tc endDelimiter:--// +--changeset michael.hoennig:rbac-global-ADMIN-USERS context:!without-test-data endDelimiter:--// -- ---------------------------------------------------------------------------- /* Create two users and assign both to the administrators' role. @@ -192,7 +192,7 @@ $$; -- ============================================================================ ---changeset michael.hoennig:rbac-global-TEST context:dev,tc runAlways:true endDelimiter:--// +--changeset michael.hoennig:rbac-global-TEST context:!without-test-data runAlways:true endDelimiter:--// -- ---------------------------------------------------------------------------- /* diff --git a/src/main/resources/db/changelog/2-rbactest/201-rbactest-customer/2018-rbactest-customer-test-data.sql b/src/main/resources/db/changelog/2-rbactest/201-rbactest-customer/2018-rbactest-customer-test-data.sql index 18c23fe4..0f9e8a8a 100644 --- a/src/main/resources/db/changelog/2-rbactest/201-rbactest-customer/2018-rbactest-customer-test-data.sql +++ b/src/main/resources/db/changelog/2-rbactest/201-rbactest-customer/2018-rbactest-customer-test-data.sql @@ -67,7 +67,7 @@ end; $$; -- ============================================================================ ---changeset michael.hoennig:test-customer-TEST-DATA-GENERATION –context=dev,tc endDelimiter:--// +--changeset michael.hoennig:test-customer-TEST-DATA-GENERATION context:!without-test-data endDelimiter:--// -- ---------------------------------------------------------------------------- do language plpgsql $$ diff --git a/src/main/resources/db/changelog/2-rbactest/202-rbactest-package/2028-rbactest-package-test-data.sql b/src/main/resources/db/changelog/2-rbactest/202-rbactest-package/2028-rbactest-package-test-data.sql index eae1342f..dc62a8f1 100644 --- a/src/main/resources/db/changelog/2-rbactest/202-rbactest-package/2028-rbactest-package-test-data.sql +++ b/src/main/resources/db/changelog/2-rbactest/202-rbactest-package/2028-rbactest-package-test-data.sql @@ -59,7 +59,7 @@ $$; -- ============================================================================ ---changeset michael.hoennig:test-package-TEST-DATA-GENERATION –context=dev,tc endDelimiter:--// +--changeset michael.hoennig:test-package-TEST-DATA-GENERATION context:!without-test-data endDelimiter:--// -- ---------------------------------------------------------------------------- do language plpgsql $$ diff --git a/src/main/resources/db/changelog/2-rbactest/203-rbactest-domain/2038-rbactest-domain-test-data.sql b/src/main/resources/db/changelog/2-rbactest/203-rbactest-domain/2038-rbactest-domain-test-data.sql index 5fbbfa8c..eb0a3af5 100644 --- a/src/main/resources/db/changelog/2-rbactest/203-rbactest-domain/2038-rbactest-domain-test-data.sql +++ b/src/main/resources/db/changelog/2-rbactest/203-rbactest-domain/2038-rbactest-domain-test-data.sql @@ -52,7 +52,7 @@ end; $$; -- ============================================================================ ---changeset michael.hoennig:hs-domain-TEST-DATA-GENERATION –context=dev,tc endDelimiter:--// +--changeset michael.hoennig:hs-domain-TEST-DATA-GENERATION context:!without-test-data endDelimiter:--// -- ---------------------------------------------------------------------------- do language plpgsql $$ diff --git a/src/main/resources/db/changelog/5-hs-office/501-contact/5018-hs-office-contact-test-data.sql b/src/main/resources/db/changelog/5-hs-office/501-contact/5018-hs-office-contact-test-data.sql index 036fd7e2..f44772ff 100644 --- a/src/main/resources/db/changelog/5-hs-office/501-contact/5018-hs-office-contact-test-data.sql +++ b/src/main/resources/db/changelog/5-hs-office/501-contact/5018-hs-office-contact-test-data.sql @@ -55,7 +55,7 @@ end; $$; -- ============================================================================ ---changeset michael.hoennig:hs-office-contact-TEST-DATA-GENERATION –context=dev,tc endDelimiter:--// +--changeset michael.hoennig:hs-office-contact-TEST-DATA-GENERATION context:!without-test-data endDelimiter:--// -- ---------------------------------------------------------------------------- do language plpgsql $$ diff --git a/src/main/resources/db/changelog/5-hs-office/502-person/5028-hs-office-person-test-data.sql b/src/main/resources/db/changelog/5-hs-office/502-person/5028-hs-office-person-test-data.sql index 49380a13..1be4c25d 100644 --- a/src/main/resources/db/changelog/5-hs-office/502-person/5028-hs-office-person-test-data.sql +++ b/src/main/resources/db/changelog/5-hs-office/502-person/5028-hs-office-person-test-data.sql @@ -34,7 +34,7 @@ end; $$; -- ============================================================================ ---changeset michael.hoennig:hs-office-person-TEST-DATA-GENERATION –context=dev,tc endDelimiter:--// +--changeset michael.hoennig:hs-office-person-TEST-DATA-GENERATION context:!without-test-data endDelimiter:--// -- ---------------------------------------------------------------------------- do language plpgsql $$ diff --git a/src/main/resources/db/changelog/5-hs-office/503-relation/5038-hs-office-relation-test-data.sql b/src/main/resources/db/changelog/5-hs-office/503-relation/5038-hs-office-relation-test-data.sql index 6673d572..28ce12bd 100644 --- a/src/main/resources/db/changelog/5-hs-office/503-relation/5038-hs-office-relation-test-data.sql +++ b/src/main/resources/db/changelog/5-hs-office/503-relation/5038-hs-office-relation-test-data.sql @@ -80,7 +80,7 @@ end; $$; -- ============================================================================ ---changeset michael.hoennig:hs-office-relation-TEST-DATA-GENERATION –context=dev,tc endDelimiter:--// +--changeset michael.hoennig:hs-office-relation-TEST-DATA-GENERATION context:!without-test-data endDelimiter:--// -- ---------------------------------------------------------------------------- do language plpgsql $$ diff --git a/src/main/resources/db/changelog/5-hs-office/504-partner/5048-hs-office-partner-test-data.sql b/src/main/resources/db/changelog/5-hs-office/504-partner/5048-hs-office-partner-test-data.sql index 3a6ced65..03cce30d 100644 --- a/src/main/resources/db/changelog/5-hs-office/504-partner/5048-hs-office-partner-test-data.sql +++ b/src/main/resources/db/changelog/5-hs-office/504-partner/5048-hs-office-partner-test-data.sql @@ -66,7 +66,7 @@ end; $$; -- ============================================================================ ---changeset michael.hoennig:hs-office-partner-TEST-DATA-GENERATION –context=dev,tc endDelimiter:--// +--changeset michael.hoennig:hs-office-partner-TEST-DATA-GENERATION context:!without-test-data endDelimiter:--// -- ---------------------------------------------------------------------------- do language plpgsql $$ diff --git a/src/main/resources/db/changelog/5-hs-office/505-bankaccount/5058-hs-office-bankaccount-test-data.sql b/src/main/resources/db/changelog/5-hs-office/505-bankaccount/5058-hs-office-bankaccount-test-data.sql index 7aedc340..7c7f5884 100644 --- a/src/main/resources/db/changelog/5-hs-office/505-bankaccount/5058-hs-office-bankaccount-test-data.sql +++ b/src/main/resources/db/changelog/5-hs-office/505-bankaccount/5058-hs-office-bankaccount-test-data.sql @@ -26,7 +26,7 @@ end; $$; -- ============================================================================ ---changeset michael.hoennig:hs-office-bankaccount-TEST-DATA-GENERATION –context=dev,tc endDelimiter:--// +--changeset michael.hoennig:hs-office-bankaccount-TEST-DATA-GENERATION context:!without-test-data endDelimiter:--// -- ---------------------------------------------------------------------------- do language plpgsql $$ diff --git a/src/main/resources/db/changelog/5-hs-office/506-debitor/5068-hs-office-debitor-test-data.sql b/src/main/resources/db/changelog/5-hs-office/506-debitor/5068-hs-office-debitor-test-data.sql index 1133621d..78a8c7f9 100644 --- a/src/main/resources/db/changelog/5-hs-office/506-debitor/5068-hs-office-debitor-test-data.sql +++ b/src/main/resources/db/changelog/5-hs-office/506-debitor/5068-hs-office-debitor-test-data.sql @@ -45,7 +45,7 @@ end; $$; -- ============================================================================ ---changeset michael.hoennig:hs-office-debitor-TEST-DATA-GENERATION –context=dev,tc endDelimiter:--// +--changeset michael.hoennig:hs-office-debitor-TEST-DATA-GENERATION context:!without-test-data endDelimiter:--// -- ---------------------------------------------------------------------------- do language plpgsql $$ diff --git a/src/main/resources/db/changelog/5-hs-office/507-sepamandate/5078-hs-office-sepamandate-test-data.sql b/src/main/resources/db/changelog/5-hs-office/507-sepamandate/5078-hs-office-sepamandate-test-data.sql index 4bed9841..f8698197 100644 --- a/src/main/resources/db/changelog/5-hs-office/507-sepamandate/5078-hs-office-sepamandate-test-data.sql +++ b/src/main/resources/db/changelog/5-hs-office/507-sepamandate/5078-hs-office-sepamandate-test-data.sql @@ -38,7 +38,7 @@ end; $$; -- ============================================================================ ---changeset michael.hoennig:hs-office-sepaMandate-TEST-DATA-GENERATION –context=dev,tc endDelimiter:--// +--changeset michael.hoennig:hs-office-sepaMandate-TEST-DATA-GENERATION context:!without-test-data endDelimiter:--// -- ---------------------------------------------------------------------------- do language plpgsql $$ diff --git a/src/main/resources/db/changelog/5-hs-office/510-membership/5108-hs-office-membership-test-data.sql b/src/main/resources/db/changelog/5-hs-office/510-membership/5108-hs-office-membership-test-data.sql index f67424a9..b5355871 100644 --- a/src/main/resources/db/changelog/5-hs-office/510-membership/5108-hs-office-membership-test-data.sql +++ b/src/main/resources/db/changelog/5-hs-office/510-membership/5108-hs-office-membership-test-data.sql @@ -28,7 +28,7 @@ end; $$; -- ============================================================================ ---changeset michael.hoennig:hs-office-membership-TEST-DATA-GENERATION –context=dev,tc endDelimiter:--// +--changeset michael.hoennig:hs-office-membership-TEST-DATA-GENERATION context:!without-test-data endDelimiter:--// -- ---------------------------------------------------------------------------- do language plpgsql $$ diff --git a/src/main/resources/db/changelog/5-hs-office/511-coopshares/5118-hs-office-coopshares-test-data.sql b/src/main/resources/db/changelog/5-hs-office/511-coopshares/5118-hs-office-coopshares-test-data.sql index 5dd06009..b5d5e5a2 100644 --- a/src/main/resources/db/changelog/5-hs-office/511-coopshares/5118-hs-office-coopshares-test-data.sql +++ b/src/main/resources/db/changelog/5-hs-office/511-coopshares/5118-hs-office-coopshares-test-data.sql @@ -38,7 +38,7 @@ end; $$; -- ============================================================================ ---changeset michael.hoennig:hs-office-coopSharesTransaction-TEST-DATA-GENERATION –context=dev,tc endDelimiter:--// +--changeset michael.hoennig:hs-office-coopSharesTransaction-TEST-DATA-GENERATION context:!without-test-data endDelimiter:--// -- ---------------------------------------------------------------------------- do language plpgsql $$ diff --git a/src/main/resources/db/changelog/5-hs-office/512-coopassets/5128-hs-office-coopassets-test-data.sql b/src/main/resources/db/changelog/5-hs-office/512-coopassets/5128-hs-office-coopassets-test-data.sql index 2ce3186b..78cf0302 100644 --- a/src/main/resources/db/changelog/5-hs-office/512-coopassets/5128-hs-office-coopassets-test-data.sql +++ b/src/main/resources/db/changelog/5-hs-office/512-coopassets/5128-hs-office-coopassets-test-data.sql @@ -44,7 +44,7 @@ end; $$; -- ============================================================================ ---changeset michael.hoennig:hs-office-coopAssetsTransaction-TEST-DATA-GENERATION –context=dev,tc endDelimiter:--// +--changeset michael.hoennig:hs-office-coopAssetsTransaction-TEST-DATA-GENERATION context:!without-test-data endDelimiter:--// -- ---------------------------------------------------------------------------- do language plpgsql $$ diff --git a/src/main/resources/db/changelog/6-hs-booking/620-booking-project/6208-hs-booking-project-test-data.sql b/src/main/resources/db/changelog/6-hs-booking/620-booking-project/6208-hs-booking-project-test-data.sql index a5dd9596..6773973c 100644 --- a/src/main/resources/db/changelog/6-hs-booking/620-booking-project/6208-hs-booking-project-test-data.sql +++ b/src/main/resources/db/changelog/6-hs-booking/620-booking-project/6208-hs-booking-project-test-data.sql @@ -34,7 +34,7 @@ end; $$; -- ============================================================================ ---changeset michael.hoennig:hs-booking-project-TEST-DATA-GENERATION –context=dev,tc endDelimiter:--// +--changeset michael.hoennig:hs-booking-project-TEST-DATA-GENERATION context:!without-test-data endDelimiter:--// -- ---------------------------------------------------------------------------- do language plpgsql $$ diff --git a/src/main/resources/db/changelog/6-hs-booking/630-booking-item/6308-hs-booking-item-test-data.sql b/src/main/resources/db/changelog/6-hs-booking/630-booking-item/6308-hs-booking-item-test-data.sql index a0b7470a..12c9d254 100644 --- a/src/main/resources/db/changelog/6-hs-booking/630-booking-item/6308-hs-booking-item-test-data.sql +++ b/src/main/resources/db/changelog/6-hs-booking/630-booking-item/6308-hs-booking-item-test-data.sql @@ -40,7 +40,7 @@ end; $$; -- ============================================================================ ---changeset michael.hoennig:hs-booking-item-TEST-DATA-GENERATION –context=dev,tc endDelimiter:--// +--changeset michael.hoennig:hs-booking-item-TEST-DATA-GENERATION context:!without-test-data endDelimiter:--// -- ---------------------------------------------------------------------------- do language plpgsql $$ diff --git a/src/main/resources/db/changelog/7-hs-hosting/701-hosting-asset/7018-hs-hosting-asset-test-data.sql b/src/main/resources/db/changelog/7-hs-hosting/701-hosting-asset/7018-hs-hosting-asset-test-data.sql index 99b9f6f7..7337101d 100644 --- a/src/main/resources/db/changelog/7-hs-hosting/701-hosting-asset/7018-hs-hosting-asset-test-data.sql +++ b/src/main/resources/db/changelog/7-hs-hosting/701-hosting-asset/7018-hs-hosting-asset-test-data.sql @@ -105,7 +105,7 @@ end; $$; -- ============================================================================ ---changeset michael.hoennig:hs-hosting-asset-TEST-DATA-GENERATION –context=dev,tc endDelimiter:--// +--changeset michael.hoennig:hs-hosting-asset-TEST-DATA-GENERATION context:!without-test-data endDelimiter:--// -- ---------------------------------------------------------------------------- do language plpgsql $$ diff --git a/src/main/resources/db/changelog/db.changelog-master.yaml b/src/main/resources/db/changelog/db.changelog-master.yaml index 19cb724f..2eb8908c 100644 --- a/src/main/resources/db/changelog/db.changelog-master.yaml +++ b/src/main/resources/db/changelog/db.changelog-master.yaml @@ -53,34 +53,34 @@ databaseChangeLog: - include: file: db/changelog/2-rbactest/200-rbactest-schema.sql - context: rbac-test + context: "!without-test-data" - include: file: db/changelog/2-rbactest/201-rbactest-customer/2010-rbactest-customer.sql - context: rbac-test + context: "!without-test-data" - include: file: db/changelog/2-rbactest/201-rbactest-customer/2013-rbactest-customer-rbac.sql - context: rbac-test + context: "!without-test-data" - include: file: db/changelog/2-rbactest/201-rbactest-customer/2018-rbactest-customer-test-data.sql - context: rbac-test + context: "!without-test-data" - include: file: db/changelog/2-rbactest/202-rbactest-package/2020-rbactest-package.sql - context: rbac-test + context: "!without-test-data" - include: file: db/changelog/2-rbactest/202-rbactest-package/2023-rbactest-package-rbac.sql - context: rbac-test + context: "!without-test-data" - include: file: db/changelog/2-rbactest/202-rbactest-package/2028-rbactest-package-test-data.sql - context: rbac-test + context: "!without-test-data" - include: file: db/changelog/2-rbactest/203-rbactest-domain/2030-rbactest-domain.sql - context: rbac-test + context: "!without-test-data" - include: file: db/changelog/2-rbactest/203-rbactest-domain/2033-rbactest-domain-rbac.sql - context: rbac-test + context: "!without-test-data" - include: file: db/changelog/2-rbactest/203-rbactest-domain/2038-rbactest-domain-test-data.sql - context: rbac-test + context: "!without-test-data" - include: file: db/changelog/5-hs-office/500-hs-office-schema.sql @@ -92,21 +92,21 @@ databaseChangeLog: file: db/changelog/5-hs-office/501-contact/5016-hs-office-contact-migration.sql - include: file: db/changelog/5-hs-office/501-contact/5018-hs-office-contact-test-data.sql - context: office-test + context: "!without-test-data" - include: file: db/changelog/5-hs-office/502-person/5020-hs-office-person.sql - include: file: db/changelog/5-hs-office/502-person/5023-hs-office-person-rbac.sql - include: file: db/changelog/5-hs-office/502-person/5028-hs-office-person-test-data.sql - context: office-test + context: "!without-test-data" - include: file: db/changelog/5-hs-office/503-relation/5030-hs-office-relation.sql - include: file: db/changelog/5-hs-office/503-relation/5033-hs-office-relation-rbac.sql - include: file: db/changelog/5-hs-office/503-relation/5038-hs-office-relation-test-data.sql - context: office-test + context: "!without-test-data" - include: file: db/changelog/5-hs-office/504-partner/5040-hs-office-partner.sql - include: @@ -117,21 +117,21 @@ databaseChangeLog: file: db/changelog/5-hs-office/504-partner/5046-hs-office-partner-migration.sql - include: file: db/changelog/5-hs-office/504-partner/5048-hs-office-partner-test-data.sql - context: office-test + context: "!without-test-data" - include: file: db/changelog/5-hs-office/505-bankaccount/5050-hs-office-bankaccount.sql - include: file: db/changelog/5-hs-office/505-bankaccount/5053-hs-office-bankaccount-rbac.sql - include: file: db/changelog/5-hs-office/505-bankaccount/5058-hs-office-bankaccount-test-data.sql - context: office-test + context: "!without-test-data" - include: file: db/changelog/5-hs-office/506-debitor/5060-hs-office-debitor.sql - include: file: db/changelog/5-hs-office/506-debitor/5063-hs-office-debitor-rbac.sql - include: file: db/changelog/5-hs-office/506-debitor/5068-hs-office-debitor-test-data.sql - context: office-test + context: "!without-test-data" - include: file: db/changelog/5-hs-office/507-sepamandate/5070-hs-office-sepamandate.sql - include: @@ -140,14 +140,14 @@ databaseChangeLog: file: db/changelog/5-hs-office/507-sepamandate/5076-hs-office-sepamandate-migration.sql - include: file: db/changelog/5-hs-office/507-sepamandate/5078-hs-office-sepamandate-test-data.sql - context: office-test + context: "!without-test-data" - include: file: db/changelog/5-hs-office/510-membership/5100-hs-office-membership.sql - include: file: db/changelog/5-hs-office/510-membership/5103-hs-office-membership-rbac.sql - include: file: db/changelog/5-hs-office/510-membership/5108-hs-office-membership-test-data.sql - context: office-test + context: "!without-test-data" - include: file: db/changelog/5-hs-office/511-coopshares/5110-hs-office-coopshares.sql - include: @@ -156,7 +156,7 @@ databaseChangeLog: file: db/changelog/5-hs-office/511-coopshares/5116-hs-office-coopshares-migration.sql - include: file: db/changelog/5-hs-office/511-coopshares/5118-hs-office-coopshares-test-data.sql - context: office-test + context: "!without-test-data" - include: file: db/changelog/5-hs-office/512-coopassets/5120-hs-office-coopassets.sql - include: @@ -165,52 +165,52 @@ databaseChangeLog: file: db/changelog/5-hs-office/512-coopassets/5126-hs-office-coopassets-migration.sql - include: file: db/changelog/5-hs-office/512-coopassets/5128-hs-office-coopassets-test-data.sql - context: office-test + context: "!without-test-data" - include: file: db/changelog/6-hs-booking/600-hs-booking-schema.sql - context: booking + context: "!only-office" - include: file: db/changelog/6-hs-booking/610-booking-debitor/6100-hs-booking-debitor.sql - context: booking + context: "!only-office" - include: file: db/changelog/6-hs-booking/620-booking-project/6200-hs-booking-project.sql - context: booking + context: "!only-office" - include: file: db/changelog/6-hs-booking/620-booking-project/6203-hs-booking-project-rbac.sql - context: booking + context: "!only-office" - include: file: db/changelog/6-hs-booking/620-booking-project/6208-hs-booking-project-test-data.sql - context: booking-test + context: "!only-office and !without-test-data" - include: file: db/changelog/6-hs-booking/630-booking-item/6300-hs-booking-item.sql - context: booking + context: "!only-office" - include: file: db/changelog/6-hs-booking/630-booking-item/6303-hs-booking-item-rbac.sql - context: booking + context: "!only-office" - include: file: db/changelog/6-hs-booking/630-booking-item/6308-hs-booking-item-test-data.sql - context: booking-test + context: "!only-office and !without-test-data" - include: file: db/changelog/7-hs-hosting/700-hs-hosting-schema.sql - context: hosting + context: "!only-office" - include: file: db/changelog/7-hs-hosting/701-hosting-asset/7010-hs-hosting-asset.sql - context: hosting + context: "!only-office" - include: file: db/changelog/7-hs-hosting/701-hosting-asset/7013-hs-hosting-asset-rbac.sql - context: hosting + context: "!only-office" - include: file: db/changelog/7-hs-hosting/701-hosting-asset/7016-hs-hosting-asset-migration.sql - context: hosting + context: "!only-office" - include: file: db/changelog/7-hs-hosting/701-hosting-asset/7018-hs-hosting-asset-test-data.sql - context: hosting-test + context: "!only-office and !without-test-data" - include: file: db/changelog/9-hs-global/9000-statistics.sql - context: hosting + context: "!only-office" - include: file: db/changelog/9-hs-global/9100-hs-integration-schema.sql diff --git a/src/test/java/net/hostsharing/hsadminng/config/ActuatorSanitizerUnitTest.java b/src/test/java/net/hostsharing/hsadminng/config/ActuatorSanitizerUnitTest.java index a804251e..6c0d0ae0 100644 --- a/src/test/java/net/hostsharing/hsadminng/config/ActuatorSanitizerUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/config/ActuatorSanitizerUnitTest.java @@ -9,7 +9,7 @@ import java.util.List; import static org.assertj.core.api.Assertions.assertThat; -class ActuatorSanitizerTest { +class ActuatorSanitizerUnitTest { private ActuatorSanitizer actuatorSanitizer; diff --git a/src/test/java/net/hostsharing/hsadminng/config/CasAuthenticationFilterIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/config/CasAuthenticationFilterIntegrationTest.java index 0c705e25..07169115 100644 --- a/src/test/java/net/hostsharing/hsadminng/config/CasAuthenticationFilterIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/config/CasAuthenticationFilterIntegrationTest.java @@ -17,7 +17,7 @@ import static org.apache.commons.lang3.RandomStringUtils.randomAlphanumeric; import static org.assertj.core.api.Assertions.assertThat; import static com.github.tomakehurst.wiremock.client.WireMock.*; @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@TestPropertySource(properties = "server.port=0") +@TestPropertySource(properties = {"server.port=0", "hsadminng.cas.server=http://localhost:8088/cas"}) @ActiveProfiles("wiremock") // IMPORTANT: To test prod config, do not use test profile! class CasAuthenticationFilterIntegrationTest { diff --git a/src/test/java/net/hostsharing/hsadminng/config/WebSecurityConfigIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/config/WebSecurityConfigIntegrationTest.java index 00444c3a..6991176e 100644 --- a/src/test/java/net/hostsharing/hsadminng/config/WebSecurityConfigIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/config/WebSecurityConfigIntegrationTest.java @@ -22,7 +22,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; import static org.assertj.core.api.Assertions.assertThat; @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@TestPropertySource(properties = {"management.port=0", "server.port=0"}) +@TestPropertySource(properties = {"management.port=0", "server.port=0", "hsadminng.cas.server=http://localhost:8088/cas"}) @ActiveProfiles("wiremock") // IMPORTANT: To test prod config, do not use test profile! class WebSecurityConfigIntegrationTest { diff --git a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java index ab3b3d08..11293384 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java @@ -46,7 +46,7 @@ import static org.hamcrest.Matchers.matchesRegex; webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = { HsadminNgApplication.class, DisableSecurityConfig.class, JpaAttempt.class } ) -@ActiveProfiles("test") +@ActiveProfiles({"test", "booking", "hosting"}) @Transactional @TestClassOrder(ClassOrderer.OrderAnnotation.class) // fail early on fetching problems class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup { diff --git a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerRestTest.java b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerRestTest.java index 0d7b11f7..aa904bf5 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerRestTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerRestTest.java @@ -42,7 +42,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @WebMvcTest(HsBookingItemController.class) @Import({StrictMapper.class, JsonObjectMapperConfiguration.class, DisableSecurityConfig.class}) @RunWith(SpringRunner.class) -@ActiveProfiles("test") +@ActiveProfiles({"test", "booking", "hosting"}) class HsBookingItemControllerRestTest { @Autowired diff --git a/src/test/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectControllerAcceptanceTest.java index 37b54e7e..bd7a65ed 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectControllerAcceptanceTest.java @@ -27,7 +27,7 @@ import static org.hamcrest.Matchers.matchesRegex; webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = { HsadminNgApplication.class, DisableSecurityConfig.class, JpaAttempt.class } ) -@ActiveProfiles("test") +@ActiveProfiles({"test", "booking", "hosting"}) @Transactional class HsBookingProjectControllerAcceptanceTest extends ContextBasedTestWithCleanup { diff --git a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerAcceptanceTest.java index ea7c93b1..4680d661 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerAcceptanceTest.java @@ -47,7 +47,7 @@ import static org.hamcrest.Matchers.matchesRegex; webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = { HsadminNgApplication.class, DisableSecurityConfig.class, DisableSecurityConfig.class, JpaAttempt.class } ) -@ActiveProfiles("test") +@ActiveProfiles({"test", "hosting"}) @TestClassOrder(ClassOrderer.OrderAnnotation.class) // fail early on fetching problems class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup { diff --git a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerRestTest.java b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerRestTest.java index 3b10e26e..d55bc92b 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerRestTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerRestTest.java @@ -56,7 +56,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @WebMvcTest(HsHostingAssetController.class) @Import({ StrictMapper.class, JsonObjectMapperConfiguration.class, DisableSecurityConfig.class }) @RunWith(SpringRunner.class) -@ActiveProfiles("test") +@ActiveProfiles({"test", "hosting"}) public class HsHostingAssetControllerRestTest { @Autowired diff --git a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetPropsControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetPropsControllerAcceptanceTest.java index de7dd82d..cc802f8d 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetPropsControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetPropsControllerAcceptanceTest.java @@ -15,7 +15,7 @@ import static net.hostsharing.hsadminng.test.JsonMatcher.lenientlyEquals; webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = { HsadminNgApplication.class, DisableSecurityConfig.class, JpaAttempt.class } ) -@ActiveProfiles("test") +@ActiveProfiles({"test", "hosting"}) class HsHostingAssetPropsControllerAcceptanceTest { @LocalServerPort diff --git a/src/test/java/net/hostsharing/hsadminng/hs/migration/ImportHostingAssets.java b/src/test/java/net/hostsharing/hsadminng/hs/migration/ImportHostingAssets.java index a831f637..256de796 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/migration/ImportHostingAssets.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/migration/ImportHostingAssets.java @@ -32,6 +32,7 @@ import org.springframework.context.annotation.Import; import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import org.springframework.test.annotation.Commit; import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.ActiveProfiles; import java.io.Reader; import java.net.IDN; @@ -121,6 +122,7 @@ import static org.assertj.core.api.Assumptions.assumeThat; }) @DirtiesContext @Import({ Context.class, JpaAttempt.class }) +@ActiveProfiles("without-test-data") @TestMethodOrder(MethodOrderer.OrderAnnotation.class) @ExtendWith(OrderedDependedTestsExtension.class) public class ImportHostingAssets extends BaseOfficeDataImport { diff --git a/src/test/java/net/hostsharing/hsadminng/hs/migration/ImportOfficeData.java b/src/test/java/net/hostsharing/hsadminng/hs/migration/ImportOfficeData.java index 5f632f88..c3111c01 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/migration/ImportOfficeData.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/migration/ImportOfficeData.java @@ -7,6 +7,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.context.annotation.Import; import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.ActiveProfiles; /* * This 'test' includes the complete legacy 'office' data import. @@ -51,6 +52,7 @@ import org.springframework.test.annotation.DirtiesContext; "spring.datasource.password=${HSADMINNG_POSTGRES_ADMIN_PASSWORD:password}", "hsadminng.superuser=${HSADMINNG_SUPERUSER:superuser-alex@hostsharing.net}" }) +@ActiveProfiles("without-test-data") @DirtiesContext @Import({ Context.class, JpaAttempt.class }) @TestMethodOrder(MethodOrderer.OrderAnnotation.class) -- 2.39.5 From f02678581274f57f3b820f58567da8f182d2d126 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Mon, 20 Jan 2025 10:23:44 +0100 Subject: [PATCH 13/18] remove booking+hosting profile references --- .../hs/booking/item/HsBookingItemControllerAcceptanceTest.java | 2 +- .../hs/booking/item/HsBookingItemControllerRestTest.java | 2 +- .../project/HsBookingProjectControllerAcceptanceTest.java | 2 +- .../hosting/asset/HsHostingAssetControllerAcceptanceTest.java | 2 +- .../hs/hosting/asset/HsHostingAssetControllerRestTest.java | 2 +- .../asset/HsHostingAssetPropsControllerAcceptanceTest.java | 2 +- src/test/resources/application.yml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java index 11293384..ab3b3d08 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java @@ -46,7 +46,7 @@ import static org.hamcrest.Matchers.matchesRegex; webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = { HsadminNgApplication.class, DisableSecurityConfig.class, JpaAttempt.class } ) -@ActiveProfiles({"test", "booking", "hosting"}) +@ActiveProfiles("test") @Transactional @TestClassOrder(ClassOrderer.OrderAnnotation.class) // fail early on fetching problems class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup { diff --git a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerRestTest.java b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerRestTest.java index aa904bf5..0d7b11f7 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerRestTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerRestTest.java @@ -42,7 +42,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @WebMvcTest(HsBookingItemController.class) @Import({StrictMapper.class, JsonObjectMapperConfiguration.class, DisableSecurityConfig.class}) @RunWith(SpringRunner.class) -@ActiveProfiles({"test", "booking", "hosting"}) +@ActiveProfiles("test") class HsBookingItemControllerRestTest { @Autowired diff --git a/src/test/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectControllerAcceptanceTest.java index bd7a65ed..37b54e7e 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectControllerAcceptanceTest.java @@ -27,7 +27,7 @@ import static org.hamcrest.Matchers.matchesRegex; webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = { HsadminNgApplication.class, DisableSecurityConfig.class, JpaAttempt.class } ) -@ActiveProfiles({"test", "booking", "hosting"}) +@ActiveProfiles("test") @Transactional class HsBookingProjectControllerAcceptanceTest extends ContextBasedTestWithCleanup { diff --git a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerAcceptanceTest.java index 4680d661..ea7c93b1 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerAcceptanceTest.java @@ -47,7 +47,7 @@ import static org.hamcrest.Matchers.matchesRegex; webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = { HsadminNgApplication.class, DisableSecurityConfig.class, DisableSecurityConfig.class, JpaAttempt.class } ) -@ActiveProfiles({"test", "hosting"}) +@ActiveProfiles("test") @TestClassOrder(ClassOrderer.OrderAnnotation.class) // fail early on fetching problems class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup { diff --git a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerRestTest.java b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerRestTest.java index d55bc92b..3b10e26e 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerRestTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerRestTest.java @@ -56,7 +56,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @WebMvcTest(HsHostingAssetController.class) @Import({ StrictMapper.class, JsonObjectMapperConfiguration.class, DisableSecurityConfig.class }) @RunWith(SpringRunner.class) -@ActiveProfiles({"test", "hosting"}) +@ActiveProfiles("test") public class HsHostingAssetControllerRestTest { @Autowired diff --git a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetPropsControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetPropsControllerAcceptanceTest.java index cc802f8d..de7dd82d 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetPropsControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetPropsControllerAcceptanceTest.java @@ -15,7 +15,7 @@ import static net.hostsharing.hsadminng.test.JsonMatcher.lenientlyEquals; webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = { HsadminNgApplication.class, DisableSecurityConfig.class, JpaAttempt.class } ) -@ActiveProfiles({"test", "hosting"}) +@ActiveProfiles("test") class HsHostingAssetPropsControllerAcceptanceTest { @LocalServerPort diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml index 4693d1bf..344828e7 100644 --- a/src/test/resources/application.yml +++ b/src/test/resources/application.yml @@ -37,7 +37,7 @@ spring: liquibase: change-log: classpath:/db/changelog/db.changelog-master.yaml - contexts: tc,test,dev,pg_stat_statements,rbac-test,office,office-test,booking,booking-test,hosting,hosting-test + contexts: tc,test,dev,pg_stat_statements # keep this in sync with main/.../application.yml springdoc: -- 2.39.5 From af8536d4a022279bd331bbedf2d54eb9036fa85b Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Mon, 20 Jan 2025 16:57:19 +0100 Subject: [PATCH 14/18] @Tag("...IntegrationTest") for integration+acceptance-tests where ... is the module name or general --- .../config/CasAuthenticationFilterIntegrationTest.java | 2 ++ .../hsadminng/config/CustomActuatorEndpointAcceptanceTest.java | 2 ++ .../hsadminng/config/WebSecurityConfigIntegrationTest.java | 2 ++ .../hs/booking/item/HsBookingItemControllerAcceptanceTest.java | 2 ++ .../hs/booking/item/HsBookingItemRepositoryIntegrationTest.java | 2 ++ .../project/HsBookingProjectControllerAcceptanceTest.java | 2 ++ .../project/HsBookingProjectRepositoryIntegrationTest.java | 2 ++ .../hosting/asset/HsHostingAssetControllerAcceptanceTest.java | 2 ++ .../asset/HsHostingAssetPropsControllerAcceptanceTest.java | 2 ++ .../hosting/asset/HsHostingAssetRepositoryIntegrationTest.java | 2 ++ .../HsOfficeBankAccountControllerAcceptanceTest.java | 1 + .../HsOfficeBankAccountRepositoryIntegrationTest.java | 2 ++ .../office/contact/HsOfficeContactControllerAcceptanceTest.java | 2 ++ .../contact/HsOfficeContactRbacRepositoryIntegrationTest.java | 2 ++ .../HsOfficeCoopAssetsTransactionControllerAcceptanceTest.java | 2 ++ .../HsOfficeCoopAssetsTransactionRepositoryIntegrationTest.java | 2 ++ .../HsOfficeCoopSharesTransactionControllerAcceptanceTest.java | 2 ++ .../HsOfficeCoopSharesTransactionRepositoryIntegrationTest.java | 2 ++ .../office/debitor/HsOfficeDebitorControllerAcceptanceTest.java | 2 ++ .../debitor/HsOfficeDebitorRepositoryIntegrationTest.java | 2 ++ .../membership/HsOfficeMembershipControllerAcceptanceTest.java | 2 ++ .../membership/HsOfficeMembershipRepositoryIntegrationTest.java | 2 ++ .../office/partner/HsOfficePartnerControllerAcceptanceTest.java | 1 + .../partner/HsOfficePartnerRbacRepositoryIntegrationTest.java | 2 ++ .../office/person/HsOfficePersonControllerAcceptanceTest.java | 2 ++ .../person/HsOfficePersonRbacRepositoryIntegrationTest.java | 2 ++ .../person/HsOfficePersonRealRepositoryIntegrationTest.java | 2 ++ .../relation/HsOfficeRealRelationRepositoryIntegrationTest.java | 2 ++ .../relation/HsOfficeRelationControllerAcceptanceTest.java | 2 ++ .../relation/HsOfficeRelationRepositoryIntegrationTest.java | 2 ++ .../HsOfficeSepaMandateControllerAcceptanceTest.java | 2 ++ .../HsOfficeSepaMandateRepositoryIntegrationTest.java | 2 ++ .../hsadminng/mapper/PostgresArrayIntegrationTest.java | 2 ++ .../hsadminng/rbac/grant/RbacGrantControllerAcceptanceTest.java | 2 ++ .../rbac/grant/RbacGrantRepositoryIntegrationTest.java | 2 ++ .../rbac/grant/RbacGrantsDiagramServiceIntegrationTest.java | 2 ++ .../hsadminng/rbac/role/RbacRoleControllerAcceptanceTest.java | 2 ++ .../hsadminng/rbac/role/RbacRoleRepositoryIntegrationTest.java | 2 ++ .../rbac/subject/RbacSubjectControllerAcceptanceTest.java | 2 ++ .../rbac/subject/RbacSubjectRepositoryIntegrationTest.java | 2 ++ .../rbac/test/cust/TestCustomerControllerAcceptanceTest.java | 2 ++ .../rbac/test/cust/TestCustomerRepositoryIntegrationTest.java | 2 ++ .../rbac/test/pac/TestPackageControllerAcceptanceTest.java | 2 ++ .../rbac/test/pac/TestPackageRepositoryIntegrationTest.java | 2 ++ 44 files changed, 86 insertions(+) diff --git a/src/test/java/net/hostsharing/hsadminng/config/CasAuthenticationFilterIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/config/CasAuthenticationFilterIntegrationTest.java index 07169115..eb00cf33 100644 --- a/src/test/java/net/hostsharing/hsadminng/config/CasAuthenticationFilterIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/config/CasAuthenticationFilterIntegrationTest.java @@ -1,6 +1,7 @@ package net.hostsharing.hsadminng.config; import com.github.tomakehurst.wiremock.WireMockServer; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -19,6 +20,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.*; @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @TestPropertySource(properties = {"server.port=0", "hsadminng.cas.server=http://localhost:8088/cas"}) @ActiveProfiles("wiremock") // IMPORTANT: To test prod config, do not use test profile! +@Tag("generalIntegrationTest") class CasAuthenticationFilterIntegrationTest { @Value("${local.server.port}") diff --git a/src/test/java/net/hostsharing/hsadminng/config/CustomActuatorEndpointAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/config/CustomActuatorEndpointAcceptanceTest.java index 251804e2..35c010c3 100644 --- a/src/test/java/net/hostsharing/hsadminng/config/CustomActuatorEndpointAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/config/CustomActuatorEndpointAcceptanceTest.java @@ -2,6 +2,7 @@ package net.hostsharing.hsadminng.config; import io.restassured.RestAssured; import net.hostsharing.hsadminng.HsadminNgApplication; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.server.LocalManagementPort; @@ -14,6 +15,7 @@ import static net.hostsharing.hsadminng.test.JsonMatcher.lenientlyEquals; classes = { HsadminNgApplication.class, DisableSecurityConfig.class } ) @ActiveProfiles("test") +@Tag("generalIntegrationTest") class CustomActuatorEndpointAcceptanceTest { @LocalManagementPort diff --git a/src/test/java/net/hostsharing/hsadminng/config/WebSecurityConfigIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/config/WebSecurityConfigIntegrationTest.java index 6991176e..3a612b35 100644 --- a/src/test/java/net/hostsharing/hsadminng/config/WebSecurityConfigIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/config/WebSecurityConfigIntegrationTest.java @@ -3,6 +3,7 @@ package net.hostsharing.hsadminng.config; import java.util.Map; import com.github.tomakehurst.wiremock.WireMockServer; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -24,6 +25,7 @@ import static org.assertj.core.api.Assertions.assertThat; @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @TestPropertySource(properties = {"management.port=0", "server.port=0", "hsadminng.cas.server=http://localhost:8088/cas"}) @ActiveProfiles("wiremock") // IMPORTANT: To test prod config, do not use test profile! +@Tag("generalIntegrationTest") class WebSecurityConfigIntegrationTest { @Value("${local.server.port}") diff --git a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java index ab3b3d08..cf47bbe9 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java @@ -19,6 +19,7 @@ import org.junit.jupiter.api.ClassOrderer; import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestClassOrder; import org.junit.jupiter.api.TestMethodOrder; @@ -49,6 +50,7 @@ import static org.hamcrest.Matchers.matchesRegex; @ActiveProfiles("test") @Transactional @TestClassOrder(ClassOrderer.OrderAnnotation.class) // fail early on fetching problems +@Tag("bookingIntegrationTest") class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup { @LocalServerPort diff --git a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRepositoryIntegrationTest.java index 9a222b0c..19bb96d8 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRepositoryIntegrationTest.java @@ -10,6 +10,7 @@ import net.hostsharing.hsadminng.mapper.Array; import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup; import net.hostsharing.hsadminng.rbac.test.JpaAttempt; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; @@ -38,6 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat; @DataJpaTest @Import({ Context.class, JpaAttempt.class }) +@Tag("bookingIntegrationTest") class HsBookingItemRepositoryIntegrationTest extends ContextBasedTestWithCleanup { @Autowired diff --git a/src/test/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectControllerAcceptanceTest.java index 37b54e7e..7b072f4e 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectControllerAcceptanceTest.java @@ -8,6 +8,7 @@ import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup; import net.hostsharing.hsadminng.rbac.test.JpaAttempt; import net.hostsharing.hsadminng.config.DisableSecurityConfig; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -29,6 +30,7 @@ import static org.hamcrest.Matchers.matchesRegex; ) @ActiveProfiles("test") @Transactional +@Tag("bookingIntegrationTest") class HsBookingProjectControllerAcceptanceTest extends ContextBasedTestWithCleanup { @LocalServerPort diff --git a/src/test/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRepositoryIntegrationTest.java index 971b1ba8..e88edcb2 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRepositoryIntegrationTest.java @@ -8,6 +8,7 @@ import net.hostsharing.hsadminng.mapper.Array; import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup; import net.hostsharing.hsadminng.rbac.test.JpaAttempt; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.EnumSource; @@ -33,6 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat; @DataJpaTest @Import({ Context.class, JpaAttempt.class }) +@Tag("bookingIntegrationTest") class HsBookingProjectRepositoryIntegrationTest extends ContextBasedTestWithCleanup { @Autowired diff --git a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerAcceptanceTest.java index ea7c93b1..3682f226 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerAcceptanceTest.java @@ -19,6 +19,7 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.ClassOrderer; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestClassOrder; import org.springframework.beans.factory.annotation.Autowired; @@ -49,6 +50,7 @@ import static org.hamcrest.Matchers.matchesRegex; ) @ActiveProfiles("test") @TestClassOrder(ClassOrderer.OrderAnnotation.class) // fail early on fetching problems +@Tag("hostingIntegrationTest") class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup { @LocalServerPort diff --git a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetPropsControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetPropsControllerAcceptanceTest.java index de7dd82d..1bdfe9bb 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetPropsControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetPropsControllerAcceptanceTest.java @@ -4,6 +4,7 @@ import io.restassured.RestAssured; import net.hostsharing.hsadminng.HsadminNgApplication; import net.hostsharing.hsadminng.rbac.test.JpaAttempt; import net.hostsharing.hsadminng.config.DisableSecurityConfig; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.server.LocalServerPort; @@ -16,6 +17,7 @@ import static net.hostsharing.hsadminng.test.JsonMatcher.lenientlyEquals; classes = { HsadminNgApplication.class, DisableSecurityConfig.class, JpaAttempt.class } ) @ActiveProfiles("test") +@Tag("hostingIntegrationTest") class HsHostingAssetPropsControllerAcceptanceTest { @LocalServerPort diff --git a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRepositoryIntegrationTest.java index 4024d16f..7417313b 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRepositoryIntegrationTest.java @@ -12,6 +12,7 @@ import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup; import net.hostsharing.hsadminng.rbac.test.JpaAttempt; import org.hibernate.exception.ConstraintViolationException; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.EnumSource; @@ -44,6 +45,7 @@ import static org.assertj.core.api.Assertions.assertThat; @DataJpaTest @Import({ Context.class, JpaAttempt.class }) +@Tag("hostingIntegrationTest") class HsHostingAssetRepositoryIntegrationTest extends ContextBasedTestWithCleanup { @Autowired diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountControllerAcceptanceTest.java index a81c220c..f42041aa 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountControllerAcceptanceTest.java @@ -32,6 +32,7 @@ import static org.hamcrest.Matchers.startsWith; ) @ActiveProfiles("test") @Transactional +@Tag("officeIntegrationTest") class HsOfficeBankAccountControllerAcceptanceTest extends ContextBasedTestWithCleanup { @LocalServerPort diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepositoryIntegrationTest.java index 7a95b503..62272655 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepositoryIntegrationTest.java @@ -8,6 +8,7 @@ import net.hostsharing.hsadminng.mapper.Array; import net.hostsharing.hsadminng.rbac.test.JpaAttempt; import org.apache.commons.lang3.RandomStringUtils; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; @@ -29,6 +30,7 @@ import static org.assertj.core.api.Assertions.assertThat; @DataJpaTest @Import({ Context.class, JpaAttempt.class }) +@Tag("officeIntegrationTest") class HsOfficeBankAccountRepositoryIntegrationTest extends ContextBasedTestWithCleanup { @Autowired diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactControllerAcceptanceTest.java index da6a380f..bf4141b8 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactControllerAcceptanceTest.java @@ -12,6 +12,7 @@ import org.json.JSONException; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -39,6 +40,7 @@ import static org.hamcrest.Matchers.startsWith; ) @ActiveProfiles("test") @Transactional +@Tag("officeIntegrationTest") class HsOfficeContactControllerAcceptanceTest extends ContextBasedTestWithCleanup { @LocalServerPort diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactRbacRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactRbacRepositoryIntegrationTest.java index 7e652325..2073057c 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactRbacRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactRbacRepositoryIntegrationTest.java @@ -8,6 +8,7 @@ import net.hostsharing.hsadminng.mapper.Array; import net.hostsharing.hsadminng.rbac.test.JpaAttempt; import org.apache.commons.lang3.RandomStringUtils; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; @@ -29,6 +30,7 @@ import static org.assertj.core.api.Assertions.assertThat; @DataJpaTest @Import( { Context.class, JpaAttempt.class }) +@Tag("officeIntegrationTest") class HsOfficeContactRbacRepositoryIntegrationTest extends ContextBasedTestWithCleanup { @Autowired diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerAcceptanceTest.java index cceee9dd..40ba4ea3 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerAcceptanceTest.java @@ -11,6 +11,7 @@ import net.hostsharing.hsadminng.config.DisableSecurityConfig; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -37,6 +38,7 @@ import static org.hamcrest.Matchers.startsWith; ) @ActiveProfiles("test") @Transactional +@Tag("officeIntegrationTest") class HsOfficeCoopAssetsTransactionControllerAcceptanceTest extends ContextBasedTestWithCleanup { @LocalServerPort diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepositoryIntegrationTest.java index 706c8034..09cc75d1 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepositoryIntegrationTest.java @@ -10,6 +10,7 @@ import net.hostsharing.hsadminng.rbac.test.JpaAttempt; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; @@ -31,6 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat; @DataJpaTest @Import( { Context.class, JpaAttempt.class }) +@Tag("officeIntegrationTest") class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBasedTestWithCleanup { @Autowired diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerAcceptanceTest.java index 810f0a60..d4ed64f5 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionControllerAcceptanceTest.java @@ -11,6 +11,7 @@ import net.hostsharing.hsadminng.config.DisableSecurityConfig; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -34,6 +35,7 @@ import static org.hamcrest.Matchers.startsWith; classes = {HsadminNgApplication.class, DisableSecurityConfig.class, JpaAttempt.class}) @ActiveProfiles("test") @Transactional +@Tag("officeIntegrationTest") class HsOfficeCoopSharesTransactionControllerAcceptanceTest extends ContextBasedTestWithCleanup { @Autowired diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepositoryIntegrationTest.java index afeae8c3..24df54cd 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepositoryIntegrationTest.java @@ -10,6 +10,7 @@ import net.hostsharing.hsadminng.rbac.test.JpaAttempt; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; @@ -30,6 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat; @DataJpaTest @Import( { Context.class, JpaAttempt.class }) +@Tag("officeIntegrationTest") class HsOfficeCoopSharesTransactionRepositoryIntegrationTest extends ContextBasedTestWithCleanup { @Autowired diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorControllerAcceptanceTest.java index 98be1755..4a4b96dd 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorControllerAcceptanceTest.java @@ -16,6 +16,7 @@ import net.hostsharing.hsadminng.config.DisableSecurityConfig; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -43,6 +44,7 @@ import static org.hamcrest.Matchers.startsWith; ) @ActiveProfiles("test") @Transactional +@Tag("officeIntegrationTest") class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanup { private static final int LOWEST_TEMP_DEBITOR_SUFFIX = 90; diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepositoryIntegrationTest.java index 7989cf74..08ef791b 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepositoryIntegrationTest.java @@ -17,6 +17,7 @@ import net.hostsharing.hsadminng.rbac.test.JpaAttempt; import org.hibernate.Hibernate; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; @@ -42,6 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat; @DataJpaTest @Import( { Context.class, JpaAttempt.class, RbacGrantsDiagramService.class }) +@Tag("officeIntegrationTest") class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithCleanup { @Autowired diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipControllerAcceptanceTest.java index a2306ba8..08c88284 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipControllerAcceptanceTest.java @@ -12,6 +12,7 @@ import net.hostsharing.hsadminng.config.DisableSecurityConfig; import org.json.JSONException; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -37,6 +38,7 @@ import static org.hamcrest.Matchers.*; ) @ActiveProfiles("test") @Transactional +@Tag("officeIntegrationTest") class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCleanup { private static final String TEMP_MEMBER_NUMBER_SUFFIX = "90"; diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepositoryIntegrationTest.java index 44713c61..d078a01c 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepositoryIntegrationTest.java @@ -10,6 +10,7 @@ import net.hostsharing.hsadminng.rbac.role.RawRbacRoleRepository; import net.hostsharing.hsadminng.mapper.Array; import net.hostsharing.hsadminng.rbac.test.JpaAttempt; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; @@ -31,6 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat; @DataJpaTest @Import( { Context.class, JpaAttempt.class }) +@Tag("officeIntegrationTest") class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTestWithCleanup { @Autowired diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerAcceptanceTest.java index 8bfc7009..7afd9714 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerAcceptanceTest.java @@ -34,6 +34,7 @@ import static org.hamcrest.Matchers.*; classes = { HsadminNgApplication.class, DisableSecurityConfig.class, JpaAttempt.class } ) @ActiveProfiles("test") +@Tag("officeIntegrationTest") class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanup { private static final UUID GIVEN_NON_EXISTING_UUID = UUID.fromString("00000000-0000-0000-0000-000000000000"); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRbacRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRbacRepositoryIntegrationTest.java index 2b5dfe1b..0fbf6990 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRbacRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRbacRepositoryIntegrationTest.java @@ -13,6 +13,7 @@ import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup; import net.hostsharing.hsadminng.rbac.test.JpaAttempt; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; @@ -38,6 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat; @DataJpaTest @Import({ Context.class, JpaAttempt.class }) +@Tag("officeIntegrationTest") class HsOfficePartnerRbacRepositoryIntegrationTest extends ContextBasedTestWithCleanup { @Autowired diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonControllerAcceptanceTest.java index a2c21dac..7f6e48ca 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonControllerAcceptanceTest.java @@ -10,6 +10,7 @@ import net.hostsharing.hsadminng.config.DisableSecurityConfig; import org.apache.commons.lang3.RandomStringUtils; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -31,6 +32,7 @@ import static org.hamcrest.Matchers.*; classes = { HsadminNgApplication.class, DisableSecurityConfig.class, JpaAttempt.class } ) @ActiveProfiles("test") +@Tag("officeIntegrationTest") class HsOfficePersonControllerAcceptanceTest extends ContextBasedTestWithCleanup { @LocalServerPort diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRbacRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRbacRepositoryIntegrationTest.java index aff5561b..fb5f3454 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRbacRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRbacRepositoryIntegrationTest.java @@ -8,6 +8,7 @@ import net.hostsharing.hsadminng.mapper.Array; import net.hostsharing.hsadminng.rbac.test.JpaAttempt; import org.apache.commons.lang3.RandomStringUtils; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; @@ -29,6 +30,7 @@ import static org.assertj.core.api.Assertions.assertThat; @DataJpaTest @Import( { Context.class, JpaAttempt.class }) +@Tag("officeIntegrationTest") class HsOfficePersonRbacRepositoryIntegrationTest extends ContextBasedTestWithCleanup { @Autowired diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealRepositoryIntegrationTest.java index 0d89050e..45c24469 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealRepositoryIntegrationTest.java @@ -7,6 +7,7 @@ import net.hostsharing.hsadminng.rbac.role.RawRbacRoleRepository; import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup; import net.hostsharing.hsadminng.rbac.test.JpaAttempt; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; @@ -27,6 +28,7 @@ import static org.assertj.core.api.Assertions.assertThat; @DataJpaTest @Import( { Context.class, JpaAttempt.class }) +@Tag("officeIntegrationTest") class HsOfficePersonRealRepositoryIntegrationTest extends ContextBasedTestWithCleanup { @Autowired diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRealRelationRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRealRelationRepositoryIntegrationTest.java index 4c8f7b75..2f80a889 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRealRelationRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRealRelationRepositoryIntegrationTest.java @@ -6,6 +6,7 @@ import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType; import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup; import net.hostsharing.hsadminng.rbac.test.JpaAttempt; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; @@ -24,6 +25,7 @@ import static org.assertj.core.api.Assertions.assertThat; @DataJpaTest @Import( { Context.class, JpaAttempt.class }) +@Tag("officeIntegrationTest") class HsOfficeRealRelationRepositoryIntegrationTest extends ContextBasedTestWithCleanup { @Autowired diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java index 8e33c35a..c97ea650 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java @@ -11,6 +11,7 @@ import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeRelati import net.hostsharing.hsadminng.rbac.test.JpaAttempt; import net.hostsharing.hsadminng.config.DisableSecurityConfig; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -33,6 +34,7 @@ import static org.hamcrest.Matchers.hasEntry; ) @ActiveProfiles("test") @Transactional +@Tag("officeIntegrationTest") class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithCleanup { public static final UUID GIVEN_NON_EXISTING_HOLDER_PERSON_UUID = UUID.fromString("00000000-0000-0000-0000-000000000000"); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRepositoryIntegrationTest.java index df3bcf23..5417ac41 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRepositoryIntegrationTest.java @@ -10,6 +10,7 @@ import net.hostsharing.hsadminng.rbac.role.RawRbacRoleRepository; import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup; import net.hostsharing.hsadminng.rbac.test.JpaAttempt; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; @@ -32,6 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat; @DataJpaTest @Import({ Context.class, JpaAttempt.class }) +@Tag("officeIntegrationTest") class HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithCleanup { @Autowired diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateControllerAcceptanceTest.java index b8876423..4336334e 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateControllerAcceptanceTest.java @@ -12,6 +12,7 @@ import net.hostsharing.hsadminng.config.DisableSecurityConfig; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -36,6 +37,7 @@ import static org.hamcrest.Matchers.*; ) @ActiveProfiles("test") @Transactional +@Tag("officeIntegrationTest") class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCleanup { @LocalServerPort diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateRepositoryIntegrationTest.java index 3debf9f5..b9a49708 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateRepositoryIntegrationTest.java @@ -10,6 +10,7 @@ import net.hostsharing.hsadminng.rbac.role.RawRbacRoleRepository; import net.hostsharing.hsadminng.mapper.Array; import net.hostsharing.hsadminng.rbac.test.JpaAttempt; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; @@ -32,6 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat; @DataJpaTest @Import({ Context.class, JpaAttempt.class }) +@Tag("officeIntegrationTest") class HsOfficeSepaMandateRepositoryIntegrationTest extends ContextBasedTestWithCleanup { @Autowired diff --git a/src/test/java/net/hostsharing/hsadminng/mapper/PostgresArrayIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/mapper/PostgresArrayIntegrationTest.java index 3542caa1..6a73d76d 100644 --- a/src/test/java/net/hostsharing/hsadminng/mapper/PostgresArrayIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/mapper/PostgresArrayIntegrationTest.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.mapper; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; @@ -11,6 +12,7 @@ import java.util.UUID; import static org.assertj.core.api.Assertions.assertThat; @DataJpaTest +@Tag("generalIntegrationTest") class PostgresArrayIntegrationTest { @Autowired diff --git a/src/test/java/net/hostsharing/hsadminng/rbac/grant/RbacGrantControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/rbac/grant/RbacGrantControllerAcceptanceTest.java index 8f059572..bfd65b57 100644 --- a/src/test/java/net/hostsharing/hsadminng/rbac/grant/RbacGrantControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/rbac/grant/RbacGrantControllerAcceptanceTest.java @@ -13,6 +13,7 @@ import net.hostsharing.hsadminng.rbac.test.JpaAttempt; import net.hostsharing.hsadminng.config.DisableSecurityConfig; import org.apache.commons.lang3.RandomStringUtils; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -37,6 +38,7 @@ import static org.hamcrest.Matchers.*; ) @ActiveProfiles("test") @Transactional(readOnly = true, propagation = Propagation.NEVER) +@Tag("generalIntegrationTest") class RbacGrantControllerAcceptanceTest extends ContextBasedTest { @LocalServerPort diff --git a/src/test/java/net/hostsharing/hsadminng/rbac/grant/RbacGrantRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/rbac/grant/RbacGrantRepositoryIntegrationTest.java index 41c2e6fc..ee7e4f9c 100644 --- a/src/test/java/net/hostsharing/hsadminng/rbac/grant/RbacGrantRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/rbac/grant/RbacGrantRepositoryIntegrationTest.java @@ -7,6 +7,7 @@ import net.hostsharing.hsadminng.rbac.subject.RbacSubjectEntity; import net.hostsharing.hsadminng.rbac.subject.RbacSubjectRepository; import net.hostsharing.hsadminng.rbac.test.JpaAttempt; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; @@ -27,6 +28,7 @@ import static org.assertj.core.api.Assertions.assertThat; @DataJpaTest @Import( { Context.class, JpaAttempt.class }) +@Tag("generalIntegrationTest") class RbacGrantRepositoryIntegrationTest extends ContextBasedTest { @Autowired diff --git a/src/test/java/net/hostsharing/hsadminng/rbac/grant/RbacGrantsDiagramServiceIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/rbac/grant/RbacGrantsDiagramServiceIntegrationTest.java index 085854f1..4ad7ea43 100644 --- a/src/test/java/net/hostsharing/hsadminng/rbac/grant/RbacGrantsDiagramServiceIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/rbac/grant/RbacGrantsDiagramServiceIntegrationTest.java @@ -6,6 +6,7 @@ import net.hostsharing.hsadminng.rbac.grant.RbacGrantsDiagramService.Include; import net.hostsharing.hsadminng.rbac.test.JpaAttempt; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; import org.springframework.beans.factory.annotation.Autowired; @@ -23,6 +24,7 @@ import static org.assertj.core.api.Assertions.assertThat; @DataJpaTest @Import( { Context.class, JpaAttempt.class, RbacGrantsDiagramService.class}) +@Tag("generalIntegrationTest") class RbacGrantsDiagramServiceIntegrationTest extends ContextBasedTestWithCleanup { @Autowired diff --git a/src/test/java/net/hostsharing/hsadminng/rbac/role/RbacRoleControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/rbac/role/RbacRoleControllerAcceptanceTest.java index aa8c7727..c3a19fcc 100644 --- a/src/test/java/net/hostsharing/hsadminng/rbac/role/RbacRoleControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/rbac/role/RbacRoleControllerAcceptanceTest.java @@ -5,6 +5,7 @@ import net.hostsharing.hsadminng.HsadminNgApplication; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.rbac.subject.RbacSubjectRepository; import net.hostsharing.hsadminng.config.DisableSecurityConfig; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -18,6 +19,7 @@ import static org.hamcrest.Matchers.*; classes = {HsadminNgApplication.class, DisableSecurityConfig.class} ) @ActiveProfiles("test") +@Tag("generalIntegrationTest") class RbacRoleControllerAcceptanceTest { @LocalServerPort diff --git a/src/test/java/net/hostsharing/hsadminng/rbac/role/RbacRoleRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/rbac/role/RbacRoleRepositoryIntegrationTest.java index 292305e5..c77b70f4 100644 --- a/src/test/java/net/hostsharing/hsadminng/rbac/role/RbacRoleRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/rbac/role/RbacRoleRepositoryIntegrationTest.java @@ -4,6 +4,7 @@ import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.mapper.Array; import net.hostsharing.hsadminng.rbac.test.JpaAttempt; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; @@ -20,6 +21,7 @@ import static org.assertj.core.api.Assertions.assertThat; @DataJpaTest @Import( { Context.class, JpaAttempt.class }) +@Tag("generalIntegrationTest") class RbacRoleRepositoryIntegrationTest { @Autowired diff --git a/src/test/java/net/hostsharing/hsadminng/rbac/subject/RbacSubjectControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/rbac/subject/RbacSubjectControllerAcceptanceTest.java index 45d8dac8..bdc65e15 100644 --- a/src/test/java/net/hostsharing/hsadminng/rbac/subject/RbacSubjectControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/rbac/subject/RbacSubjectControllerAcceptanceTest.java @@ -7,6 +7,7 @@ import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.rbac.test.JpaAttempt; import net.hostsharing.hsadminng.config.DisableSecurityConfig; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -25,6 +26,7 @@ import static org.hamcrest.Matchers.*; ) @ActiveProfiles("test") @Transactional +@Tag("generalIntegrationTest") class RbacSubjectControllerAcceptanceTest { @LocalServerPort diff --git a/src/test/java/net/hostsharing/hsadminng/rbac/subject/RbacSubjectRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/rbac/subject/RbacSubjectRepositoryIntegrationTest.java index 00654d6e..32647892 100644 --- a/src/test/java/net/hostsharing/hsadminng/rbac/subject/RbacSubjectRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/rbac/subject/RbacSubjectRepositoryIntegrationTest.java @@ -5,6 +5,7 @@ import net.hostsharing.hsadminng.rbac.context.ContextBasedTest; import net.hostsharing.hsadminng.mapper.Array; import net.hostsharing.hsadminng.rbac.test.JpaAttempt; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; @@ -26,6 +27,7 @@ import static org.assertj.core.api.Assertions.assertThat; @DataJpaTest @Import( { Context.class, JpaAttempt.class }) +@Tag("generalIntegrationTest") class RbacSubjectRepositoryIntegrationTest extends ContextBasedTest { @Autowired diff --git a/src/test/java/net/hostsharing/hsadminng/rbac/test/cust/TestCustomerControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/rbac/test/cust/TestCustomerControllerAcceptanceTest.java index 1c210164..c6b3b3cf 100644 --- a/src/test/java/net/hostsharing/hsadminng/rbac/test/cust/TestCustomerControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/rbac/test/cust/TestCustomerControllerAcceptanceTest.java @@ -9,6 +9,7 @@ import net.hostsharing.hsadminng.config.DisableSecurityConfig; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -30,6 +31,7 @@ import static org.hamcrest.Matchers.*; ) @ActiveProfiles("test") @Transactional +@Tag("generalIntegrationTest") class TestCustomerControllerAcceptanceTest { @LocalServerPort diff --git a/src/test/java/net/hostsharing/hsadminng/rbac/test/cust/TestCustomerRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/rbac/test/cust/TestCustomerRepositoryIntegrationTest.java index c0a0dd06..2656ec60 100644 --- a/src/test/java/net/hostsharing/hsadminng/rbac/test/cust/TestCustomerRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/rbac/test/cust/TestCustomerRepositoryIntegrationTest.java @@ -4,6 +4,7 @@ import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.rbac.context.ContextBasedTest; import net.hostsharing.hsadminng.rbac.test.JpaAttempt; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; @@ -19,6 +20,7 @@ import static org.assertj.core.api.Assertions.assertThat; @DataJpaTest @Import( { Context.class, JpaAttempt.class }) +@Tag("generalIntegrationTest") class TestCustomerRepositoryIntegrationTest extends ContextBasedTest { @Autowired diff --git a/src/test/java/net/hostsharing/hsadminng/rbac/test/pac/TestPackageControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/rbac/test/pac/TestPackageControllerAcceptanceTest.java index 4d68422e..fdfc9ee7 100644 --- a/src/test/java/net/hostsharing/hsadminng/rbac/test/pac/TestPackageControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/rbac/test/pac/TestPackageControllerAcceptanceTest.java @@ -7,6 +7,7 @@ import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.config.DisableSecurityConfig; import org.apache.commons.lang3.RandomStringUtils; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -28,6 +29,7 @@ import static org.hamcrest.Matchers.is; ) @ActiveProfiles("test") @Transactional +@Tag("generalIntegrationTest") class TestPackageControllerAcceptanceTest { @LocalServerPort diff --git a/src/test/java/net/hostsharing/hsadminng/rbac/test/pac/TestPackageRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/rbac/test/pac/TestPackageRepositoryIntegrationTest.java index f4fa58dc..65a164fe 100644 --- a/src/test/java/net/hostsharing/hsadminng/rbac/test/pac/TestPackageRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/rbac/test/pac/TestPackageRepositoryIntegrationTest.java @@ -4,6 +4,7 @@ import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.rbac.context.ContextBasedTest; import net.hostsharing.hsadminng.rbac.test.JpaAttempt; import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; @@ -20,6 +21,7 @@ import static org.assertj.core.api.Assertions.assertThat; @DataJpaTest @Import( { Context.class, JpaAttempt.class }) +@Tag("generalIntegrationTest") class TestPackageRepositoryIntegrationTest extends ContextBasedTest { @Autowired -- 2.39.5 From 645fde6f8768547bcd84a996049aa1b50ec9be4a Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Mon, 20 Jan 2025 16:58:09 +0100 Subject: [PATCH 15/18] module-dependent test configs where 'test' is just unit tests and 'standardTest' all but import+scenario-tests --- build.gradle | 78 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 72 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index 6ba3c5e1..ad67a152 100644 --- a/build.gradle +++ b/build.gradle @@ -179,7 +179,9 @@ openapiProcessor { } } sourceSets.main.java.srcDir 'build/generated/sources/openapi' + abstract class ProcessSpring extends DefaultTask {} + tasks.register('processSpring', ProcessSpring) ['processSpringRoot', 'processSpringRbac', @@ -253,19 +255,23 @@ licenseReport { } project.tasks.check.dependsOn(checkLicense) -// JaCoCo Test Code Coverage -jacoco { - toolVersion = "0.8.10" -} + +// HOWTO: run all unit tests: gw test test { finalizedBy jacocoTestReport // generate report after tests excludes = [ 'net.hostsharing.hsadminng.**.generated.**', ] useJUnitPlatform { - excludeTags 'importOfficeData', 'importHostingData', 'scenarioTest' + excludeTags 'importOfficeData', 'importHostingAssets', 'scenarioTest', 'generalIntegrationTest', + 'officeIntegrationTest', 'bookingIntegrationTest', 'hostingIntegrationTest' } } + +// JaCoCo Test Code Coverage for unit-tests +jacoco { + toolVersion = "0.8.10" +} jacocoTestReport { dependsOn test afterEvaluate { @@ -330,6 +336,66 @@ jacocoTestCoverageVerification { } } +// HOWTO: run all integration tests which are not specific to a module, like base, rbac, config etc. +tasks.register('generalIntegrationTest', Test) { + useJUnitPlatform { + includeTags 'generalIntegrationTest' + } + + group 'verification' + description 'runs integration tests which are not specific to a module, like base, rbac, config etc.' + + mustRunAfter spotlessJava +} + +// HOWTO: run all integration tests of the office module: gw officeIntegrationTest +tasks.register('officeIntegrationTest', Test) { + useJUnitPlatform { + includeTags 'officeIntegrationTest' + } + + group 'verification' + description 'runs integration tests of the office module' + + mustRunAfter spotlessJava +} + +// HOWTO: run all integration tests of the booking module: gw bookingIntegrationTest +tasks.register('bookingIntegrationTest', Test) { + useJUnitPlatform { + includeTags 'bookingIntegrationTest' + } + + group 'verification' + description 'runs integration tests of the office module' + + mustRunAfter spotlessJava +} + +// HOWTO: run all integration tests of the hosting module: gw hostingIntegrationTest +tasks.register('hostingIntegrationTest', Test) { + useJUnitPlatform { + includeTags 'hostingIntegrationTest' + } + + group 'verification' + description 'runs integration tests of the office module' + + mustRunAfter spotlessJava +} + +// HOWTO: run all tests except import- and scenario-tests: gw standardTest +tasks.register('standardTest', Test) { + useJUnitPlatform { + excludeTags 'importOfficeData', 'importHostingAssets', 'scenarioTest' + } + + group 'verification' + description 'runs all tests except import- and scenario-tests' + + mustRunAfter spotlessJava +} + tasks.register('importOfficeData', Test) { useJUnitPlatform { includeTags 'importOfficeData' @@ -373,7 +439,7 @@ pitest { ] targetTests = ['net.hostsharing.hsadminng.**.*UnitTest', 'net.hostsharing.hsadminng.**.*RestTest'] - excludedTestClasses = ['**AcceptanceTest*', '**IntegrationTest*'] + excludedTestClasses = ['**AcceptanceTest*', '**IntegrationTest*', '**ImportOfficeData', '**ImportHostingAssets'] pitestVersion = '1.17.0' junit5PluginVersion = '1.1.0' -- 2.39.5 From 0e29958bf9cd384c994ab4cb3b7e890fb720fb1f Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Tue, 21 Jan 2025 14:06:50 +0100 Subject: [PATCH 16/18] finalize test suites and improve documentation --- .aliases | 33 +++++++++++- Jenkinsfile | 21 ++++++-- README.md | 50 ++++++++++++------- build.gradle | 35 +++++++------ .../rbac/context/ContextIntegrationTests.java | 2 + 5 files changed, 99 insertions(+), 42 deletions(-) diff --git a/.aliases b/.aliases index b7aa5c04..925de39e 100644 --- a/.aliases +++ b/.aliases @@ -90,9 +90,38 @@ alias pg-sql-restore='gunzip --stdout | docker exec -i hsadmin-ng-postgres psql alias fp='grep -r '@Accepts' src | sed -e 's/^.*@/@/g' | sort -u | wc -l' alias gw-spotless='./gradlew spotlessApply -x pitest -x test -x :processResources' -alias gw-test='. .aliases; . .tc-environment; ./gradlew test' alias gw-check='. .aliases; . .tc-environment; gw test check -x pitest' +# HOWTO: run all 'normal' tests (no scenario+import-tests): `gw-test` +# You can also mention specific targets: `gw-test importOfficeData`. +# This will always use the environment from `.tc-environment`. +# +# HOWTO: re-run tests even if no changed can be detected: `gw-test --rerun` +# You can also mention specific targets: `gw-test scenarioTest --rerun`. +# This will always use the environment from `.tc-environment`. +# +# HOWTO: run all tests (unit, integration+acceptance, import and scenario): `gw-test --all` +# You can also re-run all these tests, which will take ~20min: `gw-test --all --rerun` +# This will always use the environment from `.tc-environment`. +# +function _gwTest() { + . .aliases; + . .tc-environment; + if [ "$1" == "--all" ]; then + shift # to remove the --all from $@ + # delierately in separate gradlew-calls to avoid Testcontains-PostgreSQL problem spillover + ./gradlew unitTest "$@" && + ./gradlew officeIntegrationTest bookingIntegrationTest hostingIntegrationTest "$@" && + ./gradlew scenarioTest "$@" && + ./gradlew importOfficeData importHostingAssets "$@"; + elif [ $# -eq 0 ] || [[ $1 == -* ]]; then + ./gradlew test "$@"; + else + ./gradlew "$@"; + fi +} +alias gw-test=_gwTest + alias howto=bin/howto alias cas-curl=bin/cas-curl @@ -107,6 +136,6 @@ if [ ! -f .environment ]; then fi source .environment -alias scenario-reports-upload='./gradlew scenarioTests convertMarkdownToHtml && ssh hsh03-hsngdev@h50.hostsharing.net "rm -f doms/hsngdev.hs-example.de/htdocs-ssl/scenarios/office/*.html" && scp build/doc/scenarios/*.html hsh03-hsngdev@h50.hostsharing.net:doms/hsngdev.hs-example.de/htdocs-ssl/scenarios/office' +alias scenario-reports-upload='./gradlew scenarioTest convertMarkdownToHtml && ssh hsh03-hsngdev@h50.hostsharing.net "rm -f doms/hsngdev.hs-example.de/htdocs-ssl/scenarios/office/*.html" && scp build/doc/scenarios/*.html hsh03-hsngdev@h50.hostsharing.net:doms/hsngdev.hs-example.de/htdocs-ssl/scenarios/office' alias scenario-reports-open='open https://hsngdev.hs-example.de/scenarios/office' diff --git a/Jenkinsfile b/Jenkinsfile index 9b569801..5e41139b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -35,9 +35,24 @@ pipeline { stage ('Tests') { parallel { - stage('Unit-/Integration/Acceptance-Tests') { + stage('Unit-Tests') { steps { - sh './gradlew check --no-daemon -x pitest -x dependencyCheckAnalyze -x importOfficeData -x importHostingAssets' + sh './gradlew unitTest --no-daemon' + } + } + stage('General-Tests') { + steps { + sh './gradlew generalTest --no-daemon' + } + } + stage('Office-Tests') { + steps { + sh './gradlew officeIntegrationTest --no-daemon' + } + } + stage('Booking+Hosting-Tests') { + steps { + sh './gradlew bookingIntegrationTest hostingIntegrationTest --no-daemon' } } stage('Import-Tests') { @@ -47,7 +62,7 @@ pipeline { } stage ('Scenario-Tests') { steps { - sh './gradlew scenarioTests --no-daemon' + sh './gradlew scenarioTest --no-daemon' } } } diff --git a/README.md b/README.md index ef1fee8a..55b7a159 100644 --- a/README.md +++ b/README.md @@ -51,10 +51,11 @@ Everything is tested on _Ubuntu Linux 22.04_ and _MacOS Monterey (12.4)_. To be able to build and run the Java Spring Boot application, you need the following tools: - Docker 20.x (on MacOS you also need *Docker Desktop* or similar) or Podman -- optionally: PostgreSQL Server 15.5-bookworm +- optionally: PostgreSQL Server 15.5-bookworm, if you want to use the database directly, not just via Docker (see instructions below to install and run in Docker) - The matching Java JDK at will be automatically installed by Gradle toolchain support to `~/.gradle/jdks/`. - You also might need an IDE (e.g. *IntelliJ IDEA* or *Eclipse* or *VS Code* with *[STS](https://spring.io/tools)* and a GUI Frontend for *PostgreSQL* like *Postbird*. +- Python 3 is expected in /usr/bin/python3 if you want to run the `howto` tool (see `bin/howto`) If you have at least Docker and the Java JDK installed in appropriate versions and in your `PATH`, then you can start like this: @@ -64,7 +65,12 @@ If you have at least Docker and the Java JDK installed in appropriate versions a gw # initially downloads the configured Gradle version into the project gw test # compiles and runs unit- and integration-tests - takes >10min even on a fast machine - gw scenarioTests # compiles and scenario-tests - takes ~1min on a decent machine + # `gw test` does NOT run import- and scenario-tests. + # Use `gw-test` instead to make sure .tc-environment is sourced. + gw scenarioTest # compiles and scenario-tests - takes ~1min on a decent machine + # Use `gw-test scenarioTest` instead to make sure .tc-environment is sourced. + + howto test # shows more test information about how to run tests # if the container has not been built yet, run this: pg-sql-run # downloads + runs PostgreSQL in a Docker container on localhost:5432 @@ -437,36 +443,42 @@ Some of these rules are checked with *ArchUnit* unit tests. ### Run Tests from Command Line -Run all tests which have not yet been passed with the current source code: +Run all unit-, integration- and acceptance-tests which have not yet been passed with the current source code: ```shell -gw test +gw test # uses the current environment, especially HSADMINNG_POSTGRES_JDBC_URL +``` + +If the referenced database is not empty, the tests might fail. + +To explicitly use the Testcontainers-environment, run: + +```shell +gw-test # uses the environment from .tc-environment ``` Force running all tests: ```shell -gw cleanTest test +gw-test --rerun ``` +To find more options about running tests, try `howto test`. + ### Spotless Code Formatting Code formatting for Java is checked via *spotless*. -The formatting style can be checked with this command: - -```shell -gw spotlessCheck -``` - -This task is also included in `gw build` and `gw check`. - To apply formatting rules, use: ```shell -gw spotlessApply +gw-spotless ``` +The gradle task spotlessCheck is also included in `gw build` and `gw check`, +thus if the formatting is not compliant to the rules, the build is going to fail. + + ### JaCoCo Test Code Coverage Check This project uses the JaCoCo test code coverage report with limit checks. @@ -508,9 +520,8 @@ This task is also executed as part of `gw check`. #### Remark -In this project, there is little business logic in *Java* code; -most business code is in *plsql* -and *Java* ist mostly used for mapping REST calls to database queries. +In this project, there is a large amount of code is in *plsql*, especially for RBAC. +*Java* ist mostly used for mapping and validating REST calls to database queries. This mapping ist mostly done through *Spring* annotations and other implicit code. Therefore, there are only few unit tests and thus mutation testing has limited value. @@ -603,7 +614,8 @@ and would not need the `rbac.role` table anymore. We would also reduce the depth of the expensive recursive CTE-query. This has to be explored further. -For now, we just keep it in mind and +For now, we just keep it in mind and FIXME + ### The Mapper is Error-Prone @@ -637,7 +649,7 @@ howto Add `--args='--spring.profiles.active=...` with the wanted profile selector: ```sh -gw bootRun --args='--spring.profiles.active=external-db,only-office,without-test-data' +gw bootRun --args='--spring.profiles.active=external-db,only -office,without-test-data' ``` These profiles mean: diff --git a/build.gradle b/build.gradle index ad67a152..9f0db4bd 100644 --- a/build.gradle +++ b/build.gradle @@ -255,16 +255,14 @@ licenseReport { } project.tasks.check.dependsOn(checkLicense) - -// HOWTO: run all unit tests: gw test +// HOWTO: run all tests except import- and scenario-tests: gw test test { finalizedBy jacocoTestReport // generate report after tests excludes = [ 'net.hostsharing.hsadminng.**.generated.**', ] useJUnitPlatform { - excludeTags 'importOfficeData', 'importHostingAssets', 'scenarioTest', 'generalIntegrationTest', - 'officeIntegrationTest', 'bookingIntegrationTest', 'hostingIntegrationTest' + excludeTags 'importOfficeData', 'importHostingAssets', 'scenarioTest' } } @@ -336,6 +334,19 @@ jacocoTestCoverageVerification { } } +// HOWTO: run all unit-tests which don't need a database: gw unitTest +tasks.register('unitTest', Test) { + useJUnitPlatform { + excludeTags 'importOfficeData', 'importHostingAssets', 'scenarioTest', 'generalIntegrationTest', + 'officeIntegrationTest', 'bookingIntegrationTest', 'hostingIntegrationTest' + } + + group 'verification' + description 'runs all unit-tests which do not need a database' + + mustRunAfter spotlessJava +} + // HOWTO: run all integration tests which are not specific to a module, like base, rbac, config etc. tasks.register('generalIntegrationTest', Test) { useJUnitPlatform { @@ -384,18 +395,6 @@ tasks.register('hostingIntegrationTest', Test) { mustRunAfter spotlessJava } -// HOWTO: run all tests except import- and scenario-tests: gw standardTest -tasks.register('standardTest', Test) { - useJUnitPlatform { - excludeTags 'importOfficeData', 'importHostingAssets', 'scenarioTest' - } - - group 'verification' - description 'runs all tests except import- and scenario-tests' - - mustRunAfter spotlessJava -} - tasks.register('importOfficeData', Test) { useJUnitPlatform { includeTags 'importOfficeData' @@ -418,7 +417,7 @@ tasks.register('importHostingAssets', Test) { mustRunAfter spotlessJava } -tasks.register('scenarioTests', Test) { +tasks.register('scenarioTest', Test) { useJUnitPlatform { includeTags 'scenarioTest' } @@ -518,7 +517,7 @@ tasks.register('convertMarkdownToHtml') { } } } -convertMarkdownToHtml.dependsOn scenarioTests +convertMarkdownToHtml.dependsOn scenarioTest // shortcut for compiling all files tasks.register('compile') { diff --git a/src/test/java/net/hostsharing/hsadminng/rbac/context/ContextIntegrationTests.java b/src/test/java/net/hostsharing/hsadminng/rbac/context/ContextIntegrationTests.java index 7f59d4e3..8b5d7693 100644 --- a/src/test/java/net/hostsharing/hsadminng/rbac/context/ContextIntegrationTests.java +++ b/src/test/java/net/hostsharing/hsadminng/rbac/context/ContextIntegrationTests.java @@ -5,6 +5,7 @@ import net.hostsharing.hsadminng.mapper.Array; import net.hostsharing.hsadminng.mapper.StrictMapper; import net.hostsharing.hsadminng.persistence.EntityManagerWrapper; import net.hostsharing.hsadminng.rbac.test.JpaAttempt; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; @@ -19,6 +20,7 @@ import jakarta.servlet.http.HttpServletRequest; import static org.assertj.core.api.Assertions.assertThat; +@Tag("generalIntegrationTest") @DataJpaTest @ComponentScan(basePackageClasses = { Context.class, JpaAttempt.class, EntityManagerWrapper.class, StrictMapper.class }) @DirtiesContext -- 2.39.5 From 56bc47dc9591116f6aba0a22ddfb55b68e7a4629 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Tue, 21 Jan 2025 14:09:11 +0100 Subject: [PATCH 17/18] re-generate TOC of README.md --- README.md | 73 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 55b7a159..8f4f358f 100644 --- a/README.md +++ b/README.md @@ -5,41 +5,48 @@ For architecture consider the files in the `doc` and `adr` folder. - [Setting up the Development Environment](#setting-up-the-development-environment) - - [PostgreSQL Server](#postgresql-server) - - [Markdown](#markdown) - - [Render Markdown embedded PlantUML](#render-markdown-embedded-plantuml) - - [Render Markdown Embedded Mermaid Diagrams](#render-markdown-embedded-mermaid-diagrams) - - [IDE Specific Settings](#ide-specific-settings) - - [IntelliJ IDEA](#intellij-idea) - - [Other Tools](#other-tools) + - [PostgreSQL Server](#postgresql-server) + - [Markdown](#markdown) + - [Render Markdown embedded PlantUML](#render-markdown-embedded-plantuml) + - [Render Markdown Embedded Mermaid Diagrams](#render-markdown-embedded-mermaid-diagrams) + - [IDE Specific Settings](#ide-specific-settings) + - [IntelliJ IDEA](#intellij-idea) + - [Other Tools](#other-tools) - [Running the SQL files](#running-the-sql-files) - - [For RBAC](#for-rbac) - - [For Historization](#for-historization) + - [For RBAC](#for-rbac) + - [For Historization](#for-historization) - [Coding Guidelines](#coding-guidelines) - - [Directory and Package Structure](#directory-and-package-structure) - - [General Directory Structure](#general-directory-structure) - - [Source Code Package Structure](#source-code-package-structure) - - [Run Tests from Command Line](#run-tests-from-command-line) - - [Spotless Code Formatting](#spotless-code-formatting) - - [JaCoCo Test Code Coverage Check](#jacoco-test-code-coverage-check) - - [PiTest Mutation Testing](#pitest-mutation-testing) - - [Remark](#remark) - - [OWASP Security Vulnerability Check](#owasp-security-vulnerability-check) - - [Dependency-License-Compatibility](#dependency-license-compatibility) - - [Dependency Version Upgrade](#dependency-version-upgrade) + - [Directory and Package Structure](#directory-and-package-structure) + - [General Directory Structure](#general-directory-structure) + - [Source Code Package Structure](#source-code-package-structure) + - [Run Tests from Command Line](#run-tests-from-command-line) + - [Spotless Code Formatting](#spotless-code-formatting) + - [JaCoCo Test Code Coverage Check](#jacoco-test-code-coverage-check) + - [PiTest Mutation Testing](#pitest-mutation-testing) + - [Remark](#remark) + - [OWASP Security Vulnerability Check](#owasp-security-vulnerability-check) + - [Dependency-License-Compatibility](#dependency-license-compatibility) + - [Dependency Version Upgrade](#dependency-version-upgrade) +- [Biggest Flaws in our Architecture](#biggest-flaws-in-our-architecture) + - [The RBAC System is too Complicated](#the-rbac-system-is-too-complicated) + - [The Mapper is Error-Prone](#the-mapper-is-error-prone) + - [Too Many Business-Rules Implemented in Controllers](#too-many-business-rules-implemented-in-controllers) - [How To ...](#how-to-...) - - [How to Configure .pgpass for the Default PostgreSQL Database?](#how-to-configure-.pgpass-for-the-default-postgresql-database?) - - [How to Run the Tests Against a Local User-Space Podman Daemon?](#how-to-run-the-tests-against-a-local-user-space-podman-daemon?) - - [Install and Run Podman](#install-and-run-podman) - - [Use the Command Line to Run the Tests Against the Podman Daemon ](#use-the-command-line-to-run-the-tests-against-the-podman-daemon-) - - [Use IntelliJ IDEA Run the Tests Against the Podman Daemon](#use-intellij-idea-run-the-tests-against-the-podman-daemon) - - [~/.testcontainers.properties](#~/.testcontainers.properties) - - [How to Run the Tests Against a Remote Podman or Docker Daemon?](#how-to-run-the-tests-against-a-remote-podman-or-docker-daemon?) - - [How to Run the Application on a Different Port?](#how-to-run-the-application-on-a-different-port?) - - [How to Use a Persistent Database for Integration Tests?](#how-to-use-a-persistent-database-for-integration-tests?) - - [How to Amend Liquibase SQL Changesets?](#how-to-amend-liquibase-sql-changesets?) - - [How to Re-Generate Spring-Controller-Interfaces from OpenAPI specs?](#how-to-re-generate-spring-controller-interfaces-from-openapi-specs?) - - [How to Generate Database Table Diagrams?](#how-to-generate-database-table-diagrams?) + - [How to Run the Application With Other Profiles, e.g. production](#) + - [How to Do a Clean Run of the Application](#how-to-do-a-clean-run-of-the-application) + - [How to Configure .pgpass for the Default PostgreSQL Database?](#how-to-configure-.pgpass-for-the-default-postgresql-database?) + - [How to Run the Tests Against a Local User-Space Podman Daemon?](#how-to-run-the-tests-against-a-local-user-space-podman-daemon?) + - [Install and Run Podman](#install-and-run-podman) + - [Use the Command Line to Run the Tests Against the Podman Daemon ](#use-the-command-line-to-run-the-tests-against-the-podman-daemon-) + - [Use IntelliJ IDEA Run the Tests Against the Podman Daemon](#use-intellij-idea-run-the-tests-against-the-podman-daemon) + - [~/.testcontainers.properties](#~/.testcontainers.properties) + - [How to Run the Tests Against a Remote Podman or Docker Daemon?](#how-to-run-the-tests-against-a-remote-podman-or-docker-daemon?) + - [How to Run the Application on a Different Port?](#how-to-run-the-application-on-a-different-port?) + - [How to Use a Persistent Database for Integration Tests?](#how-to-use-a-persistent-database-for-integration-tests?) + - [How to Amend Liquibase SQL Changesets?](#how-to-amend-liquibase-sql-changesets?) + - [How to Re-Generate Spring-Controller-Interfaces from OpenAPI specs?](#how-to-re-generate-spring-controller-interfaces-from-openapi-specs?) + - [How to Generate Database Table Diagrams?](#how-to-generate-database-table-diagrams?) + - [How to Add (Real) Admin Users](#how-to-add-(real)-admin-users) - [Further Documentation](#further-documentation) @@ -205,7 +212,7 @@ To generate the TOC (Table of Contents), a little bash script from a Given this is in PATH as `md-toc`, use: ```shell -md-toc Date: Tue, 21 Jan 2025 14:10:09 +0100 Subject: [PATCH 18/18] fix Swagger-UI --- build.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 9f0db4bd..73c94f5c 100644 --- a/build.gradle +++ b/build.gradle @@ -83,7 +83,8 @@ dependencies { compileOnly 'org.projectlombok:lombok' testCompileOnly 'org.projectlombok:lombok' - developmentOnly 'org.springframework.boot:spring-boot-devtools' + // TODO.impl: version conflict with SpringDoc, check later and re-enable if fixed + // developmentOnly 'org.springframework.boot:spring-boot-devtools' annotationProcessor 'org.projectlombok:lombok' testAnnotationProcessor 'org.projectlombok:lombok' -- 2.39.5