diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a296a501..74a78eaf 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -28,7 +28,7 @@ jobs: steps: # Checkout with all submodules - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: 'true' @@ -58,7 +58,7 @@ jobs: - name: Set up Cloud SDK uses: google-github-actions/setup-gcloud@main with: - version: '290.0.1' + version: '418.0.0' service_account_key: ${{ secrets.GCP_SA_KEY }} project_id: ${{ secrets.GCP_PROJECT_ID }} diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index e1b67af4..adfd6590 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -29,14 +29,14 @@ on: jobs: build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest permissions: contents: read packages: write steps: - name: Checkout repository - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v3 - name: Login to GitHub Container Registry if: github.event_name != 'pull_request' diff --git a/.github/workflows/github-ci.yml b/.github/workflows/github-ci.yml index c73244f0..df030fea 100644 --- a/.github/workflows/github-ci.yml +++ b/.github/workflows/github-ci.yml @@ -25,21 +25,24 @@ jobs: if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.pull_request.title, '[skip ci]') && !contains(github.event.pull_request.title, '[ci skip]')" timeout-minutes: 40 env: - NODE_VERSION: 14.17.6 + NODE_VERSION: 16.19.0 SPRING_OUTPUT_ANSI_ENABLED: DETECT SPRING_JPA_SHOW_SQL: false JHI_DISABLE_WEBPACK_LOGS: true NG_CLI_ANALYTICS: false steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 with: - node-version: 14.17.6 + node-version: 16.19.0 - - uses: actions/setup-java@v1 + - name: Set up Java + uses: actions/setup-java@v3 with: + distribution: 'temurin' java-version: '11' + cache: 'maven' - name: Stop MySQL server run: sudo /etc/init.d/mysql stop diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 00000000..c1dd12f1 Binary files /dev/null and b/.mvn/wrapper/maven-wrapper.jar differ diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index abd303b6..b74bf7fc 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1,2 +1,2 @@ -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.2/apache-maven-3.8.2-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar diff --git a/checkstyle.xml b/checkstyle.xml index 6e3dbafe..4666f08a 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -9,8 +9,7 @@ - + 3.3.9 11 - v14.17.6 - v1.22.4 + v16.19.0 + v1.22.19 UTF-8 UTF-8 ${project.build.directory}/test-results @@ -40,45 +40,49 @@ - 3.6.0 + 7.9.3 - 2.2.5.RELEASE + https://mvnrepository.com/artifact/tech.jhipster/jhipster-dependencies/${jhipster-dependencies.version} --> + 2.7.3 - 5.4.12.Final - - 3.24.0-GA + 5.6.10.Final - 3.8.7 - 3.8 + 4.15.0 + 4.15.0 2.0.1.Final - 2.3.2 - 0.13.1 - 1.3.1.Final + 4.0.0 + 0.22.0 + 1.5.2.Final - 3.1.0 - 3.8.1 - 3.1.1 + 3.2.0 + 3.12.1 + 3.10.1 + 3.4.1 2.10 - 3.0.0-M3 - 3.0.0-M4 + 3.1.0 + 3.0.0-M7 + 3.2.2 2.2.1 - 3.1.0 - 3.0.0-M4 - 3.2.3 - 3.1.1 - 1.4.3 - 8.29 - 0.0.4.RELEASE - 1.9.1 - 4.0.0 - 0.8.5 + 3.3.0 + 3.0.0-M7 + 3.3.2 + 3.1.2 + 10.3.2 + 0.0.10 + 1.12.1 + 1.11 + 3.1.0 + 5.0.0 + 2.4.0 + 0.8.8 + 3.2.1 + eclipse-temurin:11-jre-focal + amd64 1.0.0 - 1.0.0 - 3.7.0.1746 + 1.1.0 + 3.9.1.2184 ${project.build.directory}/jacoco/test ${jacoco.utReportFolder}/test.exec ${project.build.directory}/jacoco/integrationTest @@ -86,18 +90,25 @@ ${project.testresult.directory}/test ${project.testresult.directory}/integrationTest - 1.0.16 + 1.10.0 - io.github.jhipster + tech.jhipster jhipster-dependencies ${jhipster-dependencies.version} pom import + + org.testcontainers + testcontainers-bom + 1.17.3 + pom + import + @@ -106,25 +117,25 @@ org.kohsuke github-api - 1.116 + 1.313 org.gitlab java-gitlab-api - 4.0.0 + 4.1.1 org.zeroturnaround zt-zip - 1.11 + 1.15 org.eclipse.jgit org.eclipse.jgit - 4.8.0.201706111038-r + 6.4.0.202211300538-r - io.github.jhipster + tech.jhipster jhipster-framework @@ -152,27 +163,10 @@ com.fasterxml.jackson.datatype jackson-datatype-jsr310 - - com.fasterxml.jackson.module - jackson-module-afterburner - - - com.h2database - h2 - test - com.jayway.jsonpath json-path - - io.springfox - springfox-swagger2 - - - io.springfox - springfox-bean-validators - com.zaxxer HikariCP @@ -274,6 +268,11 @@ org.springframework.boot spring-boot-starter-thymeleaf + + com.google.guava + guava + 31.1-jre + org.springframework.boot spring-boot-starter-web @@ -289,6 +288,21 @@ + + org.testcontainers + testcontainers + test + + + org.testcontainers + junit-jupiter + test + + + org.testcontainers + mysql + test + org.springframework.boot spring-boot-test @@ -332,10 +346,6 @@ runtime - - org.springframework.boot - spring-boot-starter-cloud-connectors - org.springframework.security spring-security-data @@ -417,7 +427,6 @@ org.apache.maven.plugins maven-checkstyle-plugin - ${maven-checkstyle.version} com.puppycrawl.tools @@ -427,7 +436,7 @@ io.spring.nohttp nohttp-checkstyle - ${spring-nohttp-checkstyle.version} + ${nohttp-checkstyle.version} @@ -537,7 +546,7 @@ - pl.project13.maven + io.github.git-commit-id git-commit-id-plugin ${git-commit-id-plugin.version} @@ -647,11 +656,6 @@ validation-api ${validation-api.version} - - org.javassist - javassist - ${javassist.version} - @@ -699,7 +703,7 @@ You are running an incompatible version of Java. JHipster supports JDK 8 to 13. - [1.8,14) + [1.8,20) diff --git a/src/main/docker/mysql.yml b/src/main/docker/mysql.yml index 66c6fbdf..f6834b11 100644 --- a/src/main/docker/mysql.yml +++ b/src/main/docker/mysql.yml @@ -1,11 +1,10 @@ version: '2' services: jhonline-mysql: - image: mysql:5.7.20 + image: mysql:8 # volumes: # - ~/volumes/jhipster/jhonline/mysql/:/var/lib/mysql/ environment: - - MYSQL_USER=root - MYSQL_ALLOW_EMPTY_PASSWORD=yes - MYSQL_DATABASE=jhipster-online ports: diff --git a/src/main/java/io/github/jhipster/online/ApplicationWebXml.java b/src/main/java/io/github/jhipster/online/ApplicationWebXml.java index 6eaa7254..92b65105 100644 --- a/src/main/java/io/github/jhipster/online/ApplicationWebXml.java +++ b/src/main/java/io/github/jhipster/online/ApplicationWebXml.java @@ -18,9 +18,9 @@ */ package io.github.jhipster.online; -import io.github.jhipster.config.DefaultProfileUtil; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; +import tech.jhipster.config.DefaultProfileUtil; /** * This is a helper Java class that provides an alternative to creating a {@code web.xml}. diff --git a/src/main/java/io/github/jhipster/online/JhonlineApp.java b/src/main/java/io/github/jhipster/online/JhonlineApp.java index 56ad7a31..4d667e35 100644 --- a/src/main/java/io/github/jhipster/online/JhonlineApp.java +++ b/src/main/java/io/github/jhipster/online/JhonlineApp.java @@ -18,8 +18,6 @@ */ package io.github.jhipster.online; -import io.github.jhipster.config.DefaultProfileUtil; -import io.github.jhipster.config.JHipsterConstants; import io.github.jhipster.online.config.ApplicationProperties; import java.net.InetAddress; import java.net.UnknownHostException; @@ -34,6 +32,8 @@ import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.core.env.Environment; +import tech.jhipster.config.DefaultProfileUtil; +import tech.jhipster.config.JHipsterConstants; @SpringBootApplication @EnableConfigurationProperties({ LiquibaseProperties.class, ApplicationProperties.class }) diff --git a/src/main/java/io/github/jhipster/online/aop/logging/LoggingAspect.java b/src/main/java/io/github/jhipster/online/aop/logging/LoggingAspect.java index e72c04f0..ae81c307 100644 --- a/src/main/java/io/github/jhipster/online/aop/logging/LoggingAspect.java +++ b/src/main/java/io/github/jhipster/online/aop/logging/LoggingAspect.java @@ -18,7 +18,6 @@ */ package io.github.jhipster.online.aop.logging; -import io.github.jhipster.config.JHipsterConstants; import java.util.Arrays; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.ProceedingJoinPoint; @@ -30,6 +29,7 @@ import org.slf4j.LoggerFactory; import org.springframework.core.env.Environment; import org.springframework.core.env.Profiles; +import tech.jhipster.config.JHipsterConstants; /** * Aspect for logging execution of service and repository Spring components. diff --git a/src/main/java/io/github/jhipster/online/config/AsyncConfiguration.java b/src/main/java/io/github/jhipster/online/config/AsyncConfiguration.java index 0b5c0f0d..9e48319c 100644 --- a/src/main/java/io/github/jhipster/online/config/AsyncConfiguration.java +++ b/src/main/java/io/github/jhipster/online/config/AsyncConfiguration.java @@ -18,7 +18,6 @@ */ package io.github.jhipster.online.config; -import io.github.jhipster.async.ExceptionHandlingAsyncTaskExecutor; import java.util.concurrent.Executor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -31,6 +30,7 @@ import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; +import tech.jhipster.async.ExceptionHandlingAsyncTaskExecutor; @Configuration @EnableAsync diff --git a/src/main/java/io/github/jhipster/online/config/CacheConfiguration.java b/src/main/java/io/github/jhipster/online/config/CacheConfiguration.java index a9ca275a..db1ec226 100644 --- a/src/main/java/io/github/jhipster/online/config/CacheConfiguration.java +++ b/src/main/java/io/github/jhipster/online/config/CacheConfiguration.java @@ -19,7 +19,6 @@ package io.github.jhipster.online.config; -import io.github.jhipster.config.JHipsterProperties; import java.time.Duration; import javax.cache.CacheManager; import org.ehcache.config.builders.CacheConfigurationBuilder; @@ -32,6 +31,7 @@ import org.springframework.cache.annotation.EnableCaching; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import tech.jhipster.config.JHipsterProperties; @Configuration @EnableCaching diff --git a/src/main/java/io/github/jhipster/online/config/CloudDatabaseConfiguration.java b/src/main/java/io/github/jhipster/online/config/CloudDatabaseConfiguration.java deleted file mode 100644 index a6d7fe92..00000000 --- a/src/main/java/io/github/jhipster/online/config/CloudDatabaseConfiguration.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright 2017-2023 the original author or authors from the JHipster project. - * - * This file is part of the JHipster Online project, see https://github.com/jhipster/jhipster-online - * for more information. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.github.jhipster.online.config; - -import io.github.jhipster.config.JHipsterConstants; -import javax.sql.DataSource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.cloud.config.java.AbstractCloudConfig; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; - -@Configuration -@Profile(JHipsterConstants.SPRING_PROFILE_CLOUD) -public class CloudDatabaseConfiguration extends AbstractCloudConfig { - - private final Logger log = LoggerFactory.getLogger(CloudDatabaseConfiguration.class); - - private static final String CLOUD_CONFIGURATION_HIKARI_PREFIX = "spring.datasource.hikari"; - - @Bean - @ConfigurationProperties(CLOUD_CONFIGURATION_HIKARI_PREFIX) - public DataSource dataSource() { - log.info("Configuring JDBC datasource from a cloud provider"); - return connectionFactory().dataSource(); - } -} diff --git a/src/main/java/io/github/jhipster/online/config/JacksonConfiguration.java b/src/main/java/io/github/jhipster/online/config/JacksonConfiguration.java index fdebfc95..7da2cd48 100644 --- a/src/main/java/io/github/jhipster/online/config/JacksonConfiguration.java +++ b/src/main/java/io/github/jhipster/online/config/JacksonConfiguration.java @@ -21,10 +21,9 @@ import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module; import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; -import com.fasterxml.jackson.module.afterburner.AfterburnerModule; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.zalando.problem.ProblemModule; +import org.zalando.problem.jackson.ProblemModule; import org.zalando.problem.violations.ConstraintViolationProblemModule; @Configuration @@ -52,14 +51,6 @@ public Hibernate5Module hibernate5Module() { return new Hibernate5Module(); } - /* - * Jackson Afterburner module to speed up serialization/deserialization. - */ - @Bean - public AfterburnerModule afterburnerModule() { - return new AfterburnerModule(); - } - /* * Module for serialization/deserialization of RFC7807 Problem. */ diff --git a/src/main/java/io/github/jhipster/online/config/LiquibaseConfiguration.java b/src/main/java/io/github/jhipster/online/config/LiquibaseConfiguration.java index a96531b2..36591dee 100644 --- a/src/main/java/io/github/jhipster/online/config/LiquibaseConfiguration.java +++ b/src/main/java/io/github/jhipster/online/config/LiquibaseConfiguration.java @@ -19,8 +19,6 @@ package io.github.jhipster.online.config; -import io.github.jhipster.config.JHipsterConstants; -import io.github.jhipster.config.liquibase.SpringLiquibaseUtil; import java.util.concurrent.Executor; import javax.sql.DataSource; import liquibase.integration.spring.SpringLiquibase; @@ -35,6 +33,8 @@ import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; import org.springframework.core.env.Profiles; +import tech.jhipster.config.JHipsterConstants; +import tech.jhipster.config.liquibase.SpringLiquibaseUtil; @Configuration public class LiquibaseConfiguration { diff --git a/src/main/java/io/github/jhipster/online/config/LocaleConfiguration.java b/src/main/java/io/github/jhipster/online/config/LocaleConfiguration.java index 16e25d7e..64aead25 100644 --- a/src/main/java/io/github/jhipster/online/config/LocaleConfiguration.java +++ b/src/main/java/io/github/jhipster/online/config/LocaleConfiguration.java @@ -18,13 +18,13 @@ */ package io.github.jhipster.online.config; -import io.github.jhipster.config.locale.AngularCookieLocaleResolver; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.LocaleResolver; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.i18n.LocaleChangeInterceptor; +import tech.jhipster.config.locale.AngularCookieLocaleResolver; @Configuration public class LocaleConfiguration implements WebMvcConfigurer { diff --git a/src/main/java/io/github/jhipster/online/config/LoggingAspectConfiguration.java b/src/main/java/io/github/jhipster/online/config/LoggingAspectConfiguration.java index d1079971..cc2bd65e 100644 --- a/src/main/java/io/github/jhipster/online/config/LoggingAspectConfiguration.java +++ b/src/main/java/io/github/jhipster/online/config/LoggingAspectConfiguration.java @@ -18,13 +18,13 @@ */ package io.github.jhipster.online.config; -import io.github.jhipster.config.JHipsterConstants; import io.github.jhipster.online.aop.logging.LoggingAspect; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.context.annotation.Profile; import org.springframework.core.env.Environment; +import tech.jhipster.config.JHipsterConstants; @Configuration @EnableAspectJAutoProxy diff --git a/src/main/java/io/github/jhipster/online/config/LoggingConfiguration.java b/src/main/java/io/github/jhipster/online/config/LoggingConfiguration.java index af572514..01b4ed33 100644 --- a/src/main/java/io/github/jhipster/online/config/LoggingConfiguration.java +++ b/src/main/java/io/github/jhipster/online/config/LoggingConfiguration.java @@ -18,17 +18,17 @@ */ package io.github.jhipster.online.config; -import static io.github.jhipster.config.logging.LoggingUtils.*; +import static tech.jhipster.config.logging.LoggingUtils.*; import ch.qos.logback.classic.LoggerContext; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import io.github.jhipster.config.JHipsterProperties; import java.util.HashMap; import java.util.Map; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; +import tech.jhipster.config.JHipsterProperties; /* * Configures the console and Logstash log appenders from the app properties @@ -62,8 +62,5 @@ public LoggingConfiguration( if (loggingProperties.isUseJsonFormat() || logstashProperties.isEnabled()) { addContextListener(context, customFields, loggingProperties); } - if (jHipsterProperties.getMetrics().getLogs().isEnabled()) { - setMetricsMarkerLogbackFilter(context, loggingProperties.isUseJsonFormat()); - } } } diff --git a/src/main/java/io/github/jhipster/online/config/WebConfigurer.java b/src/main/java/io/github/jhipster/online/config/WebConfigurer.java index be8497c1..2da8d8e9 100644 --- a/src/main/java/io/github/jhipster/online/config/WebConfigurer.java +++ b/src/main/java/io/github/jhipster/online/config/WebConfigurer.java @@ -20,34 +20,26 @@ import static java.net.URLDecoder.decode; -import io.github.jhipster.config.JHipsterConstants; -import io.github.jhipster.config.JHipsterProperties; -import io.github.jhipster.web.filter.CachingHttpHeadersFilter; import java.io.File; -import java.io.UnsupportedEncodingException; import java.nio.charset.StandardCharsets; import java.nio.file.Paths; import java.util.EnumSet; -import java.util.List; -import javax.servlet.DispatcherType; -import javax.servlet.FilterRegistration; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; +import javax.servlet.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.boot.web.server.MimeMappings; -import org.springframework.boot.web.server.WebServerFactory; -import org.springframework.boot.web.server.WebServerFactoryCustomizer; +import org.springframework.boot.web.server.*; import org.springframework.boot.web.servlet.ServletContextInitializer; import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; import org.springframework.core.env.Profiles; -import org.springframework.http.MediaType; +import org.springframework.util.CollectionUtils; import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.UrlBasedCorsConfigurationSource; import org.springframework.web.filter.CorsFilter; +import tech.jhipster.config.JHipsterConstants; +import tech.jhipster.config.JHipsterProperties; /** * Configuration of web application with Servlet 3.0 APIs. @@ -71,10 +63,6 @@ public void onStartup(ServletContext servletContext) throws ServletException { if (env.getActiveProfiles().length != 0) { log.info("Web application configuration, using profiles: {}", (Object[]) env.getActiveProfiles()); } - EnumSet disps = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.ASYNC); - if (env.acceptsProfiles(Profiles.of(JHipsterConstants.SPRING_PROFILE_PRODUCTION))) { - initCachingHttpHeadersFilter(servletContext, disps); - } log.info("Web application fully configured"); } @@ -83,23 +71,10 @@ public void onStartup(ServletContext servletContext) throws ServletException { */ @Override public void customize(WebServerFactory server) { - setMimeMappings(server); // When running in an IDE or with ./mvnw spring-boot:run, set location of the static web assets. setLocationForStaticAssets(server); } - private void setMimeMappings(WebServerFactory server) { - if (server instanceof ConfigurableServletWebServerFactory) { - MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); - // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711 - mappings.add("html", MediaType.TEXT_HTML_VALUE + ";charset=" + StandardCharsets.UTF_8.name().toLowerCase()); - // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64 - mappings.add("json", MediaType.TEXT_HTML_VALUE + ";charset=" + StandardCharsets.UTF_8.name().toLowerCase()); - ConfigurableServletWebServerFactory servletWebServer = (ConfigurableServletWebServerFactory) server; - servletWebServer.setMimeMappings(mappings); - } - } - private void setLocationForStaticAssets(WebServerFactory server) { if (server instanceof ConfigurableServletWebServerFactory) { ConfigurableServletWebServerFactory servletWebServer = (ConfigurableServletWebServerFactory) server; @@ -116,13 +91,7 @@ private void setLocationForStaticAssets(WebServerFactory server) { * Resolve path prefix to static resources. */ private String resolvePathPrefix() { - String fullExecutablePath; - try { - fullExecutablePath = decode(this.getClass().getResource("").getPath(), StandardCharsets.UTF_8.name()); - } catch (UnsupportedEncodingException e) { - /* try without decoding if this ever happens */ - fullExecutablePath = this.getClass().getResource("").getPath(); - } + String fullExecutablePath = decode(this.getClass().getResource("").getPath(), StandardCharsets.UTF_8); String rootPath = Paths.get(".").toUri().normalize().getPath(); String extractedPath = fullExecutablePath.replace(rootPath, ""); int extractionEndIndex = extractedPath.indexOf("target/"); @@ -132,31 +101,16 @@ private String resolvePathPrefix() { return extractedPath.substring(0, extractionEndIndex); } - /** - * Initializes the caching HTTP Headers Filter. - */ - private void initCachingHttpHeadersFilter(ServletContext servletContext, EnumSet disps) { - log.debug("Registering Caching HTTP Headers Filter"); - FilterRegistration.Dynamic cachingHttpHeadersFilter = servletContext.addFilter( - "cachingHttpHeadersFilter", - new CachingHttpHeadersFilter(jHipsterProperties) - ); - - cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/content/*"); - cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/app/*"); - cachingHttpHeadersFilter.setAsyncSupported(true); - } - @Bean public CorsFilter corsFilter() { UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); CorsConfiguration config = jHipsterProperties.getCors(); - List allowedOrigins = config.getAllowedOrigins(); - if (allowedOrigins != null && !allowedOrigins.isEmpty()) { + if (!CollectionUtils.isEmpty(config.getAllowedOrigins()) || !CollectionUtils.isEmpty(config.getAllowedOriginPatterns())) { log.debug("Registering CORS filter"); source.registerCorsConfiguration("/api/**", config); source.registerCorsConfiguration("/management/**", config); - source.registerCorsConfiguration("/v2/api-docs", config); + source.registerCorsConfiguration("/v3/api-docs", config); + source.registerCorsConfiguration("/swagger-ui/**", config); } return new CorsFilter(source); } diff --git a/src/main/java/io/github/jhipster/online/domain/SubGenEvent.java b/src/main/java/io/github/jhipster/online/domain/SubGenEvent.java index 9fdd8340..5d5e5e10 100644 --- a/src/main/java/io/github/jhipster/online/domain/SubGenEvent.java +++ b/src/main/java/io/github/jhipster/online/domain/SubGenEvent.java @@ -23,6 +23,7 @@ import io.github.jhipster.online.domain.interfaces.CompleteDate; import java.io.Serializable; import java.time.Instant; +import java.util.Date; import java.util.Objects; import javax.persistence.*; import org.hibernate.annotations.Cache; diff --git a/src/main/java/io/github/jhipster/online/security/jwt/TokenProvider.java b/src/main/java/io/github/jhipster/online/security/jwt/TokenProvider.java index 6e79b454..830a41dd 100644 --- a/src/main/java/io/github/jhipster/online/security/jwt/TokenProvider.java +++ b/src/main/java/io/github/jhipster/online/security/jwt/TokenProvider.java @@ -18,7 +18,6 @@ */ package io.github.jhipster.online.security.jwt; -import io.github.jhipster.config.JHipsterProperties; import io.jsonwebtoken.*; import io.jsonwebtoken.io.Decoders; import io.jsonwebtoken.security.Keys; @@ -37,6 +36,7 @@ import org.springframework.security.core.userdetails.User; import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; +import tech.jhipster.config.JHipsterProperties; @Component public class TokenProvider { diff --git a/src/main/java/io/github/jhipster/online/service/AuditEventService.java b/src/main/java/io/github/jhipster/online/service/AuditEventService.java index 4bab0b2a..bc02e216 100644 --- a/src/main/java/io/github/jhipster/online/service/AuditEventService.java +++ b/src/main/java/io/github/jhipster/online/service/AuditEventService.java @@ -19,7 +19,6 @@ package io.github.jhipster.online.service; -import io.github.jhipster.config.JHipsterProperties; import io.github.jhipster.online.config.audit.AuditEventConverter; import io.github.jhipster.online.repository.PersistenceAuditEventRepository; import java.time.Instant; @@ -33,6 +32,7 @@ import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import tech.jhipster.config.JHipsterProperties; /** * Service for managing audit events. diff --git a/src/main/java/io/github/jhipster/online/service/GitlabService.java b/src/main/java/io/github/jhipster/online/service/GitlabService.java index e1e3ef2b..9e67495d 100644 --- a/src/main/java/io/github/jhipster/online/service/GitlabService.java +++ b/src/main/java/io/github/jhipster/online/service/GitlabService.java @@ -201,7 +201,7 @@ public User getSyncedUserFromGitProvider(User user) throws IOException { List projectList = gitlab.getGroupProjects(group); List projects = projectList.stream().map(GitlabProject::getName).collect(Collectors.toList()); company.setGitProjects(projects); - } catch (IOException e) { + } catch (Exception e) { log.error("Could not sync GitLab repositories for user `{}`: {}", user.getLogin(), e.getMessage()); } } diff --git a/src/main/java/io/github/jhipster/online/service/MailService.java b/src/main/java/io/github/jhipster/online/service/MailService.java index 5d8ab9d0..f2966518 100644 --- a/src/main/java/io/github/jhipster/online/service/MailService.java +++ b/src/main/java/io/github/jhipster/online/service/MailService.java @@ -19,7 +19,6 @@ package io.github.jhipster.online.service; -import io.github.jhipster.config.JHipsterProperties; import io.github.jhipster.online.domain.User; import java.nio.charset.StandardCharsets; import java.util.Locale; @@ -35,6 +34,7 @@ import org.springframework.stereotype.Service; import org.thymeleaf.context.Context; import org.thymeleaf.spring5.SpringTemplateEngine; +import tech.jhipster.config.JHipsterProperties; /** * Service for sending emails. diff --git a/src/main/java/io/github/jhipster/online/service/UserService.java b/src/main/java/io/github/jhipster/online/service/UserService.java index ffac075b..3fcd6980 100644 --- a/src/main/java/io/github/jhipster/online/service/UserService.java +++ b/src/main/java/io/github/jhipster/online/service/UserService.java @@ -19,7 +19,6 @@ package io.github.jhipster.online.service; -import io.github.jhipster.config.JHipsterProperties; import io.github.jhipster.online.config.CacheConfiguration; import io.github.jhipster.online.config.Constants; import io.github.jhipster.online.domain.Authority; @@ -33,7 +32,6 @@ import io.github.jhipster.online.security.AuthoritiesConstants; import io.github.jhipster.online.security.SecurityUtils; import io.github.jhipster.online.service.dto.UserDTO; -import io.github.jhipster.security.RandomUtil; import java.time.Instant; import java.time.temporal.ChronoUnit; import java.util.*; @@ -49,6 +47,8 @@ import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import tech.jhipster.config.JHipsterProperties; +import tech.jhipster.security.RandomUtil; /** * Service class for managing users. diff --git a/src/main/java/io/github/jhipster/online/web/rest/AuditResource.java b/src/main/java/io/github/jhipster/online/web/rest/AuditResource.java index 96dae5a4..4f1c2ebe 100644 --- a/src/main/java/io/github/jhipster/online/web/rest/AuditResource.java +++ b/src/main/java/io/github/jhipster/online/web/rest/AuditResource.java @@ -20,8 +20,6 @@ package io.github.jhipster.online.web.rest; import io.github.jhipster.online.service.AuditEventService; -import io.github.jhipster.web.util.PaginationUtil; -import io.github.jhipster.web.util.ResponseUtil; import java.time.Instant; import java.time.LocalDate; import java.time.ZoneId; @@ -34,6 +32,8 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.support.ServletUriComponentsBuilder; +import tech.jhipster.web.util.PaginationUtil; +import tech.jhipster.web.util.ResponseUtil; /** * REST controller for getting the {@link AuditEvent}s. diff --git a/src/main/java/io/github/jhipster/online/web/rest/EntityStatsResource.java b/src/main/java/io/github/jhipster/online/web/rest/EntityStatsResource.java index 5548192e..8d8f3120 100644 --- a/src/main/java/io/github/jhipster/online/web/rest/EntityStatsResource.java +++ b/src/main/java/io/github/jhipster/online/web/rest/EntityStatsResource.java @@ -24,8 +24,6 @@ import io.github.jhipster.online.service.EntityStatsService; import io.github.jhipster.online.service.dto.EntityStatsDTO; import io.github.jhipster.online.web.rest.errors.BadRequestAlertException; -import io.github.jhipster.web.util.HeaderUtil; -import io.github.jhipster.web.util.ResponseUtil; import java.net.URI; import java.net.URISyntaxException; import java.util.List; @@ -36,6 +34,8 @@ import org.springframework.http.ResponseEntity; import org.springframework.security.access.annotation.Secured; import org.springframework.web.bind.annotation.*; +import tech.jhipster.web.util.HeaderUtil; +import tech.jhipster.web.util.ResponseUtil; /** * REST controller for managing EntityStats. diff --git a/src/main/java/io/github/jhipster/online/web/rest/GeneratorIdentityResource.java b/src/main/java/io/github/jhipster/online/web/rest/GeneratorIdentityResource.java index 6cbddaa3..cf97db50 100644 --- a/src/main/java/io/github/jhipster/online/web/rest/GeneratorIdentityResource.java +++ b/src/main/java/io/github/jhipster/online/web/rest/GeneratorIdentityResource.java @@ -24,8 +24,6 @@ import io.github.jhipster.online.service.UserService; import io.github.jhipster.online.service.dto.GeneratorIdentityDTO; import io.github.jhipster.online.web.rest.errors.BadRequestAlertException; -import io.github.jhipster.web.util.HeaderUtil; -import io.github.jhipster.web.util.ResponseUtil; import java.net.URI; import java.net.URISyntaxException; import java.util.List; @@ -35,6 +33,8 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import tech.jhipster.web.util.HeaderUtil; +import tech.jhipster.web.util.ResponseUtil; /** * REST controller for managing GeneratorIdentity. diff --git a/src/main/java/io/github/jhipster/online/web/rest/JdlMetadataResource.java b/src/main/java/io/github/jhipster/online/web/rest/JdlMetadataResource.java index d4b67c4b..0deafb5b 100644 --- a/src/main/java/io/github/jhipster/online/web/rest/JdlMetadataResource.java +++ b/src/main/java/io/github/jhipster/online/web/rest/JdlMetadataResource.java @@ -24,8 +24,6 @@ import io.github.jhipster.online.service.JdlMetadataService; import io.github.jhipster.online.service.UserService; import io.github.jhipster.online.service.dto.JdlMetadataDTO; -import io.github.jhipster.web.util.HeaderUtil; -import io.github.jhipster.web.util.ResponseUtil; import java.util.List; import java.util.Optional; import javax.validation.Valid; @@ -36,6 +34,8 @@ import org.springframework.http.ResponseEntity; import org.springframework.security.access.annotation.Secured; import org.springframework.web.bind.annotation.*; +import tech.jhipster.web.util.HeaderUtil; +import tech.jhipster.web.util.ResponseUtil; /** * REST controller for managing JdlMetadata. diff --git a/src/main/java/io/github/jhipster/online/web/rest/SubGenEventResource.java b/src/main/java/io/github/jhipster/online/web/rest/SubGenEventResource.java index 495c21a3..a7e19bd5 100644 --- a/src/main/java/io/github/jhipster/online/web/rest/SubGenEventResource.java +++ b/src/main/java/io/github/jhipster/online/web/rest/SubGenEventResource.java @@ -24,8 +24,6 @@ import io.github.jhipster.online.service.SubGenEventService; import io.github.jhipster.online.service.dto.SubGenEventDTO; import io.github.jhipster.online.web.rest.errors.BadRequestAlertException; -import io.github.jhipster.web.util.HeaderUtil; -import io.github.jhipster.web.util.ResponseUtil; import java.net.URI; import java.net.URISyntaxException; import java.util.List; @@ -36,6 +34,8 @@ import org.springframework.http.ResponseEntity; import org.springframework.security.access.annotation.Secured; import org.springframework.web.bind.annotation.*; +import tech.jhipster.web.util.HeaderUtil; +import tech.jhipster.web.util.ResponseUtil; /** * REST controller for managing SubGenEvent. diff --git a/src/main/java/io/github/jhipster/online/web/rest/UserResource.java b/src/main/java/io/github/jhipster/online/web/rest/UserResource.java index 1bc77e83..d047d625 100644 --- a/src/main/java/io/github/jhipster/online/web/rest/UserResource.java +++ b/src/main/java/io/github/jhipster/online/web/rest/UserResource.java @@ -29,9 +29,6 @@ import io.github.jhipster.online.web.rest.errors.BadRequestAlertException; import io.github.jhipster.online.web.rest.errors.EmailAlreadyUsedException; import io.github.jhipster.online.web.rest.errors.LoginAlreadyUsedException; -import io.github.jhipster.web.util.HeaderUtil; -import io.github.jhipster.web.util.PaginationUtil; -import io.github.jhipster.web.util.ResponseUtil; import java.net.URI; import java.net.URISyntaxException; import java.util.List; @@ -48,6 +45,9 @@ import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.support.ServletUriComponentsBuilder; +import tech.jhipster.web.util.HeaderUtil; +import tech.jhipster.web.util.PaginationUtil; +import tech.jhipster.web.util.ResponseUtil; /** * REST controller for managing users. diff --git a/src/main/java/io/github/jhipster/online/web/rest/YoRCResource.java b/src/main/java/io/github/jhipster/online/web/rest/YoRCResource.java index d4dcd9ee..34a0b417 100644 --- a/src/main/java/io/github/jhipster/online/web/rest/YoRCResource.java +++ b/src/main/java/io/github/jhipster/online/web/rest/YoRCResource.java @@ -24,8 +24,6 @@ import io.github.jhipster.online.service.YoRCService; import io.github.jhipster.online.service.dto.YoRCDTO; import io.github.jhipster.online.web.rest.errors.BadRequestAlertException; -import io.github.jhipster.web.util.HeaderUtil; -import io.github.jhipster.web.util.ResponseUtil; import java.net.URI; import java.net.URISyntaxException; import java.util.List; @@ -36,6 +34,8 @@ import org.springframework.http.ResponseEntity; import org.springframework.security.access.annotation.Secured; import org.springframework.web.bind.annotation.*; +import tech.jhipster.web.util.HeaderUtil; +import tech.jhipster.web.util.ResponseUtil; /** * REST controller for managing YoRC. diff --git a/src/main/java/io/github/jhipster/online/web/rest/errors/ExceptionTranslator.java b/src/main/java/io/github/jhipster/online/web/rest/errors/ExceptionTranslator.java index d9b42dc2..f661bacd 100644 --- a/src/main/java/io/github/jhipster/online/web/rest/errors/ExceptionTranslator.java +++ b/src/main/java/io/github/jhipster/online/web/rest/errors/ExceptionTranslator.java @@ -19,7 +19,6 @@ package io.github.jhipster.online.web.rest.errors; -import io.github.jhipster.web.util.HeaderUtil; import java.util.List; import java.util.stream.Collectors; import javax.annotation.Nonnull; @@ -40,6 +39,7 @@ import org.zalando.problem.spring.web.advice.ProblemHandling; import org.zalando.problem.spring.web.advice.security.SecurityAdviceTrait; import org.zalando.problem.violations.ConstraintViolationProblem; +import tech.jhipster.web.util.HeaderUtil; /** * Controller advice to translate the server side exceptions to client-friendly json structures. diff --git a/src/main/resources/config/application-dev.yml b/src/main/resources/config/application-dev.yml index 469130ca..a6878a31 100644 --- a/src/main/resources/config/application-dev.yml +++ b/src/main/resources/config/application-dev.yml @@ -20,12 +20,6 @@ logging: io.github.jhipster.online: DEBUG spring: - profiles: - active: dev - include: - - swagger - # Uncomment to activate TLS for the dev profile - #- tls devtools: restart: enabled: true @@ -56,7 +50,7 @@ spring: hibernate.cache.use_second_level_cache: true hibernate.cache.use_query_cache: false hibernate.generate_statistics: false - # hibernate.cache.region.factory_class: io.github.jhipster.config.jcache.NoDefaultJCacheRegionFactory + # hibernate.cache.region.factory_class: tech.jhipster.config.jcache.NoDefaultJCacheRegionFactory liquibase: contexts: dev mail: @@ -103,10 +97,6 @@ jhipster: enabled: true from: jhipster-online@jhipster.tech base-url: http://127.0.0.1:8080 - metrics: - logs: # Reports metrics in the logs - enabled: false - report-frequency: 60 # in seconds logging: use-json-format: false # By default, logs are not in Json format logstash: # Forward logs to logstash over a socket, used by LoggingConfiguration diff --git a/src/main/resources/config/application-prod.yml b/src/main/resources/config/application-prod.yml index fe25e0ce..a0d110b0 100644 --- a/src/main/resources/config/application-prod.yml +++ b/src/main/resources/config/application-prod.yml @@ -78,12 +78,12 @@ spring: # ciphers: TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 ,TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 ,TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 ,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_256_CBC_SHA256,TLS_DHE_RSA_WITH_AES_256_CBC_SHA,TLS_RSA_WITH_AES_128_GCM_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_CBC_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA,TLS_RSA_WITH_CAMELLIA_256_CBC_SHA,TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA,TLS_RSA_WITH_CAMELLIA_128_CBC_SHA # =================================================================== server: - use-forward-headers: true port: 8080 compression: enabled: true mime-types: text/html,text/xml,text/plain,text/css, application/javascript, application/json min-response-size: 1024 + forward-headers-strategy: framework # =================================================================== # JHipster specific properties @@ -114,10 +114,6 @@ jhipster: mail: # specific JHipster mail property, for standard properties see MailProperties from: jhipster-online@jhipster.tech base-url: http://my-server-url-to-change # Modify according to your server's URL - metrics: - logs: # Reports metrics in the logs - enabled: false - report-frequency: 60 # in seconds logging: use-json-format: false # By default, logs are not in Json format logstash: # Forward logs to logstash over a socket, used by LoggingConfiguration diff --git a/src/main/resources/config/application.yml b/src/main/resources/config/application.yml index 2d1eac83..ecc9de39 100644 --- a/src/main/resources/config/application.yml +++ b/src/main/resources/config/application.yml @@ -65,6 +65,12 @@ spring: # Otherwise, it will be filled in by maven when building the JAR file # Either way, it can be overridden by `--spring.profiles.active` value passed in the commandline or `-Dspring.profiles.active` set in `JAVA_OPTS` active: #spring.profiles.active# + group: + dev: + - dev + - api-docs + # Uncomment to activate TLS for the dev profile + #- tls jmx: enabled: false data: @@ -96,8 +102,8 @@ spring: main: allow-bean-definition-overriding: true mvc: - favicon: - enabled: false + pathmatch: + matching-strategy: ant_path_matcher task: execution: thread-name-prefix: jhonline-task- @@ -146,17 +152,6 @@ jhipster: # max-age: 1800 mail: from: no-reply@jhipster.tech - swagger: - default-include-pattern: /api/.* - title: jhonline API - description: jhonline API documentation - version: 0.0.1 - terms-of-service-url: - contact-name: - contact-url: - contact-email: - license: - license-url: # =================================================================== # Application specific properties # Add your own application properties here, see the ApplicationProperties class diff --git a/src/main/resources/config/liquibase/changelog/20230216080000_update_column_types.xml b/src/main/resources/config/liquibase/changelog/20230216080000_update_column_types.xml new file mode 100644 index 00000000..98e5d477 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20230216080000_update_column_types.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/master.xml b/src/main/resources/config/liquibase/master.xml index a9d4fffe..3d0a36e6 100644 --- a/src/main/resources/config/liquibase/master.xml +++ b/src/main/resources/config/liquibase/master.xml @@ -24,4 +24,5 @@ + diff --git a/src/test/java/io/github/jhipster/online/config/AsyncConfiguration.java b/src/test/java/io/github/jhipster/online/config/AsyncConfiguration.java index 6b3e8b0d..b772ef7b 100644 --- a/src/test/java/io/github/jhipster/online/config/AsyncConfiguration.java +++ b/src/test/java/io/github/jhipster/online/config/AsyncConfiguration.java @@ -18,7 +18,6 @@ */ package io.github.jhipster.online.config; -import io.github.jhipster.config.JHipsterProperties; import java.util.concurrent.Executor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -28,6 +27,7 @@ import org.springframework.scheduling.annotation.AsyncConfigurer; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableScheduling; +import tech.jhipster.config.JHipsterProperties; @Configuration @EnableAsync diff --git a/src/test/java/io/github/jhipster/online/config/WebConfigurerTest.java b/src/test/java/io/github/jhipster/online/config/WebConfigurerTest.java index 3f341649..3f02f834 100644 --- a/src/test/java/io/github/jhipster/online/config/WebConfigurerTest.java +++ b/src/test/java/io/github/jhipster/online/config/WebConfigurerTest.java @@ -19,6 +19,7 @@ package io.github.jhipster.online.config; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatCode; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.*; @@ -27,13 +28,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import io.github.jhipster.config.JHipsterConstants; -import io.github.jhipster.config.JHipsterProperties; -import io.github.jhipster.web.filter.CachingHttpHeadersFilter; import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; +import java.util.*; import javax.servlet.*; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -43,6 +39,8 @@ import org.springframework.mock.web.MockServletContext; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import tech.jhipster.config.JHipsterConstants; +import tech.jhipster.config.JHipsterProperties; /** * Unit tests for the {@link WebConfigurer} class. @@ -70,37 +68,21 @@ public void setup() { } @Test - void testStartUpProdServletContext() throws ServletException { - env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION); - webConfigurer.onStartup(servletContext); - - verify(servletContext).addFilter(eq("cachingHttpHeadersFilter"), any(CachingHttpHeadersFilter.class)); - } - - @Test - void testStartUpDevServletContext() throws ServletException { - env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT); - webConfigurer.onStartup(servletContext); - - verify(servletContext, never()).addFilter(eq("cachingHttpHeadersFilter"), any(CachingHttpHeadersFilter.class)); - } - - @Test - void testCustomizeServletContainer() { + void shouldCustomizeServletContainer() { env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION); UndertowServletWebServerFactory container = new UndertowServletWebServerFactory(); webConfigurer.customize(container); assertThat(container.getMimeMappings().get("abs")).isEqualTo("audio/x-mpeg"); - assertThat(container.getMimeMappings().get("html")).isEqualTo("text/html;charset=utf-8"); - assertThat(container.getMimeMappings().get("json")).isEqualTo("text/html;charset=utf-8"); + assertThat(container.getMimeMappings().get("html")).isEqualTo("text/html"); + assertThat(container.getMimeMappings().get("json")).isEqualTo("application/json"); if (container.getDocumentRoot() != null) { assertThat(container.getDocumentRoot()).isEqualTo(new File("target/classes/static/")); } } @Test - void testCorsFilterOnApiPath() throws Exception { - props.getCors().setAllowedOrigins(Collections.singletonList("*")); + void shouldCorsFilterOnApiPath() throws Exception { + props.getCors().setAllowedOrigins(Collections.singletonList("other.domain.com")); props.getCors().setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE")); props.getCors().setAllowedHeaders(Collections.singletonList("*")); props.getCors().setMaxAge(1800L); @@ -128,7 +110,7 @@ void testCorsFilterOnApiPath() throws Exception { } @Test - void testCorsFilterOnOtherPath() throws Exception { + void shouldCorsFilterOnOtherPath() throws Exception { props.getCors().setAllowedOrigins(Collections.singletonList("*")); props.getCors().setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE")); props.getCors().setAllowedHeaders(Collections.singletonList("*")); @@ -144,7 +126,7 @@ void testCorsFilterOnOtherPath() throws Exception { } @Test - void testCorsFilterDeactivated() throws Exception { + void shouldCorsFilterDeactivatedForNullAllowedOrigins() throws Exception { props.getCors().setAllowedOrigins(null); MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new WebConfigurerTestController()).addFilters(webConfigurer.corsFilter()).build(); @@ -156,7 +138,7 @@ void testCorsFilterDeactivated() throws Exception { } @Test - void testCorsFilterDeactivated2() throws Exception { + void shouldCorsFilterDeactivatedForEmptyAllowedOrigins() throws Exception { props.getCors().setAllowedOrigins(new ArrayList<>()); MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new WebConfigurerTestController()).addFilters(webConfigurer.corsFilter()).build(); diff --git a/src/test/java/io/github/jhipster/online/security/jwt/JWTFilterTest.java b/src/test/java/io/github/jhipster/online/security/jwt/JWTFilterTest.java index 41b92568..939decb9 100644 --- a/src/test/java/io/github/jhipster/online/security/jwt/JWTFilterTest.java +++ b/src/test/java/io/github/jhipster/online/security/jwt/JWTFilterTest.java @@ -20,7 +20,6 @@ import static org.assertj.core.api.Assertions.assertThat; -import io.github.jhipster.config.JHipsterProperties; import io.github.jhipster.online.security.AuthoritiesConstants; import io.jsonwebtoken.io.Decoders; import io.jsonwebtoken.security.Keys; @@ -35,6 +34,7 @@ import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.test.util.ReflectionTestUtils; +import tech.jhipster.config.JHipsterProperties; class JWTFilterTest { diff --git a/src/test/java/io/github/jhipster/online/security/jwt/TokenProviderTest.java b/src/test/java/io/github/jhipster/online/security/jwt/TokenProviderTest.java index 12a64fd6..03c38996 100644 --- a/src/test/java/io/github/jhipster/online/security/jwt/TokenProviderTest.java +++ b/src/test/java/io/github/jhipster/online/security/jwt/TokenProviderTest.java @@ -20,7 +20,6 @@ import static org.assertj.core.api.Assertions.assertThat; -import io.github.jhipster.config.JHipsterProperties; import io.github.jhipster.online.security.AuthoritiesConstants; import io.jsonwebtoken.Jwts; import io.jsonwebtoken.SignatureAlgorithm; @@ -37,6 +36,7 @@ import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.test.util.ReflectionTestUtils; +import tech.jhipster.config.JHipsterProperties; class TokenProviderTest { diff --git a/src/test/java/io/github/jhipster/online/service/AuditEventServiceIT.java b/src/test/java/io/github/jhipster/online/service/AuditEventServiceIT.java index 448e493c..0bbf5623 100644 --- a/src/test/java/io/github/jhipster/online/service/AuditEventServiceIT.java +++ b/src/test/java/io/github/jhipster/online/service/AuditEventServiceIT.java @@ -20,7 +20,6 @@ import static org.assertj.core.api.Assertions.assertThat; -import io.github.jhipster.config.JHipsterProperties; import io.github.jhipster.online.JhonlineApp; import io.github.jhipster.online.domain.PersistentAuditEvent; import io.github.jhipster.online.repository.PersistenceAuditEventRepository; @@ -31,6 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.transaction.annotation.Transactional; +import tech.jhipster.config.JHipsterProperties; /** * Integration tests for {@link AuditEventService}. diff --git a/src/test/java/io/github/jhipster/online/service/JHipsterServiceTest.java b/src/test/java/io/github/jhipster/online/service/JHipsterServiceTest.java index 0769d25e..4c43c094 100644 --- a/src/test/java/io/github/jhipster/online/service/JHipsterServiceTest.java +++ b/src/test/java/io/github/jhipster/online/service/JHipsterServiceTest.java @@ -74,8 +74,8 @@ void shouldRunProcess(@TempDir Path tempDir) throws IOException { verify(logsService).addLog(generationId, "Installing the JHipster version used by the project"); verify(taskExecutor).execute(any(Runnable.class)); - verify(logsService).addLog(eq(generationId), startsWith("up to date in")); - verify(logsService).addLog(generationId, "found 0 vulnerabilities"); + verify(logsService).addLog(eq(generationId), startsWith("up to date")); + //verify(logsService).addLog(generationId, "found 0 vulnerabilities"); } @Test diff --git a/src/test/java/io/github/jhipster/online/service/MailServiceIT.java b/src/test/java/io/github/jhipster/online/service/MailServiceIT.java index a546b483..8f6d6dbb 100644 --- a/src/test/java/io/github/jhipster/online/service/MailServiceIT.java +++ b/src/test/java/io/github/jhipster/online/service/MailServiceIT.java @@ -23,7 +23,6 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.*; -import io.github.jhipster.config.JHipsterProperties; import io.github.jhipster.online.JhonlineApp; import io.github.jhipster.online.config.Constants; import io.github.jhipster.online.domain.User; @@ -54,6 +53,7 @@ import org.springframework.mail.MailSendException; import org.springframework.mail.javamail.JavaMailSenderImpl; import org.thymeleaf.spring5.SpringTemplateEngine; +import tech.jhipster.config.JHipsterProperties; /** * Integration tests for {@link MailService}. diff --git a/src/test/java/io/github/jhipster/online/service/UserServiceIT.java b/src/test/java/io/github/jhipster/online/service/UserServiceIT.java index 8ebf5d1f..2b9b6cc1 100644 --- a/src/test/java/io/github/jhipster/online/service/UserServiceIT.java +++ b/src/test/java/io/github/jhipster/online/service/UserServiceIT.java @@ -26,7 +26,6 @@ import io.github.jhipster.online.domain.User; import io.github.jhipster.online.repository.UserRepository; import io.github.jhipster.online.service.dto.UserDTO; -import io.github.jhipster.security.RandomUtil; import java.time.Instant; import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; @@ -43,6 +42,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.transaction.annotation.Transactional; +import tech.jhipster.security.RandomUtil; /** * Integration tests for {@link UserService}. diff --git a/src/test/java/io/github/jhipster/online/service/yorc/YoRCServiceChoicesIntTest.java b/src/test/java/io/github/jhipster/online/service/yorc/YoRCServiceChoicesIntTest.java index a691594d..76d7cccb 100644 --- a/src/test/java/io/github/jhipster/online/service/yorc/YoRCServiceChoicesIntTest.java +++ b/src/test/java/io/github/jhipster/online/service/yorc/YoRCServiceChoicesIntTest.java @@ -162,15 +162,15 @@ void assertThatDailyProportionsAreCorrect() { .hasSize(5) .extracting(TemporalDistributionDTO::getDate) .containsExactly( - Instant.parse("2018-09-27T00:00:00Z"), Instant.parse("2019-01-01T00:00:00Z"), + Instant.parse("2018-09-27T00:00:00Z"), Instant.parse("2019-01-02T00:00:00Z"), Instant.parse("2018-09-13T00:00:00Z"), Instant.parse("2018-09-14T00:00:00Z") ); - Map fst = result.get(0).getValues(); // 27 sept 2018 - Map snd = result.get(1).getValues(); // 01 jan 2019 + Map snd = result.get(0).getValues(); // 01 jan 2019 + Map fst = result.get(1).getValues(); // 27 sept 2018 Map thr = result.get(2).getValues(); // 02 jan 2019 Map fou = result.get(3).getValues(); // 13 sept 2018 Map fiv = result.get(4).getValues(); // 14 sept 2018 diff --git a/src/test/java/io/github/jhipster/online/web/rest/EntityStatsResourceIntTest.java b/src/test/java/io/github/jhipster/online/web/rest/EntityStatsResourceIntTest.java index 2ec0ea94..3fc0abac 100644 --- a/src/test/java/io/github/jhipster/online/web/rest/EntityStatsResourceIntTest.java +++ b/src/test/java/io/github/jhipster/online/web/rest/EntityStatsResourceIntTest.java @@ -91,7 +91,7 @@ class EntityStatsResourceIntTest { private static final Boolean DEFAULT_FLUENT_METHODS = false; private static final Boolean UPDATED_FLUENT_METHODS = true; - private static final Instant DEFAULT_DATE = Instant.ofEpochMilli(0L); + private static final Instant DEFAULT_DATE = Instant.ofEpochMilli(1000L); private static final Instant UPDATED_DATE = Instant.now().truncatedTo(ChronoUnit.MILLIS); @Autowired diff --git a/src/test/java/io/github/jhipster/online/web/rest/SubGenEventResourceIntTest.java b/src/test/java/io/github/jhipster/online/web/rest/SubGenEventResourceIntTest.java index dfe180c5..7670215f 100644 --- a/src/test/java/io/github/jhipster/online/web/rest/SubGenEventResourceIntTest.java +++ b/src/test/java/io/github/jhipster/online/web/rest/SubGenEventResourceIntTest.java @@ -82,7 +82,7 @@ class SubGenEventResourceIntTest { private static final String DEFAULT_EVENT = "AAAAAAAAAA"; private static final String UPDATED_EVENT = "BBBBBBBBBB"; - private static final Instant DEFAULT_DATE = Instant.ofEpochMilli(0L); + private static final Instant DEFAULT_DATE = Instant.ofEpochMilli(1000L); private static final Instant UPDATED_DATE = Instant.now().truncatedTo(ChronoUnit.MILLIS); @Autowired diff --git a/src/test/java/io/github/jhipster/online/web/rest/YoRCResourceIntTest.java b/src/test/java/io/github/jhipster/online/web/rest/YoRCResourceIntTest.java index 5cde8772..4083549a 100644 --- a/src/test/java/io/github/jhipster/online/web/rest/YoRCResourceIntTest.java +++ b/src/test/java/io/github/jhipster/online/web/rest/YoRCResourceIntTest.java @@ -61,7 +61,7 @@ class YoRCResourceIntTest { private static final String DEFAULT_JHIPSTER_VERSION = "AAAAAAAAAA"; - private static final Instant DEFAULT_CREATION_DATE = Instant.ofEpochMilli(0L); + private static final Instant DEFAULT_CREATION_DATE = Instant.ofEpochMilli(1000L); private static final String DEFAULT_GIT_PROVIDER = "AAAAAAAAAA"; diff --git a/src/test/resources/config/application.yml b/src/test/resources/config/application.yml index 61de7fd3..b5db277b 100644 --- a/src/test/resources/config/application.yml +++ b/src/test/resources/config/application.yml @@ -18,17 +18,22 @@ spring: name: jhonline datasource: type: com.zaxxer.hikari.HikariDataSource - url: jdbc:h2:mem:jhonline;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE - name: - username: + url: jdbc:tc:mysql:8://localhost:3306/jhipster-online?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true + username: root password: hikari: + poolName: Hikari auto-commit: false + data-source-properties: + cachePrepStmts: true + prepStmtCacheSize: 250 + prepStmtCacheSqlLimit: 2048 + useServerPrepStmts: true jackson: serialization: write-durations-as-timestamps: false jpa: - database-platform: io.github.jhipster.domain.util.FixedH2Dialect + database-platform: org.hibernate.dialect.MySQL8Dialect open-in-view: false show-sql: false hibernate: @@ -53,8 +58,8 @@ spring: messages: basename: i18n/messages mvc: - favicon: - enabled: false + pathmatch: + matching-strategy: ant_path_matcher task: execution: thread-name-prefix: jhonline-task- @@ -100,10 +105,6 @@ jhipster: base64-secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx # Token is valid 24 hours token-validity-in-seconds: 86400 - metrics: - logs: # Reports metrics in the logs - enabled: true - report-frequency: 60 # in seconds # =================================================================== # Application specific properties diff --git a/src/test/resources/logback.xml b/src/test/resources/logback.xml index 86978cb7..e7720def 100644 --- a/src/test/resources/logback.xml +++ b/src/test/resources/logback.xml @@ -35,7 +35,8 @@ - + + WARN