From 8782971614d616e06feb0fba30657fd13a8fccda Mon Sep 17 00:00:00 2001 From: "idriss.naji" Date: Tue, 25 Oct 2022 07:47:37 +0200 Subject: [PATCH] chore: upgrade library versions and fix CVEs --- .github/workflows/securityScan.yml | 21 +++++++ pom.xml | 60 ++++++++++++------- run-trivy.sh | 2 + .../CustomSwaggerUIApiResourceController.java | 18 ------ .../CustomSwaggerUIPathController.java | 22 ------- ...tenancyWithSingleDomainTenantResolver.java | 3 +- .../config/KeycloakConfiguration.java | 14 +++++ .../agencyservice/config/SecurityConfig.java | 11 ---- .../agencyservice/config/SpringFoxConfig.java | 3 +- .../resources/application-testing.properties | 4 +- .../admin/hallink/AgencyLinksBuilderTest.java | 8 +-- .../DiocesePaginationLinkBuilderTest.java | 14 ++--- .../api/admin/hallink/RootDTOBuilderTest.java | 8 +-- .../hallink/SearchResultLinkBuilderTest.java | 16 ++--- .../service/AgencyAdminServiceITBase.java | 16 ++--- ...AgencyAdminFullResponseDTOBuilderTest.java | 8 +-- .../AgencyOfflineStatusValidatorTest.java | 13 ++-- ...trollerWithSingleDomainMultitenancyIT.java | 4 +- .../api/service/AgencyServiceITBase.java | 36 ++++------- .../service/AgencyServiceTenantAwareTest.java | 5 +- .../api/service/AgencyServiceTest.java | 5 +- ...ncyWithSingleDomainTenantResolverTest.java | 4 +- .../api/tenant/TenantResolverServiceTest.java | 23 ++----- ...tendedConsultingTypeResponseDTOHelper.java | 6 +- 24 files changed, 157 insertions(+), 167 deletions(-) create mode 100644 .github/workflows/securityScan.yml create mode 100644 run-trivy.sh delete mode 100644 src/main/java/de/caritas/cob/agencyservice/api/controller/CustomSwaggerUIApiResourceController.java delete mode 100644 src/main/java/de/caritas/cob/agencyservice/api/controller/CustomSwaggerUIPathController.java create mode 100644 src/main/java/de/caritas/cob/agencyservice/config/KeycloakConfiguration.java diff --git a/.github/workflows/securityScan.yml b/.github/workflows/securityScan.yml new file mode 100644 index 00000000..a733d908 --- /dev/null +++ b/.github/workflows/securityScan.yml @@ -0,0 +1,21 @@ +name: Run trivy security scan +on: + push: + branches: + - 'develop' + pull_request: +jobs: + build: + name: Build + runs-on: ubuntu-20.04 + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Run Trivy vulnerability scanner in fs mode + uses: aquasecurity/trivy-action@master + with: + scan-type: 'fs' + scan-ref: '.' + format: 'table' + exit-code: 1 + severity: CRITICAL \ No newline at end of file diff --git a/pom.xml b/pom.xml index 3f828c98..238b7302 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ org.springframework.boot spring-boot-starter-parent - 2.3.5.RELEASE + 2.7.5 @@ -26,7 +26,20 @@ 11 17.0.0 - 2.16.0 + 2.17.1 + 6.2.0 + 5.11.10.Final + 0.2.3 + 3.0.0 + 2.1.1 + 3.11 + 4.1.1 + 1.4.200 + 2.0.2 + 2.10.6 + 5.0.0 + 2.7.5 + 4.9.1 @@ -52,45 +65,44 @@ spring-boot-starter-hateoas - org.hibernate.validator - hibernate-validator - 6.1.6.Final + org.springframework.boot + spring-boot-starter-validation org.hibernate hibernate-search-orm - 5.11.5.Final + ${hibernate-search-orm.version} org.openapitools openapi-generator-maven-plugin - 5.1.1 + ${openapi.generator.maven.version} provided org.openapitools jackson-databind-nullable - 0.2.1 + ${jackson-databind-nullable.version} io.springfox springfox-swagger2 - 2.9.2 + ${springfox-swagger2.version} io.springfox springfox-bean-validators - 2.9.2 + ${springfox-swagger2.version} io.springfox springfox-swagger-ui - 2.9.2 + ${springfox-swagger2.version} @@ -112,7 +124,7 @@ javax.ws.rs javax.ws.rs-api - 2.1.1 + ${javax.ws.rs-api.version} @@ -126,14 +138,19 @@ org.apache.commons commons-lang3 - 3.11 + ${commons-lang3.version} org.liquibase liquibase-maven-plugin - 4.1.1 + ${liquibase-maven-plugin.version} + + + org.liquibase + liquibase-core + ${liquibase-core.version} @@ -141,6 +158,7 @@ com.h2database h2 test + ${h2.version} org.springframework.boot @@ -159,18 +177,18 @@ powermock-module-junit4 org.powermock test - 2.0.2 + ${powermock-module-junit4.version} powermock-api-mockito2 org.powermock test - 2.0.2 + ${powermock-module-junit4.version} net.sf.ehcache ehcache - 2.10.6 + ${ehcache.version} @@ -199,13 +217,13 @@ org.jeasy easy-random-core - 4.3.0 + ${easy-random-core.version} test org.springframework.boot spring-boot-autoconfigure - 2.3.5.RELEASE + ${spring-boot-autoconfigure.version} @@ -227,7 +245,7 @@ org.openapitools openapi-generator-maven-plugin - 5.1.1 + ${openapi.generator.maven.version} agency-service @@ -442,7 +460,7 @@ org.liquibase liquibase-maven-plugin - 4.1.1 + ${liquibase-maven-plugin.version} src/main/resources/liquibase.properties diff --git a/run-trivy.sh b/run-trivy.sh new file mode 100644 index 00000000..1ee60603 --- /dev/null +++ b/run-trivy.sh @@ -0,0 +1,2 @@ +rm report*.sarif +trivy fs --security-checks=config,vuln --severity=CRITICAL --format=sarif --output report.sarif . \ No newline at end of file diff --git a/src/main/java/de/caritas/cob/agencyservice/api/controller/CustomSwaggerUIApiResourceController.java b/src/main/java/de/caritas/cob/agencyservice/api/controller/CustomSwaggerUIApiResourceController.java deleted file mode 100644 index cf1bd814..00000000 --- a/src/main/java/de/caritas/cob/agencyservice/api/controller/CustomSwaggerUIApiResourceController.java +++ /dev/null @@ -1,18 +0,0 @@ -package de.caritas.cob.agencyservice.api.controller; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import springfox.documentation.annotations.ApiIgnore; -import springfox.documentation.swagger.web.ApiResourceController; -import springfox.documentation.swagger.web.SwaggerResourcesProvider; - -@Controller -@ApiIgnore -@RequestMapping(value = "${springfox.docuPath}" + "/swagger-resources") -public class CustomSwaggerUIApiResourceController extends ApiResourceController { - - public CustomSwaggerUIApiResourceController(SwaggerResourcesProvider swaggerResources) { - super(swaggerResources); - } - -} diff --git a/src/main/java/de/caritas/cob/agencyservice/api/controller/CustomSwaggerUIPathController.java b/src/main/java/de/caritas/cob/agencyservice/api/controller/CustomSwaggerUIPathController.java deleted file mode 100644 index defa7ae5..00000000 --- a/src/main/java/de/caritas/cob/agencyservice/api/controller/CustomSwaggerUIPathController.java +++ /dev/null @@ -1,22 +0,0 @@ -package de.caritas.cob.agencyservice.api.controller; - -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import springfox.documentation.annotations.ApiIgnore; -import springfox.documentation.spring.web.DocumentationCache; -import springfox.documentation.spring.web.json.JsonSerializer; -import springfox.documentation.swagger2.mappers.ServiceModelToSwagger2Mapper; -import springfox.documentation.swagger2.web.Swagger2Controller; - -@Controller -@ApiIgnore -@RequestMapping(value = "${springfox.docuPath}") -public class CustomSwaggerUIPathController extends Swagger2Controller { - - public CustomSwaggerUIPathController(Environment environment, DocumentationCache documentationCache, - ServiceModelToSwagger2Mapper mapper, JsonSerializer jsonSerializer) { - super(environment, documentationCache, mapper, jsonSerializer); - } - -} diff --git a/src/main/java/de/caritas/cob/agencyservice/api/tenant/MultitenancyWithSingleDomainTenantResolver.java b/src/main/java/de/caritas/cob/agencyservice/api/tenant/MultitenancyWithSingleDomainTenantResolver.java index 55957d4f..2cdddaa0 100644 --- a/src/main/java/de/caritas/cob/agencyservice/api/tenant/MultitenancyWithSingleDomainTenantResolver.java +++ b/src/main/java/de/caritas/cob/agencyservice/api/tenant/MultitenancyWithSingleDomainTenantResolver.java @@ -1,6 +1,7 @@ package de.caritas.cob.agencyservice.api.tenant; import de.caritas.cob.agencyservice.applicationsettingsservice.generated.web.model.ApplicationSettingsDTO; +import de.caritas.cob.agencyservice.applicationsettingsservice.generated.web.model.ApplicationSettingsDTOMainTenantSubdomainForSingleDomainMultitenancy; import de.caritas.cob.agencyservice.applicationsettingsservice.generated.web.model.SettingDTO; import de.caritas.cob.agencyservice.config.apiclient.ApplicationSettingsApiControllerFactory; import de.caritas.cob.agencyservice.config.apiclient.TenantServiceApiControllerFactory; @@ -61,7 +62,7 @@ private Optional resolveFromTenantServiceBasedOnMainTenantSubdomain(String private Optional getMainTenantSubdomainFromApplicationSettings() { ApplicationSettingsDTO applicationSettings = applicationSettingsApiControllerFactory.createControllerApi().getApplicationSettings(); - SettingDTO mainTenantSubdomainForSingleDomainMultitenancy = applicationSettings.getMainTenantSubdomainForSingleDomainMultitenancy(); + ApplicationSettingsDTOMainTenantSubdomainForSingleDomainMultitenancy mainTenantSubdomainForSingleDomainMultitenancy = applicationSettings.getMainTenantSubdomainForSingleDomainMultitenancy(); if (mainTenantSubdomainForSingleDomainMultitenancy == null) { return Optional.empty(); } diff --git a/src/main/java/de/caritas/cob/agencyservice/config/KeycloakConfiguration.java b/src/main/java/de/caritas/cob/agencyservice/config/KeycloakConfiguration.java new file mode 100644 index 00000000..518f32c6 --- /dev/null +++ b/src/main/java/de/caritas/cob/agencyservice/config/KeycloakConfiguration.java @@ -0,0 +1,14 @@ +package de.caritas.cob.agencyservice.config; + +import org.keycloak.adapters.KeycloakConfigResolver; +import org.keycloak.adapters.springboot.KeycloakSpringBootConfigResolver; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class KeycloakConfiguration { + @Bean + public KeycloakConfigResolver keyCloakConfigResolver() { + return new KeycloakSpringBootConfigResolver(); + } +} diff --git a/src/main/java/de/caritas/cob/agencyservice/config/SecurityConfig.java b/src/main/java/de/caritas/cob/agencyservice/config/SecurityConfig.java index 0f511cfe..6be574c6 100644 --- a/src/main/java/de/caritas/cob/agencyservice/config/SecurityConfig.java +++ b/src/main/java/de/caritas/cob/agencyservice/config/SecurityConfig.java @@ -6,8 +6,6 @@ import de.caritas.cob.agencyservice.filter.HttpTenantFilter; import de.caritas.cob.agencyservice.filter.StatelessCsrfFilter; import javax.annotation.Nullable; -import org.keycloak.adapters.KeycloakConfigResolver; -import org.keycloak.adapters.springboot.KeycloakSpringBootConfigResolver; import org.keycloak.adapters.springsecurity.KeycloakConfiguration; import org.keycloak.adapters.springsecurity.client.KeycloakClientRequestFactory; import org.keycloak.adapters.springsecurity.config.KeycloakWebSecurityConfigurerAdapter; @@ -90,15 +88,6 @@ protected void configure(HttpSecurity http) throws Exception { .anyRequest().denyAll(); } - /** - * Use the KeycloakSpringBootConfigResolver to be able to save the Keycloak settings in the spring - * application properties. - */ - @Bean - public KeycloakConfigResolver keyCloakConfigResolver() { - return new KeycloakSpringBootConfigResolver(); - } - /** * Change springs authentication strategy to be stateless (no session is being created). */ diff --git a/src/main/java/de/caritas/cob/agencyservice/config/SpringFoxConfig.java b/src/main/java/de/caritas/cob/agencyservice/config/SpringFoxConfig.java index 3d12c6d7..d4da48fc 100644 --- a/src/main/java/de/caritas/cob/agencyservice/config/SpringFoxConfig.java +++ b/src/main/java/de/caritas/cob/agencyservice/config/SpringFoxConfig.java @@ -34,7 +34,6 @@ * */ @Configuration -@EnableSwagger2 @Import(BeanValidatorPluginsConfiguration.class) public class SpringFoxConfig { @@ -76,7 +75,7 @@ private List securityReferences() { SecurityReference.builder().reference("token").scopes(new AuthorizationScope[0]).build()); } - private List securitySchemes() { + private List securitySchemes() { return singletonList(new ApiKey("Bearer", "Authorization", "header")); } diff --git a/src/main/resources/application-testing.properties b/src/main/resources/application-testing.properties index 22dcd8a8..9a864356 100644 --- a/src/main/resources/application-testing.properties +++ b/src/main/resources/application-testing.properties @@ -28,9 +28,9 @@ rocket.chat.login.logout.technical.user.automatically=false spring.liquibase.enabled=false spring.datasource.driver-class-name=org.h2.Driver spring.datasource.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1 -spring.datasource.schema=classpath*:database/AgencyDatabase.sql +spring.sql.init.schema-locations=classpath*:database/AgencyDatabase.sql spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect -spring.datasource.sql-script-encoding=UTF-8 +spring.sql.init.encoding=UTF-8 spring.jpa.open-in-view=false # CSRF diff --git a/src/test/java/de/caritas/cob/agencyservice/api/admin/hallink/AgencyLinksBuilderTest.java b/src/test/java/de/caritas/cob/agencyservice/api/admin/hallink/AgencyLinksBuilderTest.java index d1f7e04b..5f7a55f2 100644 --- a/src/test/java/de/caritas/cob/agencyservice/api/admin/hallink/AgencyLinksBuilderTest.java +++ b/src/test/java/de/caritas/cob/agencyservice/api/admin/hallink/AgencyLinksBuilderTest.java @@ -28,19 +28,19 @@ void buildAgencyLinks_Should_returnAgencyLinks_When_AgencyIsSet() { assertThat(agencyLinks.getSelf(), notNullValue()); assertThat(agencyLinks.getSelf().getMethod(), is(MethodEnum.GET)); assertThat(agencyLinks.getSelf().getHref(), - is(String.format("/agencyadmin/agencies/%s", agency.getId()))); + is(String.format("/${openapi.willBeReplaced.base-path}/agencyadmin/agencies/%s", agency.getId()))); assertThat(agencyLinks.getDelete(), notNullValue()); assertThat(agencyLinks.getDelete().getMethod(), is(MethodEnum.DELETE)); assertThat(agencyLinks.getDelete().getHref(), - is(String.format("/agencyadmin/agencies/%s", agency.getId()))); + is(String.format("/${openapi.willBeReplaced.base-path}/agencyadmin/agencies/%s", agency.getId()))); assertThat(agencyLinks.getUpdate(), notNullValue()); assertThat(agencyLinks.getUpdate().getMethod(), is(MethodEnum.PUT)); assertThat(agencyLinks.getUpdate().getHref(), - is(String.format("/agencyadmin/agencies/%s", agency.getId()))); + is(String.format("/${openapi.willBeReplaced.base-path}/agencyadmin/agencies/%s", agency.getId()))); assertThat(agencyLinks.getPostcodeRanges(), notNullValue()); assertThat(agencyLinks.getPostcodeRanges().getMethod(), is(MethodEnum.GET)); assertThat(agencyLinks.getPostcodeRanges().getHref(), - is(String.format("/agencyadmin/postcoderanges/%s", agency.getId()))); + is(String.format("/${openapi.willBeReplaced.base-path}/agencyadmin/postcoderanges/%s", agency.getId()))); } @Test diff --git a/src/test/java/de/caritas/cob/agencyservice/api/admin/hallink/DiocesePaginationLinkBuilderTest.java b/src/test/java/de/caritas/cob/agencyservice/api/admin/hallink/DiocesePaginationLinkBuilderTest.java index 750f8a65..1918782b 100644 --- a/src/test/java/de/caritas/cob/agencyservice/api/admin/hallink/DiocesePaginationLinkBuilderTest.java +++ b/src/test/java/de/caritas/cob/agencyservice/api/admin/hallink/DiocesePaginationLinkBuilderTest.java @@ -26,15 +26,15 @@ void buildPaginationLinks_Should_returnPaginationLinks_When_allParametersAreSet( assertThat(paginationLinks.getSelf(), notNullValue()); assertThat(paginationLinks.getSelf().getMethod(), is(MethodEnum.GET)); assertThat(paginationLinks.getSelf().getHref(), - is("/agencyadmin/dioceses?page=2&perPage=20")); + is("/${openapi.willBeReplaced.base-path}/agencyadmin/dioceses?page=2&perPage=20")); assertThat(paginationLinks.getPrevious(), notNullValue()); assertThat(paginationLinks.getPrevious().getMethod(), is(MethodEnum.GET)); assertThat(paginationLinks.getPrevious().getHref(), - is("/agencyadmin/dioceses?page=1&perPage=20")); + is("/${openapi.willBeReplaced.base-path}/agencyadmin/dioceses?page=1&perPage=20")); assertThat(paginationLinks.getNext(), notNullValue()); assertThat(paginationLinks.getNext().getMethod(), is(MethodEnum.GET)); assertThat(paginationLinks.getNext().getHref(), - is("/agencyadmin/dioceses?page=3&perPage=20")); + is("/${openapi.willBeReplaced.base-path}/agencyadmin/dioceses?page=3&perPage=20")); } @Test @@ -47,7 +47,7 @@ void buildPaginationLinks_Should_havePreviousLink_When_currentPageIsNotTheFirst( assertThat(paginationLinks.getPrevious(), notNullValue()); assertThat(paginationLinks.getPrevious().getHref(), - endsWith("/agencyadmin/dioceses?page=1&perPage=20")); + endsWith("/${openapi.willBeReplaced.base-path}/agencyadmin/dioceses?page=1&perPage=20")); } @Test @@ -71,7 +71,7 @@ void buildPaginationLinks_Should_haveNextLink_When_currentPageIsNotTheLast() { assertThat(paginationLinks.getNext(), notNullValue()); assertThat(paginationLinks.getNext().getHref(), - endsWith("/agencyadmin/dioceses?page=3&perPage=20")); + endsWith("/${openapi.willBeReplaced.base-path}/agencyadmin/dioceses?page=3&perPage=20")); } @Test @@ -94,7 +94,7 @@ void buildPaginationLinks_Should_returnSelfLink() { assertThat(paginationLinks, notNullValue()); assertThat(paginationLinks.getSelf().getHref(), - is("/agencyadmin/dioceses?page=1&perPage=20")); + is("/${openapi.willBeReplaced.base-path}/agencyadmin/dioceses?page=1&perPage=20")); } @Test @@ -104,6 +104,6 @@ void buildPaginationLinks_Should_returnDefaultPaginationValues_When_noParameters assertThat(paginationLinks, notNullValue()); assertThat(paginationLinks.getSelf().getHref(), - is("/agencyadmin/dioceses?page=1&perPage=20")); + is("/${openapi.willBeReplaced.base-path}/agencyadmin/dioceses?page=1&perPage=20")); } } diff --git a/src/test/java/de/caritas/cob/agencyservice/api/admin/hallink/RootDTOBuilderTest.java b/src/test/java/de/caritas/cob/agencyservice/api/admin/hallink/RootDTOBuilderTest.java index bc306487..8fd5bc18 100644 --- a/src/test/java/de/caritas/cob/agencyservice/api/admin/hallink/RootDTOBuilderTest.java +++ b/src/test/java/de/caritas/cob/agencyservice/api/admin/hallink/RootDTOBuilderTest.java @@ -22,17 +22,17 @@ void buildRootDTO_Should_returnRootDTOWithHalLinks() { assertThat(rootLinks, notNullValue()); assertThat(rootLinks.getAgencies(), notNullValue()); assertThat(rootLinks.getAgencies().getHref(), - is("/agencyadmin/agencies?page=1&perPage=20{&q}")); + is("/${openapi.willBeReplaced.base-path}/agencyadmin/agencies?page=1&perPage=20{&q}")); assertThat(rootLinks.getAgencies().getMethod(), is(MethodEnum.GET)); - assertThat(rootLinks.getSelf().getHref(), is("/agencyadmin")); + assertThat(rootLinks.getSelf().getHref(), is("/${openapi.willBeReplaced.base-path}/agencyadmin")); assertThat(rootLinks.getSelf().getMethod(), is(MethodEnum.GET)); assertThat(rootLinks.getAgencypostcodes(), notNullValue()); assertThat(rootLinks.getAgencypostcodes().getHref(), - is("/agencyadmin/postcoderanges/{agencyId}")); + is("/${openapi.willBeReplaced.base-path}/agencyadmin/postcoderanges/{agencyId}")); assertThat(rootLinks.getAgencypostcodes().getMethod(), is(MethodEnum.GET)); assertThat(rootLinks.getDioceses(), notNullValue()); assertThat(rootLinks.getDioceses().getHref(), - is("/agencyadmin/dioceses?page=1&perPage=20")); + is("/${openapi.willBeReplaced.base-path}/agencyadmin/dioceses?page=1&perPage=20")); assertThat(rootLinks.getAgencypostcodes().getMethod(), is(MethodEnum.GET)); } diff --git a/src/test/java/de/caritas/cob/agencyservice/api/admin/hallink/SearchResultLinkBuilderTest.java b/src/test/java/de/caritas/cob/agencyservice/api/admin/hallink/SearchResultLinkBuilderTest.java index c1aab285..07ea2d03 100644 --- a/src/test/java/de/caritas/cob/agencyservice/api/admin/hallink/SearchResultLinkBuilderTest.java +++ b/src/test/java/de/caritas/cob/agencyservice/api/admin/hallink/SearchResultLinkBuilderTest.java @@ -27,19 +27,19 @@ void buildSearchResultLinks_Should_returnSearchResultLinks_When_allParametersAre assertThat(searchResultLinks.getSelf(), notNullValue()); assertThat(searchResultLinks.getSelf().getMethod(), is(MethodEnum.GET)); assertThat(searchResultLinks.getSelf().getHref(), - is("/agencyadmin/agencies?page=2&perPage=20&q=keyword")); + is("/${openapi.willBeReplaced.base-path}/agencyadmin/agencies?page=2&perPage=20&q=keyword")); assertThat(searchResultLinks.getPrevious(), notNullValue()); assertThat(searchResultLinks.getPrevious().getMethod(), is(MethodEnum.GET)); assertThat(searchResultLinks.getPrevious().getHref(), - is("/agencyadmin/agencies?page=1&perPage=20&q=keyword")); + is("/${openapi.willBeReplaced.base-path}/agencyadmin/agencies?page=1&perPage=20&q=keyword")); assertThat(searchResultLinks.getNext(), notNullValue()); assertThat(searchResultLinks.getNext().getMethod(), is(MethodEnum.GET)); assertThat(searchResultLinks.getNext().getHref(), - is("/agencyadmin/agencies?page=3&perPage=20&q=keyword")); + is("/${openapi.willBeReplaced.base-path}/agencyadmin/agencies?page=3&perPage=20&q=keyword")); assertThat(searchResultLinks.getSearch(), notNullValue()); assertThat(searchResultLinks.getSearch().getMethod(), is(MethodEnum.GET)); assertThat(searchResultLinks.getSearch().getHref(), - is("/agencyadmin/agencies?page=2&perPage=20{&q}")); + is("/${openapi.willBeReplaced.base-path}/agencyadmin/agencies?page=2&perPage=20{&q}")); } @Test @@ -53,7 +53,7 @@ void buildAgencyAdminSearchResult_Should_havePreviousLink_When_currentPageIsNotT assertThat(searchResultLinks.getPrevious(), notNullValue()); assertThat(searchResultLinks.getPrevious().getHref(), - endsWith("/agencyadmin/agencies?page=1&perPage=20&q=keyword")); + endsWith("/${openapi.willBeReplaced.base-path}/agencyadmin/agencies?page=1&perPage=20&q=keyword")); } @Test @@ -79,7 +79,7 @@ void buildAgencyAdminSearchResult_Should_haveNextLink_When_currentPageIsNotTheLa assertThat(searchResultLinks.getNext(), notNullValue()); assertThat(searchResultLinks.getNext().getHref(), - endsWith("/agencyadmin/agencies?page=3&perPage=20&q=keyword")); + endsWith("/${openapi.willBeReplaced.base-path}/agencyadmin/agencies?page=3&perPage=20&q=keyword")); } @Test @@ -103,7 +103,7 @@ void buildSearchResultLinks_Should_returnPlaceHolderSelfLink_When_keywordIsNotSe assertThat(searchResultLinks, notNullValue()); assertThat(searchResultLinks.getSelf().getHref(), - is("/agencyadmin/agencies?page=1&perPage=20{&q}")); + is("/${openapi.willBeReplaced.base-path}/agencyadmin/agencies?page=1&perPage=20{&q}")); } @Test @@ -113,7 +113,7 @@ void buildSearchResultLinks_Should_returnDefaultPaginationValues_When_noParamete assertThat(searchResultLinks, notNullValue()); assertThat(searchResultLinks.getSelf().getHref(), - is("/agencyadmin/agencies?page=1&perPage=20{&q}")); + is("/${openapi.willBeReplaced.base-path}/agencyadmin/agencies?page=1&perPage=20{&q}")); } } diff --git a/src/test/java/de/caritas/cob/agencyservice/api/admin/service/AgencyAdminServiceITBase.java b/src/test/java/de/caritas/cob/agencyservice/api/admin/service/AgencyAdminServiceITBase.java index 49ac68e6..001b9b3e 100644 --- a/src/test/java/de/caritas/cob/agencyservice/api/admin/service/AgencyAdminServiceITBase.java +++ b/src/test/java/de/caritas/cob/agencyservice/api/admin/service/AgencyAdminServiceITBase.java @@ -62,25 +62,25 @@ public void saveAgency_Should_ProvideValidAgencyLinks() { agencyAdminFullResponseDTO.getLinks().getDelete().getHref(), endsWith( String.format( - "/agencyadmin/agencies/%s", agencyAdminFullResponseDTO.getEmbedded().getId()))); + "/${openapi.willBeReplaced.base-path}/agencyadmin/agencies/%s", agencyAdminFullResponseDTO.getEmbedded().getId()))); assertThat(agencyAdminFullResponseDTO.getLinks().getSelf(), notNullValue()); assertThat( agencyAdminFullResponseDTO.getLinks().getSelf().getHref(), endsWith( String.format( - "/agencyadmin/agencies/%s", agencyAdminFullResponseDTO.getEmbedded().getId()))); + "/${openapi.willBeReplaced.base-path}/agencyadmin/agencies/%s", agencyAdminFullResponseDTO.getEmbedded().getId()))); assertThat(agencyAdminFullResponseDTO.getLinks().getUpdate(), notNullValue()); assertThat( agencyAdminFullResponseDTO.getLinks().getUpdate().getHref(), endsWith( String.format( - "/agencyadmin/agencies/%s", agencyAdminFullResponseDTO.getEmbedded().getId()))); + "/${openapi.willBeReplaced.base-path}/agencyadmin/agencies/%s", agencyAdminFullResponseDTO.getEmbedded().getId()))); assertThat(agencyAdminFullResponseDTO.getLinks().getPostcodeRanges(), notNullValue()); assertThat( agencyAdminFullResponseDTO.getLinks().getPostcodeRanges().getHref(), endsWith( String.format( - "/agencyadmin/postcoderanges/%s", agencyAdminFullResponseDTO.getEmbedded().getId()))); + "/${openapi.willBeReplaced.base-path}/agencyadmin/postcoderanges/%s", agencyAdminFullResponseDTO.getEmbedded().getId()))); } protected AgencyDTO createAgencyDTO() { @@ -146,25 +146,25 @@ public void updateAgency_Should_ProvideValidAgencyLinks() { agencyAdminFullResponseDTO.getLinks().getDelete().getHref(), endsWith( String.format( - "/agencyadmin/agencies/%s", agencyAdminFullResponseDTO.getEmbedded().getId()))); + "/${openapi.willBeReplaced.base-path}/agencyadmin/agencies/%s", agencyAdminFullResponseDTO.getEmbedded().getId()))); assertThat(agencyAdminFullResponseDTO.getLinks().getSelf(), notNullValue()); assertThat( agencyAdminFullResponseDTO.getLinks().getSelf().getHref(), endsWith( String.format( - "/agencyadmin/agencies/%s", agencyAdminFullResponseDTO.getEmbedded().getId()))); + "/${openapi.willBeReplaced.base-path}/agencyadmin/agencies/%s", agencyAdminFullResponseDTO.getEmbedded().getId()))); assertThat(agencyAdminFullResponseDTO.getLinks().getUpdate(), notNullValue()); assertThat( agencyAdminFullResponseDTO.getLinks().getUpdate().getHref(), endsWith( String.format( - "/agencyadmin/agencies/%s", agencyAdminFullResponseDTO.getEmbedded().getId()))); + "/${openapi.willBeReplaced.base-path}/agencyadmin/agencies/%s", agencyAdminFullResponseDTO.getEmbedded().getId()))); assertThat(agencyAdminFullResponseDTO.getLinks().getPostcodeRanges(), notNullValue()); assertThat( agencyAdminFullResponseDTO.getLinks().getPostcodeRanges().getHref(), endsWith( String.format( - "/agencyadmin/postcoderanges/%s", agencyAdminFullResponseDTO.getEmbedded().getId()))); + "/${openapi.willBeReplaced.base-path}/agencyadmin/postcoderanges/%s", agencyAdminFullResponseDTO.getEmbedded().getId()))); } public void getAgency_Should_returnExpectedAgency_When_agencyWithIdExists() { diff --git a/src/test/java/de/caritas/cob/agencyservice/api/admin/service/agency/AgencyAdminFullResponseDTOBuilderTest.java b/src/test/java/de/caritas/cob/agencyservice/api/admin/service/agency/AgencyAdminFullResponseDTOBuilderTest.java index 10b3104f..8890ac3e 100644 --- a/src/test/java/de/caritas/cob/agencyservice/api/admin/service/agency/AgencyAdminFullResponseDTOBuilderTest.java +++ b/src/test/java/de/caritas/cob/agencyservice/api/admin/service/agency/AgencyAdminFullResponseDTOBuilderTest.java @@ -97,19 +97,19 @@ void fromAgency_Should_Return_ValidHalLinks() { assertThat(agencyLinks.getSelf(), notNullValue()); assertThat(agencyLinks.getSelf().getMethod(), is(MethodEnum.GET)); assertThat(agencyLinks.getSelf().getHref(), - is(String.format("/agencyadmin/agencies/%s", agency.getId()))); + is(String.format("/${openapi.willBeReplaced.base-path}/agencyadmin/agencies/%s", agency.getId()))); assertThat(agencyLinks.getDelete(), notNullValue()); assertThat(agencyLinks.getDelete().getMethod(), is(MethodEnum.DELETE)); assertThat(agencyLinks.getDelete().getHref(), - is(String.format("/agencyadmin/agencies/%s", agency.getId()))); + is(String.format("/${openapi.willBeReplaced.base-path}/agencyadmin/agencies/%s", agency.getId()))); assertThat(agencyLinks.getUpdate(), notNullValue()); assertThat(agencyLinks.getUpdate().getMethod(), is(MethodEnum.PUT)); assertThat(agencyLinks.getUpdate().getHref(), - is(String.format("/agencyadmin/agencies/%s", agency.getId()))); + is(String.format("/${openapi.willBeReplaced.base-path}/agencyadmin/agencies/%s", agency.getId()))); assertThat(agencyLinks.getPostcodeRanges(), notNullValue()); assertThat(agencyLinks.getPostcodeRanges().getMethod(), is(MethodEnum.GET)); assertThat(agencyLinks.getPostcodeRanges().getHref(), - is(String.format("/agencyadmin/postcoderanges/%s", this.agency.getId()))); + is(String.format("/${openapi.willBeReplaced.base-path}/agencyadmin/postcoderanges/%s", this.agency.getId()))); } } diff --git a/src/test/java/de/caritas/cob/agencyservice/api/admin/validation/validators/AgencyOfflineStatusValidatorTest.java b/src/test/java/de/caritas/cob/agencyservice/api/admin/validation/validators/AgencyOfflineStatusValidatorTest.java index 94a9d6a7..0ad6a62b 100644 --- a/src/test/java/de/caritas/cob/agencyservice/api/admin/validation/validators/AgencyOfflineStatusValidatorTest.java +++ b/src/test/java/de/caritas/cob/agencyservice/api/admin/validation/validators/AgencyOfflineStatusValidatorTest.java @@ -9,6 +9,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; @@ -30,14 +31,17 @@ import org.jeasy.random.EasyRandom; import org.junit.Test; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; import org.junit.runner.RunWith; import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) +@ExtendWith(MockitoExtension.class) class AgencyOfflineStatusValidatorTest { static boolean IS_OFFLINE = true; @@ -97,6 +101,7 @@ void init() { EasyRandom easyRandom = new EasyRandom(); this.validateAgencyDto = easyRandom.nextObject(ValidateAgencyDTO.class); this.consultingTypeSettings = easyRandom.nextObject(ExtendedConsultingTypeResponseDTO.class); + this.consultingTypeSettings.setWhiteSpot(easyRandom.nextObject(de.caritas.cob.agencyservice.consultingtypeservice.generated.web.model.WhiteSpotDTO.class)); } @ParameterizedTest @@ -114,11 +119,11 @@ void validate_Should_ThrowInvalidOfflineStatusException(boolean isOffline, consultingTypeSettings.setId(agency.getConsultingTypeId()); consultingTypeSettings.setLockedAgencies(isLockedAgencies); - when(agencyPostCodeRangeRepository.countAllByAgencyId(validateAgencyDto.getId())) + lenient().when(agencyPostCodeRangeRepository.countAllByAgencyId(validateAgencyDto.getId())) .thenReturn(numberOfAgencyPostcodeRanges); when(agencyRepository.findById(validateAgencyDto.getId())) .thenReturn(Optional.of(agency)); - when(this.userAdminService.getConsultantsOfAgency(anyLong(), anyInt(), anyInt())) + lenient().when(this.userAdminService.getConsultantsOfAgency(anyLong(), anyInt(), anyInt())) .thenReturn(assignedConsultants); when(consultingTypeManager.getConsultingTypeSettings(anyInt())).thenReturn(consultingTypeSettings); @@ -141,11 +146,11 @@ void validate_Should_NotThrowInvalidOfflineStatusException( consultingTypeSettings.getWhiteSpot().setWhiteSpotAgencyId(isWhiteSpotAgency ? validateAgencyDto.getId().intValue() : validateAgencyDto.getId().intValue() + 1); consultingTypeSettings.setId(AGENCY_SUCHT.getConsultingTypeId()); consultingTypeSettings.setLockedAgencies(!isOffline); - when(agencyPostCodeRangeRepository.countAllByAgencyId(validateAgencyDto.getId())) + lenient().when(agencyPostCodeRangeRepository.countAllByAgencyId(validateAgencyDto.getId())) .thenReturn(numberOfAgencyPostcodeRanges); when(agencyRepository.findById(validateAgencyDto.getId())) .thenReturn(Optional.of(AGENCY_SUCHT)); - when(this.userAdminService.getConsultantsOfAgency(anyLong(), anyInt(), anyInt())) + lenient().when(this.userAdminService.getConsultantsOfAgency(anyLong(), anyInt(), anyInt())) .thenReturn(assignedConsultants); when(consultingTypeManager.getConsultingTypeSettings(anyInt())).thenReturn(consultingTypeSettings); diff --git a/src/test/java/de/caritas/cob/agencyservice/api/controller/AgencyControllerWithSingleDomainMultitenancyIT.java b/src/test/java/de/caritas/cob/agencyservice/api/controller/AgencyControllerWithSingleDomainMultitenancyIT.java index 50884604..48ece26e 100644 --- a/src/test/java/de/caritas/cob/agencyservice/api/controller/AgencyControllerWithSingleDomainMultitenancyIT.java +++ b/src/test/java/de/caritas/cob/agencyservice/api/controller/AgencyControllerWithSingleDomainMultitenancyIT.java @@ -14,7 +14,7 @@ import de.caritas.cob.agencyservice.api.manager.consultingtype.ConsultingTypeManager; import de.caritas.cob.agencyservice.api.tenant.TenantContext; import de.caritas.cob.agencyservice.applicationsettingsservice.generated.web.model.ApplicationSettingsDTO; -import de.caritas.cob.agencyservice.applicationsettingsservice.generated.web.model.SettingDTO; +import de.caritas.cob.agencyservice.applicationsettingsservice.generated.web.model.ApplicationSettingsDTOMainTenantSubdomainForSingleDomainMultitenancy; import de.caritas.cob.agencyservice.config.apiclient.ApplicationSettingsApiControllerFactory; import de.caritas.cob.agencyservice.config.apiclient.TenantServiceApiControllerFactory; import de.caritas.cob.agencyservice.tenantservice.generated.web.model.RestrictedTenantDTO; @@ -79,7 +79,7 @@ public void setUp() throws MissingConsultingTypeException { .thenReturn( new de.caritas.cob.agencyservice.consultingtypeservice.generated.web.model.ExtendedConsultingTypeResponseDTO()); when(applicationsettingsControllerApi.getApplicationSettings()).thenReturn(new ApplicationSettingsDTO() - .mainTenantSubdomainForSingleDomainMultitenancy(new SettingDTO().value("app"))); + .mainTenantSubdomainForSingleDomainMultitenancy(new ApplicationSettingsDTOMainTenantSubdomainForSingleDomainMultitenancy().value("app"))); when(tenantControllerApi.getRestrictedTenantDataBySubdomain("app")).thenReturn(new RestrictedTenantDTO().id(0L)); when(tenantServiceApiControllerFactory.createControllerApi()).thenReturn(tenantControllerApi); } diff --git a/src/test/java/de/caritas/cob/agencyservice/api/service/AgencyServiceITBase.java b/src/test/java/de/caritas/cob/agencyservice/api/service/AgencyServiceITBase.java index 65c7200e..2de85f8b 100644 --- a/src/test/java/de/caritas/cob/agencyservice/api/service/AgencyServiceITBase.java +++ b/src/test/java/de/caritas/cob/agencyservice/api/service/AgencyServiceITBase.java @@ -1,5 +1,18 @@ package de.caritas.cob.agencyservice.api.service; +import java.util.List; +import java.util.Optional; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.mock.mockito.MockBean; + +import de.caritas.cob.agencyservice.api.exception.MissingConsultingTypeException; +import de.caritas.cob.agencyservice.api.manager.consultingtype.ConsultingTypeManager; +import de.caritas.cob.agencyservice.api.model.AgencyResponseDTO; +import de.caritas.cob.agencyservice.api.model.FullAgencyResponseDTO; +import de.caritas.cob.agencyservice.api.repository.agency.Agency; +import de.caritas.cob.agencyservice.api.repository.agency.AgencyRepository; + import static de.caritas.cob.agencyservice.testHelper.TestConstants.CONSULTING_TYPE_PREGNANCY; import static de.caritas.cob.agencyservice.testHelper.TestConstants.CONSULTING_TYPE_SETTINGS_PREGNANCY; import static de.caritas.cob.agencyservice.testHelper.TestConstants.CONSULTING_TYPE_U25; @@ -11,29 +24,6 @@ import static org.junit.Assert.assertTrue; import static org.powermock.api.mockito.PowerMockito.when; -import de.caritas.cob.agencyservice.AgencyServiceApplication; -import de.caritas.cob.agencyservice.api.exception.MissingConsultingTypeException; -import de.caritas.cob.agencyservice.api.manager.consultingtype.ConsultingTypeManager; -import de.caritas.cob.agencyservice.api.model.AgencyResponseDTO; -import de.caritas.cob.agencyservice.api.model.FullAgencyResponseDTO; -import de.caritas.cob.agencyservice.api.repository.agency.Agency; -import de.caritas.cob.agencyservice.api.repository.agency.AgencyRepository; -import java.util.List; -import java.util.Optional; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import org.checkerframework.checker.nullness.Opt; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; -import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; - public class AgencyServiceITBase { @Autowired diff --git a/src/test/java/de/caritas/cob/agencyservice/api/service/AgencyServiceTenantAwareTest.java b/src/test/java/de/caritas/cob/agencyservice/api/service/AgencyServiceTenantAwareTest.java index 04d57e22..c9c2a008 100644 --- a/src/test/java/de/caritas/cob/agencyservice/api/service/AgencyServiceTenantAwareTest.java +++ b/src/test/java/de/caritas/cob/agencyservice/api/service/AgencyServiceTenantAwareTest.java @@ -11,6 +11,7 @@ import de.caritas.cob.agencyservice.api.tenant.TenantContext; import de.caritas.cob.agencyservice.consultingtypeservice.generated.web.model.ExtendedConsultingTypeResponseDTO; import de.caritas.cob.agencyservice.consultingtypeservice.generated.web.model.RegistrationDTO; +import de.caritas.cob.agencyservice.consultingtypeservice.generated.web.model.BasicConsultingTypeResponseDTORegistration; import de.caritas.cob.agencyservice.tenantservice.generated.web.model.RestrictedTenantDTO; import de.caritas.cob.agencyservice.tenantservice.generated.web.model.Settings; import java.util.Optional; @@ -62,7 +63,7 @@ public void getAgencies_Should_throwBadRequestException_When_topicIdNotProvidedA // given ReflectionTestUtils.setField(agencyService, "topicsFeatureEnabled", true); ExtendedConsultingTypeResponseDTO dto = new ExtendedConsultingTypeResponseDTO().registration( - new RegistrationDTO().minPostcodeSize(5)); + new BasicConsultingTypeResponseDTORegistration().minPostcodeSize(5)); when(consultingTypeManager.getConsultingTypeSettings(1)).thenReturn(dto); RestrictedTenantDTO restrictedTenantDTO = new RestrictedTenantDTO().settings( new Settings().topicsInRegistrationEnabled(true)); @@ -84,7 +85,7 @@ public void getAgencies_Should_searchByTopicId_When_topicIdProvidedAndFeatureEna // given ReflectionTestUtils.setField(agencyService, "topicsFeatureEnabled", true); ExtendedConsultingTypeResponseDTO dto = new ExtendedConsultingTypeResponseDTO().registration( - new RegistrationDTO().minPostcodeSize(5)); + new BasicConsultingTypeResponseDTORegistration().minPostcodeSize(5)); when(consultingTypeManager.getConsultingTypeSettings(1)).thenReturn(dto); RestrictedTenantDTO restrictedTenantDTO = new RestrictedTenantDTO().settings( new Settings().topicsInRegistrationEnabled(true)); diff --git a/src/test/java/de/caritas/cob/agencyservice/api/service/AgencyServiceTest.java b/src/test/java/de/caritas/cob/agencyservice/api/service/AgencyServiceTest.java index c7968836..a36360e8 100644 --- a/src/test/java/de/caritas/cob/agencyservice/api/service/AgencyServiceTest.java +++ b/src/test/java/de/caritas/cob/agencyservice/api/service/AgencyServiceTest.java @@ -41,6 +41,7 @@ import de.caritas.cob.agencyservice.api.repository.agency.Agency; import de.caritas.cob.agencyservice.api.repository.agency.AgencyRepository; import de.caritas.cob.agencyservice.api.tenant.TenantContext; +import de.caritas.cob.agencyservice.consultingtypeservice.generated.web.model.BasicConsultingTypeResponseDTORegistration; import de.caritas.cob.agencyservice.consultingtypeservice.generated.web.model.ExtendedConsultingTypeResponseDTO; import de.caritas.cob.agencyservice.consultingtypeservice.generated.web.model.RegistrationDTO; import de.caritas.cob.agencyservice.tenantservice.generated.web.model.RestrictedTenantDTO; @@ -294,7 +295,7 @@ public void getAgencies_Should_throwBadRequestException_When_TopicIdNotProvidedA // given ReflectionTestUtils.setField(agencyService, "topicsFeatureEnabled", true); ExtendedConsultingTypeResponseDTO dto = new ExtendedConsultingTypeResponseDTO().registration( - new RegistrationDTO().minPostcodeSize(5)); + new BasicConsultingTypeResponseDTORegistration().minPostcodeSize(5)); when(consultingTypeManager.getConsultingTypeSettings(1)).thenReturn(dto); RestrictedTenantDTO restrictedTenantDTO = new RestrictedTenantDTO().settings( new Settings().topicsInRegistrationEnabled(true)); @@ -310,7 +311,7 @@ public void getAgencies_Should_searchByTopicId_When_TopicIdProvidedAndFeatureEna // given ReflectionTestUtils.setField(agencyService, "topicsFeatureEnabled", true); ExtendedConsultingTypeResponseDTO dto = new ExtendedConsultingTypeResponseDTO().registration( - new RegistrationDTO().minPostcodeSize(5)); + new BasicConsultingTypeResponseDTORegistration().minPostcodeSize(5)); when(consultingTypeManager.getConsultingTypeSettings(1)).thenReturn(dto); RestrictedTenantDTO restrictedTenantDTO = new RestrictedTenantDTO().settings( new Settings().topicsInRegistrationEnabled(true)); diff --git a/src/test/java/de/caritas/cob/agencyservice/api/tenant/MultitenancyWithSingleDomainTenantResolverTest.java b/src/test/java/de/caritas/cob/agencyservice/api/tenant/MultitenancyWithSingleDomainTenantResolverTest.java index 1117b67c..0d596e47 100644 --- a/src/test/java/de/caritas/cob/agencyservice/api/tenant/MultitenancyWithSingleDomainTenantResolverTest.java +++ b/src/test/java/de/caritas/cob/agencyservice/api/tenant/MultitenancyWithSingleDomainTenantResolverTest.java @@ -5,7 +5,7 @@ import static org.mockito.Mockito.when; import de.caritas.cob.agencyservice.applicationsettingsservice.generated.web.model.ApplicationSettingsDTO; -import de.caritas.cob.agencyservice.applicationsettingsservice.generated.web.model.SettingDTO; +import de.caritas.cob.agencyservice.applicationsettingsservice.generated.web.model.ApplicationSettingsDTOMainTenantSubdomainForSingleDomainMultitenancy; import de.caritas.cob.agencyservice.config.apiclient.ApplicationSettingsApiControllerFactory; import de.caritas.cob.agencyservice.config.apiclient.TenantServiceApiControllerFactory; import de.caritas.cob.agencyservice.tenantservice.generated.web.model.RestrictedTenantDTO; @@ -87,7 +87,7 @@ void resolve_Should_resolveToTenantIdBasedOnMainTenantSubdomainValue_When_Applic when(applicationSettingsApiControllerFactory.createControllerApi()).thenReturn(applicationsettingsControllerApi); when(applicationsettingsControllerApi.getApplicationSettings()).thenReturn( new ApplicationSettingsDTO().mainTenantSubdomainForSingleDomainMultitenancy( - new SettingDTO().value("app"))); + new ApplicationSettingsDTOMainTenantSubdomainForSingleDomainMultitenancy().value("app"))); when(tenantControllerApi.getRestrictedTenantDataBySubdomain("app")).thenReturn( new RestrictedTenantDTO().id(1L)); // when diff --git a/src/test/java/de/caritas/cob/agencyservice/api/tenant/TenantResolverServiceTest.java b/src/test/java/de/caritas/cob/agencyservice/api/tenant/TenantResolverServiceTest.java index d61c6835..29dc2a67 100644 --- a/src/test/java/de/caritas/cob/agencyservice/api/tenant/TenantResolverServiceTest.java +++ b/src/test/java/de/caritas/cob/agencyservice/api/tenant/TenantResolverServiceTest.java @@ -1,32 +1,21 @@ package de.caritas.cob.agencyservice.api.tenant; -import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.Mockito.when; - -import com.google.common.collect.Maps; -import de.caritas.cob.agencyservice.api.service.TenantHeaderSupplier; -import de.caritas.cob.agencyservice.api.service.TenantService; -import de.caritas.cob.agencyservice.filter.SubdomainExtractor; -import java.util.HashMap; import java.util.Optional; + import javax.servlet.http.HttpServletRequest; -import liquibase.pro.packaged.L; -import org.assertj.core.util.Sets; -import org.checkerframework.checker.nullness.Opt; -import org.junit.Ignore; -import org.junit.jupiter.api.Disabled; + import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken; -import org.keycloak.representations.AccessToken; -import org.keycloak.representations.AccessToken.Access; import org.mockito.Answers; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.security.access.AccessDeniedException; -import org.springframework.web.context.request.ServletRequestAttributes; + +import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) class TenantResolverServiceTest { diff --git a/src/test/java/de/caritas/cob/agencyservice/testHelper/ExtendedConsultingTypeResponseDTOHelper.java b/src/test/java/de/caritas/cob/agencyservice/testHelper/ExtendedConsultingTypeResponseDTOHelper.java index 98cc5fd5..f61f4d4d 100644 --- a/src/test/java/de/caritas/cob/agencyservice/testHelper/ExtendedConsultingTypeResponseDTOHelper.java +++ b/src/test/java/de/caritas/cob/agencyservice/testHelper/ExtendedConsultingTypeResponseDTOHelper.java @@ -4,8 +4,8 @@ import de.caritas.cob.agencyservice.api.manager.consultingtype.registration.Registration; import de.caritas.cob.agencyservice.api.manager.consultingtype.whiteSpot.WhiteSpot; +import de.caritas.cob.agencyservice.consultingtypeservice.generated.web.model.BasicConsultingTypeResponseDTORegistration; import de.caritas.cob.agencyservice.consultingtypeservice.generated.web.model.ExtendedConsultingTypeResponseDTO; -import de.caritas.cob.agencyservice.consultingtypeservice.generated.web.model.RegistrationDTO; import de.caritas.cob.agencyservice.consultingtypeservice.generated.web.model.WhiteSpotDTO; public class ExtendedConsultingTypeResponseDTOHelper { @@ -24,9 +24,9 @@ public static ExtendedConsultingTypeResponseDTO createExtendedConsultingTypeResp whiteSpotDTO.setWhiteSpotAgencyAssigned(whiteSpot.isWhiteSpotAgencyAssigned()); } - RegistrationDTO registrationDTO = null; + BasicConsultingTypeResponseDTORegistration registrationDTO = null; if (nonNull(registration)) { - registrationDTO = new RegistrationDTO(); + registrationDTO = new BasicConsultingTypeResponseDTORegistration(); registrationDTO.setMinPostcodeSize(registration.getMinPostcodeSize()); } extendedConsultingTypeResponseDTO.setLockedAgencies(isLockedAgencies);