Compare commits

...

2 Commits

Author SHA1 Message Date
Jesse Brault
b714593194 Upgrade to Spring Boot 4.0.1. 2025-12-24 12:20:40 -06:00
Jesse Brault
91168d69cb Upgrade to Spring Boot 3.5.9. 2025-12-24 11:48:47 -06:00
9 changed files with 38 additions and 41 deletions

View File

@ -1,7 +1,7 @@
plugins { plugins {
id 'java' id 'java'
id 'org.springframework.boot' version '3.4.0' id 'org.springframework.boot' version '4.0.1'
id 'io.spring.dependency-management' version '1.1.6' id 'io.spring.dependency-management' version '1.1.7'
} }
group = 'app.mealsmadeeasy' group = 'app.mealsmadeeasy'
@ -47,24 +47,26 @@ dependencies {
// From Spring Initalizr // From Spring Initalizr
implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security' implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-webmvc'
implementation 'org.springframework.boot:spring-boot-starter-jackson'
runtimeOnly 'com.mysql:mysql-connector-j' runtimeOnly 'com.mysql:mysql-connector-j'
testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.boot:spring-boot-starter-webmvc-test'
testImplementation 'org.springframework.boot:spring-boot-starter-jackson-test'
testImplementation 'org.springframework.security:spring-security-test' testImplementation 'org.springframework.security:spring-security-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher' testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
// Custom // Custom
implementation 'io.jsonwebtoken:jjwt-api:0.12.6' implementation 'io.jsonwebtoken:jjwt-api:0.13.0'
implementation 'io.jsonwebtoken:jjwt-jackson:0.12.6' implementation 'io.jsonwebtoken:jjwt-jackson:0.13.0'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.12.6' runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.13.0'
implementation 'org.commonmark:commonmark:0.24.0' implementation 'org.commonmark:commonmark:0.27.0'
implementation 'org.jsoup:jsoup:1.18.3' implementation 'org.jsoup:jsoup:1.21.2'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.18.2' implementation 'tools.jackson.dataformat:jackson-dataformat-yaml:3.0.3'
implementation 'io.minio:minio:8.5.14' implementation 'io.minio:minio:8.6.0'
compileOnly 'org.jetbrains:annotations:26.0.1' compileOnly 'org.jetbrains:annotations:26.0.2-1'
// https://mvnrepository.com/artifact/com.twelvemonkeys.imageio/imageio-webp // https://mvnrepository.com/artifact/com.twelvemonkeys.imageio/imageio-webp
runtimeOnly 'com.twelvemonkeys.imageio:imageio-webp:3.12.0' runtimeOnly 'com.twelvemonkeys.imageio:imageio-webp:3.12.0'
@ -75,13 +77,11 @@ dependencies {
// https://mvnrepository.com/artifact/org.apache.xmlgraphics/batik-all // https://mvnrepository.com/artifact/org.apache.xmlgraphics/batik-all
runtimeOnly 'org.apache.xmlgraphics:batik-all:1.19' runtimeOnly 'org.apache.xmlgraphics:batik-all:1.19'
compileOnly 'org.jetbrains:annotations:24.1.0'
// Custom testing // Custom testing
testRuntimeOnly 'com.h2database:h2' testRuntimeOnly 'com.h2database:h2'
testImplementation 'org.testcontainers:testcontainers:1.20.4' testImplementation 'org.testcontainers:testcontainers:1.21.4'
testImplementation 'org.testcontainers:junit-jupiter:1.20.4' testImplementation 'org.testcontainers:junit-jupiter:1.21.4'
testImplementation "org.testcontainers:minio:1.20.4" testImplementation "org.testcontainers:minio:1.21.4"
testFixturesImplementation 'org.hamcrest:hamcrest:3.0' testFixturesImplementation 'org.hamcrest:hamcrest:3.0'
} }

View File

@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME

View File

@ -3,18 +3,18 @@ package app.mealsmadeeasy.api.auth;
import app.mealsmadeeasy.api.user.User; import app.mealsmadeeasy.api.user.User;
import app.mealsmadeeasy.api.user.UserCreateException; import app.mealsmadeeasy.api.user.UserCreateException;
import app.mealsmadeeasy.api.user.UserService; import app.mealsmadeeasy.api.user.UserService;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.servlet.http.Cookie; import jakarta.servlet.http.Cookie;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder; import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import tools.jackson.databind.ObjectMapper;
import java.util.Map; import java.util.Map;
@ -46,7 +46,7 @@ public class AuthControllerTests {
} }
} }
private MockHttpServletRequestBuilder getLoginRequest() throws Exception { private MockHttpServletRequestBuilder getLoginRequest() {
final Map<String, ?> body = Map.of( final Map<String, ?> body = Map.of(
"username", "test", "username", "test",
"password", "test" "password", "test"

View File

@ -8,11 +8,10 @@ import app.mealsmadeeasy.api.image.spec.ImageUpdateInfoSpec;
import app.mealsmadeeasy.api.user.User; import app.mealsmadeeasy.api.user.User;
import app.mealsmadeeasy.api.user.UserCreateException; import app.mealsmadeeasy.api.user.UserCreateException;
import app.mealsmadeeasy.api.user.UserService; import app.mealsmadeeasy.api.user.UserService;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.mock.web.MockMultipartFile; import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
@ -23,6 +22,7 @@ import org.testcontainers.containers.MinIOContainer;
import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.junit.jupiter.Testcontainers;
import org.testcontainers.utility.DockerImageName; import org.testcontainers.utility.DockerImageName;
import tools.jackson.databind.ObjectMapper;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;

View File

@ -13,12 +13,10 @@ import app.mealsmadeeasy.api.recipe.star.RecipeStarService;
import app.mealsmadeeasy.api.user.User; import app.mealsmadeeasy.api.user.User;
import app.mealsmadeeasy.api.user.UserCreateException; import app.mealsmadeeasy.api.user.UserCreateException;
import app.mealsmadeeasy.api.user.UserService; import app.mealsmadeeasy.api.user.UserService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.DynamicPropertyRegistry; import org.springframework.test.context.DynamicPropertyRegistry;
@ -28,6 +26,7 @@ import org.testcontainers.containers.MinIOContainer;
import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.junit.jupiter.Testcontainers;
import org.testcontainers.utility.DockerImageName; import org.testcontainers.utility.DockerImageName;
import tools.jackson.databind.ObjectMapper;
import java.io.InputStream; import java.io.InputStream;
@ -242,7 +241,7 @@ public class RecipeControllerTests {
.andExpect(jsonPath("$.content", hasSize(3))); .andExpect(jsonPath("$.content", hasSize(3)));
} }
private String getUpdateBody() throws JsonProcessingException { private String getUpdateBody() {
final RecipeUpdateSpec spec = new RecipeUpdateSpec(); final RecipeUpdateSpec spec = new RecipeUpdateSpec();
spec.setTitle("Updated Test Recipe"); spec.setTitle("Updated Test Recipe");
spec.setPreparationTime(15); spec.setPreparationTime(15);

View File

@ -2,17 +2,16 @@ package app.mealsmadeeasy.api.signup;
import app.mealsmadeeasy.api.user.UserCreateException.Type; import app.mealsmadeeasy.api.user.UserCreateException.Type;
import app.mealsmadeeasy.api.user.UserService; import app.mealsmadeeasy.api.user.UserService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder; import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import tools.jackson.databind.ObjectMapper;
import java.util.Map; import java.util.Map;
@ -34,8 +33,7 @@ public class SignUpControllerTests {
@Autowired @Autowired
private UserService userService; private UserService userService;
private MockHttpServletRequestBuilder getCheckUsernameRequest(String usernameToCheck) private MockHttpServletRequestBuilder getCheckUsernameRequest(String usernameToCheck) {
throws JsonProcessingException {
final Map<String, Object> body = Map.of("username", usernameToCheck); final Map<String, Object> body = Map.of("username", usernameToCheck);
return MockMvcRequestBuilders.get("/sign-up/check-username") return MockMvcRequestBuilders.get("/sign-up/check-username")
.content(this.objectMapper.writeValueAsString(body)) .content(this.objectMapper.writeValueAsString(body))
@ -60,7 +58,7 @@ public class SignUpControllerTests {
} }
private MockHttpServletRequestBuilder getCheckEmailRequest(String emailToCheck) throws JsonProcessingException { private MockHttpServletRequestBuilder getCheckEmailRequest(String emailToCheck) {
final Map<String, Object> body = Map.of("email", emailToCheck); final Map<String, Object> body = Map.of("email", emailToCheck);
return MockMvcRequestBuilders.get("/sign-up/check-email") return MockMvcRequestBuilders.get("/sign-up/check-email")
.content(this.objectMapper.writeValueAsString(body)) .content(this.objectMapper.writeValueAsString(body))

View File

@ -8,14 +8,14 @@ import app.mealsmadeeasy.api.recipe.RecipeService;
import app.mealsmadeeasy.api.recipe.spec.RecipeCreateSpec; import app.mealsmadeeasy.api.recipe.spec.RecipeCreateSpec;
import app.mealsmadeeasy.api.user.User; import app.mealsmadeeasy.api.user.User;
import app.mealsmadeeasy.api.user.UserService; import app.mealsmadeeasy.api.user.UserService;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile; import org.springframework.context.annotation.Profile;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.dataformat.yaml.YAMLFactory;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.InputStream; import java.io.InputStream;

View File

@ -1,7 +1,6 @@
package app.mealsmadeeasy.api.security; package app.mealsmadeeasy.api.security;
import app.mealsmadeeasy.api.jwt.JwtService; import app.mealsmadeeasy.api.jwt.JwtService;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.jsonwebtoken.ExpiredJwtException; import io.jsonwebtoken.ExpiredJwtException;
import io.jsonwebtoken.JwtException; import io.jsonwebtoken.JwtException;
import jakarta.servlet.FilterChain; import jakarta.servlet.FilterChain;
@ -19,6 +18,7 @@ import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.web.authentication.WebAuthenticationDetailsSource; import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter; import org.springframework.web.filter.OncePerRequestFilter;
import tools.jackson.databind.ObjectMapper;
import java.io.IOException; import java.io.IOException;

View File

@ -5,6 +5,7 @@ import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.ProviderManager; import org.springframework.security.authentication.ProviderManager;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider; import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.config.Customizer; import org.springframework.security.config.Customizer;
@ -32,7 +33,7 @@ public class SecurityConfiguration {
} }
@Bean @Bean
public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) throws Exception { public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) {
httpSecurity.authorizeHttpRequests(requests -> requests.anyRequest().permitAll()); httpSecurity.authorizeHttpRequests(requests -> requests.anyRequest().permitAll());
httpSecurity.csrf(AbstractHttpConfigurer::disable); httpSecurity.csrf(AbstractHttpConfigurer::disable);
httpSecurity.cors(Customizer.withDefaults()); httpSecurity.cors(Customizer.withDefaults());
@ -58,15 +59,14 @@ public class SecurityConfiguration {
@Bean @Bean
public DaoAuthenticationProvider daoAuthenticationProvider() { public DaoAuthenticationProvider daoAuthenticationProvider() {
final var provider = new DaoAuthenticationProvider(); final var provider = new DaoAuthenticationProvider(this.jpaUserDetailsService);
provider.setUserDetailsService(this.jpaUserDetailsService); provider.setPasswordEncoder(this.beanFactory.getBean(PasswordEncoder.class));
provider.setPasswordEncoder(this.passwordEncoder());
return provider; return provider;
} }
@Bean @Bean
public AuthenticationManager authenticationManager() { public AuthenticationManager authenticationManager() {
return new ProviderManager(this.daoAuthenticationProvider()); return new ProviderManager(this.beanFactory.getBean(AuthenticationProvider.class));
} }
} }