diff --git a/pom.xml b/pom.xml
index 83dc34c..357a67e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,124 +1,135 @@
- 4.0.0
-
- org.springframework.boot
- spring-boot-starter-parent
- 3.4.1
-
-
- de.zendric.app
- XpenselyServer
- 1.0.0
- XpenselyServer
- XpenselyServer used to handle the Xpensely App
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 21
-
-
-
- org.springframework.boot
- spring-boot-starter-data-jpa
-
-
- org.springframework.boot
- spring-boot-starter-security
-
-
- org.springframework.boot
- spring-boot-starter-validation
-
-
- com.bucket4j
- bucket4j-core
- 8.10.1
-
-
- org.springframework.boot
- spring-boot-starter-oauth2-resource-server
-
-
- org.springframework.boot
- spring-boot-starter-oauth2-client
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
- org.springframework.boot
- spring-boot-devtools
- runtime
- true
-
-
- org.postgresql
- postgresql
- runtime
-
-
- org.projectlombok
- lombok
- true
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
- com.h2database
- h2
- test
-
-
- org.springframework.security
- spring-security-test
- test
-
-
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 4.0.6
+
+
+ de.zendric.app
+ XpenselyServer
+ 1.0.0
+ XpenselyServer
+ XpenselyServer used to handle the Xpensely App
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 21
+ 1.18.46
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+ org.springframework.boot
+ spring-boot-starter-security
+
+
+ org.springframework.boot
+ spring-boot-starter-validation
+
+
+ com.bucket4j
+ bucket4j-core
+ 8.10.1
+
+
+ org.springframework.boot
+ spring-boot-starter-oauth2-resource-server
+
+
+ org.springframework.boot
+ spring-boot-starter-oauth2-client
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework.boot
+ spring-boot-devtools
+ runtime
+ true
+
+
+ org.postgresql
+ postgresql
+ runtime
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.springframework.boot
+ spring-boot-starter-webmvc-test
+ test
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa-test
+ test
+
+
+ com.h2database
+ h2
+ test
+
+
+ org.springframework.security
+ spring-security-test
+ test
+
+
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
-
-
- org.projectlombok
- lombok
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
-
- org.projectlombok
- lombok
-
-
-
-
-
-
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+
+ org.projectlombok
+ lombok
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+ org.projectlombok
+ lombok
+
+
+
+
+
+
diff --git a/src/main/java/de/zendric/app/xpensely_server/controller/AppUserController.java b/src/main/java/de/zendric/app/xpensely_server/controller/AppUserController.java
index 7bb5e8a..597824b 100644
--- a/src/main/java/de/zendric/app/xpensely_server/controller/AppUserController.java
+++ b/src/main/java/de/zendric/app/xpensely_server/controller/AppUserController.java
@@ -9,7 +9,6 @@ import org.springframework.web.server.ResponseStatusException;
import de.zendric.app.xpensely_server.model.AppUser;
import de.zendric.app.xpensely_server.model.AppUserCreateRequest;
-import de.zendric.app.xpensely_server.model.Exception.UsernameAlreadyExistsException;
import de.zendric.app.xpensely_server.security.AuthenticatedUserResolver;
import de.zendric.app.xpensely_server.services.UserService;
@@ -47,15 +46,9 @@ public class AppUserController {
@PostMapping("/createUser")
public ResponseEntity createUser(@RequestBody @Valid AppUserCreateRequest userRequest) {
- try {
- AppUser convertedUser = userRequest.convertToAppUser();
- AppUser nUser = userService.createUser(convertedUser);
- return new ResponseEntity<>(nUser, HttpStatus.CREATED);
- } catch (UsernameAlreadyExistsException e) {
- return new ResponseEntity<>(null, HttpStatus.CONFLICT);
- } catch (Exception e) {
- return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST);
- }
+ AppUser convertedUser = userRequest.convertToAppUser();
+ AppUser nUser = userService.createUser(convertedUser);
+ return new ResponseEntity<>(nUser, HttpStatus.CREATED);
}
@DeleteMapping
diff --git a/src/main/java/de/zendric/app/xpensely_server/controller/ExpenseListController.java b/src/main/java/de/zendric/app/xpensely_server/controller/ExpenseListController.java
index 3ef07f8..a2227e3 100644
--- a/src/main/java/de/zendric/app/xpensely_server/controller/ExpenseListController.java
+++ b/src/main/java/de/zendric/app/xpensely_server/controller/ExpenseListController.java
@@ -68,6 +68,7 @@ public class ExpenseListController {
expenseList.setXpenselyStandardCategories(standardCategories);
expenseList.setSharedWith(null);
ExpenseList savedItem = expenseListService.createList(expenseList);
+ log.debug("Created expense list '{}' for user {}", savedItem.getName(), authenticatedUser.getId());
return new ResponseEntity<>(savedItem, HttpStatus.CREATED);
}
@@ -106,7 +107,7 @@ public class ExpenseListController {
AppUser user = authenticatedUserResolver.resolveCurrentUser(authentication);
Optional expenseListOpt = expenseListService.findById(expenseListId);
if (expenseListOpt.isEmpty())
- return new ResponseEntity<>(null, HttpStatus.NOT_FOUND);
+ return new ResponseEntity<>(HttpStatus.NOT_FOUND);
assertMember(user, expenseListOpt.get());
AppUser expenseOwner = userService.getUserByName(expenseChangeRequest.getOwnerName());
Expense expense = expenseChangeRequest.convertToExpense(expenseOwner.getId(), expenseListOpt.get());
diff --git a/src/main/java/de/zendric/app/xpensely_server/security/SecurityConfig.java b/src/main/java/de/zendric/app/xpensely_server/security/SecurityConfig.java
index 1ae17fc..19a8a19 100644
--- a/src/main/java/de/zendric/app/xpensely_server/security/SecurityConfig.java
+++ b/src/main/java/de/zendric/app/xpensely_server/security/SecurityConfig.java
@@ -6,7 +6,7 @@ import org.springframework.context.annotation.Profile;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
-import org.springframework.security.oauth2.server.resource.web.BearerTokenAuthenticationFilter;
+import org.springframework.security.oauth2.server.resource.web.authentication.BearerTokenAuthenticationFilter;
import org.springframework.security.web.SecurityFilterChain;
@Configuration
@@ -18,7 +18,7 @@ public class SecurityConfig {
http
.authorizeHttpRequests(auth -> auth
.anyRequest().permitAll())
- .csrf().disable();
+ .csrf(csrf -> csrf.disable());
return http.build();
}
@@ -33,7 +33,7 @@ public class SecurityConfig {
.jwt(Customizer.withDefaults()))
.oauth2Login(Customizer.withDefaults())
.addFilterAfter(new RateLimitFilter(), BearerTokenAuthenticationFilter.class)
- .csrf().disable();
+ .csrf(csrf -> csrf.disable());
return http.build();
}
diff --git a/src/main/java/de/zendric/app/xpensely_server/services/ExpenseListService.java b/src/main/java/de/zendric/app/xpensely_server/services/ExpenseListService.java
index 0f65b6e..20d8177 100644
--- a/src/main/java/de/zendric/app/xpensely_server/services/ExpenseListService.java
+++ b/src/main/java/de/zendric/app/xpensely_server/services/ExpenseListService.java
@@ -31,18 +31,10 @@ public class ExpenseListService {
this.customCategoryRepository = customCategoryRepository;
}
- public List getAllLists() {
- return repository.findAll();
- }
-
public ExpenseList createList(ExpenseList list) {
return repository.save(list);
}
- public void deleteList(Long id) {
- repository.deleteById(id);
- }
-
public void deleteById(Long id) {
repository.deleteById(id);
}
@@ -51,10 +43,6 @@ public class ExpenseListService {
return repository.findById(id);
}
- public Iterable findAll() {
- return repository.findAll();
- }
-
public ExpenseList save(ExpenseList expenseList) {
return repository.save(expenseList);
}
diff --git a/src/test/java/de/zendric/app/xpensely_Server/ExpenseListRepositoryTest.java b/src/test/java/de/zendric/app/xpensely_Server/ExpenseListRepositoryTest.java
index 23bce57..97ddbc5 100644
--- a/src/test/java/de/zendric/app/xpensely_Server/ExpenseListRepositoryTest.java
+++ b/src/test/java/de/zendric/app/xpensely_Server/ExpenseListRepositoryTest.java
@@ -4,7 +4,7 @@ import de.zendric.app.xpensely_server.model.ExpenseList;
import de.zendric.app.xpensely_server.repo.ExpenseListRepository;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
+import org.springframework.boot.data.jpa.test.autoconfigure.DataJpaTest;
import java.util.Optional;
diff --git a/src/test/java/de/zendric/app/xpensely_Server/controller/AppUserControllerTest.java b/src/test/java/de/zendric/app/xpensely_Server/controller/AppUserControllerTest.java
index 94dbd6d..b99093c 100644
--- a/src/test/java/de/zendric/app/xpensely_Server/controller/AppUserControllerTest.java
+++ b/src/test/java/de/zendric/app/xpensely_Server/controller/AppUserControllerTest.java
@@ -6,8 +6,11 @@ import de.zendric.app.xpensely_server.security.AuthenticatedUserResolver;
import de.zendric.app.xpensely_server.services.UserService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
-import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
+import org.springframework.boot.security.oauth2.client.autoconfigure.OAuth2ClientAutoConfiguration;
+import org.springframework.boot.security.oauth2.client.autoconfigure.servlet.OAuth2ClientWebSecurityAutoConfiguration;
+import org.springframework.boot.security.oauth2.server.resource.autoconfigure.servlet.OAuth2ResourceServerAutoConfiguration;
+import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
+import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest;
import org.springframework.http.MediaType;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
@@ -18,7 +21,11 @@ import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
-@WebMvcTest(AppUserController.class)
+@WebMvcTest(value = AppUserController.class, excludeAutoConfiguration = {
+ OAuth2ClientAutoConfiguration.class,
+ OAuth2ClientWebSecurityAutoConfiguration.class,
+ OAuth2ResourceServerAutoConfiguration.class
+})
@AutoConfigureMockMvc(addFilters = false)
@ActiveProfiles("test")
class AppUserControllerTest {
diff --git a/src/test/java/de/zendric/app/xpensely_Server/controller/ExpenseListControllerTest.java b/src/test/java/de/zendric/app/xpensely_Server/controller/ExpenseListControllerTest.java
index 22418e3..5c50950 100644
--- a/src/test/java/de/zendric/app/xpensely_Server/controller/ExpenseListControllerTest.java
+++ b/src/test/java/de/zendric/app/xpensely_Server/controller/ExpenseListControllerTest.java
@@ -9,8 +9,11 @@ import de.zendric.app.xpensely_server.services.ExpenseListService;
import de.zendric.app.xpensely_server.services.UserService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
-import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
+import org.springframework.boot.security.oauth2.client.autoconfigure.OAuth2ClientAutoConfiguration;
+import org.springframework.boot.security.oauth2.client.autoconfigure.servlet.OAuth2ClientWebSecurityAutoConfiguration;
+import org.springframework.boot.security.oauth2.server.resource.autoconfigure.servlet.OAuth2ResourceServerAutoConfiguration;
+import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
+import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest;
import org.springframework.http.MediaType;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
@@ -24,7 +27,11 @@ import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
-@WebMvcTest(ExpenseListController.class)
+@WebMvcTest(value = ExpenseListController.class, excludeAutoConfiguration = {
+ OAuth2ClientAutoConfiguration.class,
+ OAuth2ClientWebSecurityAutoConfiguration.class,
+ OAuth2ResourceServerAutoConfiguration.class
+})
@AutoConfigureMockMvc(addFilters = false)
@ActiveProfiles("test")
class ExpenseListControllerTest {