From 3b9a16730ed82c4da6f7028f41fbcd1db60c159e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Mino?= Date: Wed, 4 Dec 2024 08:52:49 +0100 Subject: [PATCH 1/5] chore(deps): upgrade to spring-boot 3.4.0 --- src/main/resources/generator/dependencies/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/generator/dependencies/pom.xml b/src/main/resources/generator/dependencies/pom.xml index 72b6b95e902..f1b629008f8 100644 --- a/src/main/resources/generator/dependencies/pom.xml +++ b/src/main/resources/generator/dependencies/pom.xml @@ -16,7 +16,7 @@ @project.version@ 8.0 - 3.3.5 + 3.4.0 2023.0.4 4.2.0 2.6.0 From 987b826b1e71d506f4b91a682c39732a06f609cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Mino?= Date: Wed, 4 Dec 2024 08:53:03 +0100 Subject: [PATCH 2/5] chore(deps): upgrade to springdoc-openapi 2.7.0 --- src/main/resources/generator/dependencies/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/generator/dependencies/pom.xml b/src/main/resources/generator/dependencies/pom.xml index f1b629008f8..e54628eecbc 100644 --- a/src/main/resources/generator/dependencies/pom.xml +++ b/src/main/resources/generator/dependencies/pom.xml @@ -19,7 +19,7 @@ 3.4.0 2023.0.4 4.2.0 - 2.6.0 + 2.7.0 3.9.0 5.5.0 2.15.0 From e5484b8cb5d096b4c092d759c2b685796d743768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Mino?= Date: Wed, 4 Dec 2024 08:54:42 +0100 Subject: [PATCH 3/5] chore(spring-boot): replace deprecated MockBean by MockitoBean --- .../server/springboot/cucumber/cucumber.md.mustache | 2 +- .../gateway/java/test/GatewayResourceIT.java.mustache | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/resources/generator/server/springboot/cucumber/cucumber.md.mustache b/src/main/resources/generator/server/springboot/cucumber/cucumber.md.mustache index c206be2f39e..26106356450 100644 --- a/src/main/resources/generator/server/springboot/cucumber/cucumber.md.mustache +++ b/src/main/resources/generator/server/springboot/cucumber/cucumber.md.mustache @@ -112,7 +112,7 @@ Behind the scene, your last service will be recalled until the assertions are OK ## Mocking beans -You may need to mock beans for your component tests, but you won't be able to do it in a "classic" way (using `@MockBean`) since the application context will be already loaded. A way to achieve that is to overload beans to have mocks: +You may need to mock beans for your component tests, but you won't be able to do it in a "classic" way (using `@MockitoBean`) since the application context will be already loaded. A way to achieve that is to overload beans to have mocks: ```java @ActiveProfiles("test") diff --git a/src/main/resources/generator/server/springboot/springcloud/gateway/java/test/GatewayResourceIT.java.mustache b/src/main/resources/generator/server/springboot/springcloud/gateway/java/test/GatewayResourceIT.java.mustache index de77d1494c3..7968b8c77f4 100644 --- a/src/main/resources/generator/server/springboot/springcloud/gateway/java/test/GatewayResourceIT.java.mustache +++ b/src/main/resources/generator/server/springboot/springcloud/gateway/java/test/GatewayResourceIT.java.mustache @@ -17,7 +17,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.cloud.client.DefaultServiceInstance; import org.springframework.cloud.client.ServiceInstance; import org.springframework.cloud.client.discovery.DiscoveryClient; @@ -25,6 +24,7 @@ import org.springframework.cloud.gateway.handler.AsyncPredicate; import org.springframework.cloud.gateway.handler.predicate.PathRoutePredicateFactory; import org.springframework.cloud.gateway.route.Route; import org.springframework.cloud.gateway.route.RouteLocator; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.web.reactive.server.FluxExchangeResult; import org.springframework.test.web.reactive.server.WebTestClient; import org.springframework.web.server.ServerWebExchange; @@ -35,10 +35,10 @@ import reactor.test.StepVerifier; @AutoConfigureWebTestClient class GatewayResourceIT { - @MockBean + @MockitoBean private DiscoveryClient discoveryClient; - @MockBean + @MockitoBean private RouteLocator routeLocator; @Autowired From b10a008b46047b1657445e83df9f33229f4147bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Mino?= Date: Wed, 4 Dec 2024 09:01:00 +0100 Subject: [PATCH 4/5] chore(liquibase): handle change in LiquibaseProperties Contexts and labelFilter are now a collection and not a string anymore --- .../main/LiquibaseConfiguration.java.mustache | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/resources/generator/server/springboot/dbmigration/liquibase/main/LiquibaseConfiguration.java.mustache b/src/main/resources/generator/server/springboot/dbmigration/liquibase/main/LiquibaseConfiguration.java.mustache index 71f9b993606..13b3e143ef1 100644 --- a/src/main/resources/generator/server/springboot/dbmigration/liquibase/main/LiquibaseConfiguration.java.mustache +++ b/src/main/resources/generator/server/springboot/dbmigration/liquibase/main/LiquibaseConfiguration.java.mustache @@ -16,6 +16,9 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; +import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; +import {{packageName}}.shared.generation.domain.ExcludeFromGeneratedCodeCoverage; @Configuration @EnableConfigurationProperties({ LiquibaseProperties.class }) @@ -34,6 +37,7 @@ class LiquibaseConfiguration { } @Bean + @ExcludeFromGeneratedCodeCoverage(reason = "Not testing all liquibase properties configuration") public SpringLiquibase liquibase( @Qualifier("taskExecutor") Executor executor, @LiquibaseDataSource ObjectProvider liquibaseDataSource, @@ -62,14 +66,18 @@ class LiquibaseConfiguration { ); } liquibase.setChangeLog(liquibaseProperties.getChangeLog()); - liquibase.setContexts(liquibaseProperties.getContexts()); + if (!CollectionUtils.isEmpty(liquibaseProperties.getContexts())) { + liquibase.setContexts(StringUtils.collectionToCommaDelimitedString(liquibaseProperties.getContexts())); + } liquibase.setDefaultSchema(liquibaseProperties.getDefaultSchema()); liquibase.setLiquibaseSchema(liquibaseProperties.getLiquibaseSchema()); liquibase.setLiquibaseTablespace(liquibaseProperties.getLiquibaseTablespace()); liquibase.setDatabaseChangeLogLockTable(liquibaseProperties.getDatabaseChangeLogLockTable()); liquibase.setDatabaseChangeLogTable(liquibaseProperties.getDatabaseChangeLogTable()); liquibase.setDropFirst(liquibaseProperties.isDropFirst()); - liquibase.setLabelFilter(liquibaseProperties.getLabelFilter()); + if (!CollectionUtils.isEmpty(liquibaseProperties.getLabelFilter())) { + liquibase.setContexts(StringUtils.collectionToCommaDelimitedString(liquibaseProperties.getLabelFilter())); + } liquibase.setChangeLogParameters(liquibaseProperties.getParameters()); liquibase.setRollbackFile(liquibaseProperties.getRollbackFile()); liquibase.setTestRollbackOnUpdate(liquibaseProperties.isTestRollbackOnUpdate()); From edb51d0d8725bc24bd45659efce098960b79d526 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Mino?= Date: Wed, 4 Dec 2024 21:36:22 +0100 Subject: [PATCH 5/5] chore(authentication): replace deprecated methods --- .../primary/SecurityConfiguration.java.mustache | 2 +- .../primary/SecurityConfiguration.java.mustache | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/generator/server/springboot/mvc/security/jwt/authentication/main/infrastructure/primary/SecurityConfiguration.java.mustache b/src/main/resources/generator/server/springboot/mvc/security/jwt/authentication/main/infrastructure/primary/SecurityConfiguration.java.mustache index 2f793113544..fd46970e1a0 100644 --- a/src/main/resources/generator/server/springboot/mvc/security/jwt/authentication/main/infrastructure/primary/SecurityConfiguration.java.mustache +++ b/src/main/resources/generator/server/springboot/mvc/security/jwt/authentication/main/infrastructure/primary/SecurityConfiguration.java.mustache @@ -59,7 +59,7 @@ class SecurityConfiguration { .contentSecurityPolicy(csp -> csp.policyDirectives(properties.getContentSecurityPolicy())) .frameOptions(FrameOptionsConfig::deny) .referrerPolicy(referrer -> referrer.policy(ReferrerPolicyHeaderWriter.ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN)) - .permissionsPolicy(permissions -> + .permissionsPolicyHeader(permissions -> permissions.policy("camera=(), fullscreen=(self), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), midi=(), payment=(), sync-xhr=()")) ) .formLogin(AbstractHttpConfigurer::disable) diff --git a/src/main/resources/generator/server/springboot/mvc/security/oauth2/core/main/infrastructure/primary/SecurityConfiguration.java.mustache b/src/main/resources/generator/server/springboot/mvc/security/oauth2/core/main/infrastructure/primary/SecurityConfiguration.java.mustache index 46786a9d0ef..d0068515c2b 100644 --- a/src/main/resources/generator/server/springboot/mvc/security/oauth2/core/main/infrastructure/primary/SecurityConfiguration.java.mustache +++ b/src/main/resources/generator/server/springboot/mvc/security/oauth2/core/main/infrastructure/primary/SecurityConfiguration.java.mustache @@ -72,7 +72,7 @@ class SecurityConfiguration { .contentSecurityPolicy(csp -> csp.policyDirectives(applicationSecurityProperties.getContentSecurityPolicy())) .frameOptions(FrameOptionsConfig::sameOrigin) .referrerPolicy(referrer -> referrer.policy(ReferrerPolicyHeaderWriter.ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN)) - .permissionsPolicy(permissions -> + .permissionsPolicyHeader(permissions -> permissions.policy("camera=(), fullscreen=(self), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), midi=(), payment=(), sync-xhr=()")) ) .authorizeHttpRequests(authz -> authz @@ -145,7 +145,7 @@ class SecurityConfiguration { jwtDecoder.setClaimSetConverter( new CustomClaimConverter( clientRegistrationRepository.findByRegistrationId("oidc"), - restTemplateBuilder.setConnectTimeout(Duration.ofMillis(TIMEOUT)).setReadTimeout(Duration.ofMillis(TIMEOUT)).build() + restTemplateBuilder.connectTimeout(Duration.ofMillis(TIMEOUT)).readTimeout(Duration.ofMillis(TIMEOUT)).build() ) );