Update backend to Spring Boot 3 (#111)

* Update Spring Boot to 3.0.5
This commit is contained in:
Simon
2023-04-09 01:41:54 +02:00
committed by GitHub
parent 1c386041aa
commit 2231077935
18 changed files with 49 additions and 48 deletions
@@ -3,26 +3,22 @@ package de.grimsi.gameyfin.config;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpStatus;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.HttpStatusEntryPoint;
import org.springframework.security.web.firewall.HttpFirewall;
import org.springframework.security.web.firewall.StrictHttpFirewall;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
@EnableMethodSecurity
@RequiredArgsConstructor
public class SecurityConfiguration {
@@ -33,7 +29,7 @@ public class SecurityConfiguration {
private String password;
@Bean
protected SecurityFilterChain httpSecurity(HttpSecurity http) throws Exception {
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.csrf().disable();
http.headers().frameOptions().disable();
http.httpBasic(Customizer.withDefaults());
@@ -3,9 +3,9 @@ package de.grimsi.gameyfin.entities;
import lombok.*;
import org.hibernate.Hibernate;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import java.util.Objects;
@Entity
@@ -5,7 +5,7 @@ import lombok.*;
import org.hibernate.Hibernate;
import org.hibernate.annotations.CreationTimestamp;
import javax.persistence.*;
import jakarta.persistence.*;
import java.time.Instant;
import java.util.List;
import java.util.Objects;
@@ -3,8 +3,8 @@ package de.grimsi.gameyfin.entities;
import lombok.*;
import org.hibernate.Hibernate;
import javax.persistence.Entity;
import javax.persistence.Id;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import java.util.Objects;
@Entity
@@ -3,8 +3,8 @@ package de.grimsi.gameyfin.entities;
import lombok.*;
import org.hibernate.Hibernate;
import javax.persistence.Entity;
import javax.persistence.Id;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import java.util.Objects;
@Entity
@@ -3,7 +3,7 @@ package de.grimsi.gameyfin.entities;
import lombok.*;
import org.hibernate.Hibernate;
import javax.persistence.*;
import jakarta.persistence.*;
import java.util.List;
import java.util.Objects;
@@ -3,9 +3,9 @@ package de.grimsi.gameyfin.entities;
import lombok.*;
import org.hibernate.Hibernate;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import java.util.Objects;
@Entity
@@ -3,8 +3,8 @@ package de.grimsi.gameyfin.entities;
import lombok.*;
import org.hibernate.Hibernate;
import javax.persistence.Entity;
import javax.persistence.Id;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import java.util.Objects;
@Entity
@@ -3,8 +3,8 @@ package de.grimsi.gameyfin.entities;
import lombok.*;
import org.hibernate.Hibernate;
import javax.persistence.Entity;
import javax.persistence.Id;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import java.util.Objects;
@Entity
@@ -3,7 +3,8 @@ package de.grimsi.gameyfin.entities;
import lombok.*;
import org.hibernate.Hibernate;
import javax.persistence.*;
import jakarta.persistence.*;
import java.util.Objects;
@Entity
@@ -18,7 +19,8 @@ public class UnmappableFile {
}
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "HIBERNATE_SEQUENCE")
@SequenceGenerator(name = "HIBERNATE_SEQUENCE", allocationSize = 1)
private Long id;
private String path;
@@ -18,7 +18,7 @@ import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.util.UriComponentsBuilder;
import javax.annotation.PostConstruct;
import jakarta.annotation.PostConstruct;
import java.net.URI;
import java.util.Collection;
import java.util.Collections;
@@ -15,7 +15,7 @@ import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.reactive.function.client.WebClientResponseException;
import reactor.core.publisher.Flux;
import javax.annotation.PostConstruct;
import jakarta.annotation.PostConstruct;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -1,7 +1,6 @@
package de.grimsi.gameyfin.repositories;
import de.grimsi.gameyfin.entities.UnmappableFile;
import de.grimsi.gameyfin.service.FilesystemService;
import org.jeasy.random.EasyRandom;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -95,7 +95,7 @@ class GameServiceTest {
ResponseStatusException e = assertThrows(ResponseStatusException.class, () -> target.getDetectedGame(slug));
assertThat(e.getStatus()).isEqualTo(HttpStatus.NOT_FOUND);
assertThat(e.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
verify(detectedGameRepositoryMock, times(1)).findById(slug);
}
@@ -257,7 +257,7 @@ class GameServiceTest {
ResponseStatusException e = assertThrows(ResponseStatusException.class, () -> target.mapPathToGame(input.getPath(), input.getSlug()));
assertThat(e.getStatus()).isEqualTo(HttpStatus.CONFLICT);
assertThat(e.getStatusCode()).isEqualTo(HttpStatus.CONFLICT);
verify(detectedGameRepositoryMock, times(1)).existsBySlug(input.getSlug());
verify(detectedGameRepositoryMock, never()).findByPath(input.getPath());
verify(unmappableFileRepositoryMock, never()).findByPath(input.getPath());
@@ -273,7 +273,7 @@ class GameServiceTest {
ResponseStatusException e = assertThrows(ResponseStatusException.class, () -> target.mapPathToGame(input.getPath(), input.getSlug()));
assertThat(e.getStatus()).isEqualTo(HttpStatus.NOT_FOUND);
assertThat(e.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
verify(detectedGameRepositoryMock, times(1)).existsBySlug(input.getSlug());
verify(detectedGameRepositoryMock, times(1)).findByPath(input.getPath());
verify(unmappableFileRepositoryMock, times(1)).findByPath(input.getPath());
@@ -311,7 +311,7 @@ class GameServiceTest {
ResponseStatusException e = assertThrows(ResponseStatusException.class, () -> target.refreshGame(slug));
assertThat(e.getStatus()).isEqualTo(HttpStatus.NOT_FOUND);
assertThat(e.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
verify(detectedGameRepositoryMock, times(1)).findById(slug);
}
}