9d314a49c6
Integration test module (it/) simulates a zero-code consumer of plate-auth-starter: - TestConsumerApplication: minimal @SpringBootApplication - AuthBootstrapIT: verifies all required beans are present + PermissiveOrgValidator default - ExchangeFlowIT: full exchange flow (valid envelope → tokens, tampered sig → 401, replay → 401) - PlateAuthFlywayMigrationIT: V1-V6 migration test (CI-only, requires Docker/Testcontainers) Also adds: - SecurityConfig: extracted from auto-config to separate @Configuration for proper bean ordering - PlateAuthExceptionHandler: SecurityException → 401, IllegalArgument → 400 - PlateAuthFlywayConfig: @ConditionalOnProperty(plate.auth.flyway.enabled) for test flexibility - @AutoConfigurationPackage for entity scanning from starter JAR - @Order(-100) on SecurityFilterChain for priority over defaults - CORS: allowedOriginPatterns(*) when no origins configured (dev-friendly) All 5 tests green locally (2 Docker-dependent skipped without CI env).
30 lines
1.1 KiB
Java
30 lines
1.1 KiB
Java
package de.platesoft.auth.config;
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
|
|
/**
|
|
* Global exception handler for plate-auth controllers.
|
|
*/
|
|
@RestControllerAdvice(basePackages = "de.platesoft.auth.controller")
|
|
public class PlateAuthExceptionHandler {
|
|
|
|
@ExceptionHandler(SecurityException.class)
|
|
public ResponseEntity<String> handleSecurityException(SecurityException e) {
|
|
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(e.getMessage());
|
|
}
|
|
|
|
@ExceptionHandler(IllegalArgumentException.class)
|
|
public ResponseEntity<String> handleIllegalArgument(IllegalArgumentException e) {
|
|
return ResponseEntity.badRequest().body(e.getMessage());
|
|
}
|
|
|
|
@ExceptionHandler(Exception.class)
|
|
public ResponseEntity<String> handleGenericException(Exception e) {
|
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
|
.body("Internal error: " + e.getClass().getSimpleName() + ": " + e.getMessage());
|
|
}
|
|
}
|