diff --git a/pom.xml b/pom.xml
index 0b094f0..d4630a8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,10 +26,10 @@
2.19.0
6.6.0
- 3.0.0
+
0.2.3
- 2.10.0
- 6.0.5
+
+ 6.0.5
2.10.9.2
2.1.1
3.12.1
@@ -38,10 +38,10 @@
2.1.214
4.9.1
8.0.0.Final
- 4.1.1
+ 4.23.2
17
17
- 3.0.0
+
@@ -83,6 +83,11 @@
spring-security-core
${spring-security.version}
+
+ org.springframework.boot
+ spring-boot-starter-oauth2-resource-server
+
+
@@ -125,21 +130,19 @@
plexus-utils
3.3.0
-
+
+
io.swagger.core.v3
swagger-annotations
2.2.15
+
+
- io.springfox
- springfox-boot-starter
- ${springfox.boot.starter.version}
-
-
- io.swagger.parser.v3
- swagger-parser
- 2.1.15
+ org.springdoc
+ springdoc-openapi-starter-webmvc-ui
+ 2.4.0
@@ -149,12 +152,6 @@
20220320
-
-
- io.springfox
- springfox-boot-starter
- ${springfox-boot-starter.version}
-
org.keycloak
@@ -250,19 +247,14 @@
org.springframework.security
spring-security-test
+ ${spring-security.version}
test
- powermock-module-junit4
- org.powermock
- test
- 2.0.2
-
-
- powermock-api-mockito2
- org.powermock
+ junit
+ junit
+ 4.13.2
test
- 2.0.2
diff --git a/src/main/java/de/caritas/cob/videoservice/api/controller/CustomSwaggerApiResourceController.java b/src/main/java/de/caritas/cob/videoservice/api/controller/CustomSwaggerApiResourceController.java
deleted file mode 100644
index 20c524d..0000000
--- a/src/main/java/de/caritas/cob/videoservice/api/controller/CustomSwaggerApiResourceController.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package de.caritas.cob.videoservice.api.controller;
-
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import springfox.documentation.annotations.ApiIgnore;
-import springfox.documentation.swagger.web.ApiResourceController;
-import springfox.documentation.swagger.web.SwaggerResourcesProvider;
-
-@Controller
-@ApiIgnore
-@RequestMapping(value = "${springfox.docuPath}" + "/swagger-resources")
-public class CustomSwaggerApiResourceController extends ApiResourceController {
-
- public static final String SWAGGER_UI_BASE_URL = "/videocalls/docs";
-
- public CustomSwaggerApiResourceController(SwaggerResourcesProvider swaggerResources) {
- super(swaggerResources, SWAGGER_UI_BASE_URL);
- }
-}
diff --git a/src/main/java/de/caritas/cob/videoservice/api/controller/VideoController.java b/src/main/java/de/caritas/cob/videoservice/api/controller/VideoController.java
index 905b2e3..473e5f5 100644
--- a/src/main/java/de/caritas/cob/videoservice/api/controller/VideoController.java
+++ b/src/main/java/de/caritas/cob/videoservice/api/controller/VideoController.java
@@ -41,7 +41,7 @@ public class VideoController implements VideocallsApi {
*/
@Override
public ResponseEntity createVideoCall(
- @RequestHeader String rcUserId, @Valid CreateVideoCallDTO createVideoCallDto) {
+ @RequestHeader String rcUserId, CreateVideoCallDTO createVideoCallDto) {
var response = videoCallFacade.startVideoCall(createVideoCallDto, rcUserId);
return new ResponseEntity<>(response, HttpStatus.CREATED);
diff --git a/src/main/java/de/caritas/cob/videoservice/api/service/UuidRegistry.java b/src/main/java/de/caritas/cob/videoservice/api/service/UuidRegistry.java
index fb28a0b..521d31b 100644
--- a/src/main/java/de/caritas/cob/videoservice/api/service/UuidRegistry.java
+++ b/src/main/java/de/caritas/cob/videoservice/api/service/UuidRegistry.java
@@ -10,7 +10,7 @@
@Component
public class UuidRegistry {
- private static final List GENERATED_UUIDS = new CopyOnWriteArrayList<>();
+ protected static final List GENERATED_UUIDS = new CopyOnWriteArrayList<>();
/**
* Generates an unique {@link UUID} string that is currently not registered and adds it to the
diff --git a/src/main/java/de/caritas/cob/videoservice/config/SpringFoxConfig.java b/src/main/java/de/caritas/cob/videoservice/config/SpringFoxConfig.java
deleted file mode 100644
index 07f14cd..0000000
--- a/src/main/java/de/caritas/cob/videoservice/config/SpringFoxConfig.java
+++ /dev/null
@@ -1,135 +0,0 @@
-package de.caritas.cob.videoservice.config;
-
-import static java.util.Collections.singletonList;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Import;
-import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
-import springfox.documentation.builders.PathSelectors;
-import springfox.documentation.builders.RequestHandlerSelectors;
-import springfox.documentation.service.ApiInfo;
-import springfox.documentation.service.ApiKey;
-import springfox.documentation.service.AuthorizationScope;
-import springfox.documentation.service.Contact;
-import springfox.documentation.service.SecurityReference;
-import springfox.documentation.service.SecurityScheme;
-import springfox.documentation.spi.DocumentationType;
-import springfox.documentation.spi.service.contexts.SecurityContext;
-import springfox.documentation.spring.web.plugins.Docket;
-import springfox.documentation.swagger2.annotations.EnableSwagger2;
-
-/**
- * Provides the SpringFox (API documentation generation) configuration.
- *
- */
-@Configuration
-@Import(BeanValidatorPluginsConfiguration.class)
-@EnableSwagger2
-public class SpringFoxConfig {
-
- @Value("${springfox.docuTitle}")
- private String docuTitle;
- @Value("${springfox.docuDescription}")
- private String docuDescription;
- @Value("${springfox.docuVersion}")
- private String docuVersion;
- @Value("${springfox.docuTermsUrl}")
- private String docuTermsUrl;
- @Value("${springfox.docuContactName}")
- private String docuContactName;
- @Value("${springfox.docuContactUrl}")
- private String docuContactUrl;
- @Value("${springfox.docuContactEmail}")
- private String docuContactEmail;
- @Value("${springfox.docuLicense}")
- private String docuLicense;
- @Value("${springfox.docuLicenseUrl}")
- private String docuLicenseUrl;
-
- /**
- * White list for path patterns that should be white listed so that swagger UI can be accessed
- * without authorization.
- */
- public static final String[] WHITE_LIST =
- new String[] {
- "/videocalls/docs",
- "/videocalls/docs/**",
- "/videocalls/event/stop",
- "/v2/api-docs",
- "/configuration/ui",
- "/swagger-resources/**",
- "/configuration/security",
- "/swagger-ui",
- "/swagger-ui/**",
- "/webjars/**",
- "/actuator/health",
- "/actuator/health/**"
- };
-
- /**
- * SpringFox Docket Bean.
- *
- * @return {@link Docket}
- */
- @Bean
- public Docket apiDocket() {
- return new Docket(DocumentationType.SWAGGER_2).select()
- .apis(RequestHandlerSelectors.basePackage("de.caritas.cob.agencyservice.api")).build()
- .consumes(getContentTypes()).produces(getContentTypes()).apiInfo(getApiInfo())
- .useDefaultResponseMessages(false).protocols(protocols()).securitySchemes(securitySchemes())
- .securityContexts(securityContexts());
- }
-
- private List securityContexts() {
- return singletonList(SecurityContext.builder()
- .forPaths(PathSelectors.any()).securityReferences(securityReferences()).build());
- }
-
- private List securityReferences() {
- return singletonList(
- SecurityReference.builder().reference("token").scopes(new AuthorizationScope[0]).build());
- }
-
- private List securitySchemes() {
- return singletonList(new ApiKey("Bearer", "Authorization", "header"));
- }
-
- /**
- * Returns the API protocols (for documentation).
- *
- * @return the supported protocols
- */
- private Set protocols() {
- Set protocols = new HashSet<>();
- protocols.add("https");
- return protocols;
- }
-
- /**
- * Returns all content types which should be consumed/produced.
- *
- * @return the supported content types
- */
- private Set getContentTypes() {
- Set contentTypes = new HashSet<>();
- contentTypes.add("application/json");
- return contentTypes;
- }
-
- /**
- * Returns the API information (defined in application.properties).
- *
- * @return api information
- */
- private ApiInfo getApiInfo() {
- return new ApiInfo(docuTitle, docuDescription, docuVersion, docuTermsUrl,
- new Contact(docuContactName, docuContactUrl, docuContactEmail), docuLicense, docuLicenseUrl,
- Collections.emptyList());
- }
-}
diff --git a/src/main/java/de/caritas/cob/videoservice/config/security/WebSecurityConfig.java b/src/main/java/de/caritas/cob/videoservice/config/security/WebSecurityConfig.java
index 97d4ed3..2dc3894 100644
--- a/src/main/java/de/caritas/cob/videoservice/config/security/WebSecurityConfig.java
+++ b/src/main/java/de/caritas/cob/videoservice/config/security/WebSecurityConfig.java
@@ -1,7 +1,6 @@
package de.caritas.cob.videoservice.config.security;
import de.caritas.cob.videoservice.api.authorization.Authority.AuthorityValue;
-import de.caritas.cob.videoservice.config.SpringFoxConfig;
import de.caritas.cob.videoservice.filter.HttpTenantFilter;
import de.caritas.cob.videoservice.filter.StatelessCsrfFilter;
import jakarta.annotation.Nullable;
@@ -30,6 +29,22 @@ public class WebSecurityConfig implements WebMvcConfigurer {
private static final String UUID_PATTERN =
"\\b[0-9a-f]{8}\\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\\b[0-9a-f]{12}\\b";
+ public static final String[] WHITE_LIST =
+ new String[] {
+ "/videocalls/docs",
+ "/videocalls/docs/**",
+ "/videocalls/event/stop",
+ "/v2/api-docs",
+ "/configuration/ui",
+ "/swagger-resources/**",
+ "/configuration/security",
+ "/swagger-ui",
+ "/swagger-ui/**",
+ "/webjars/**",
+ "/actuator/health",
+ "/actuator/health/**"
+ };
+
@Autowired AuthorisationService authorisationService;
@Autowired JwtAuthConverterProperties jwtAuthConverterProperties;
@@ -69,7 +84,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.authorizeRequests()
- .requestMatchers(SpringFoxConfig.WHITE_LIST)
+ .requestMatchers(WHITE_LIST)
.permitAll()
.requestMatchers("/videocalls/new")
.hasAuthority(AuthorityValue.CONSULTANT)
diff --git a/src/main/java/de/caritas/cob/videoservice/filter/StatelessCsrfFilter.java b/src/main/java/de/caritas/cob/videoservice/filter/StatelessCsrfFilter.java
index 797adce..36a906f 100644
--- a/src/main/java/de/caritas/cob/videoservice/filter/StatelessCsrfFilter.java
+++ b/src/main/java/de/caritas/cob/videoservice/filter/StatelessCsrfFilter.java
@@ -3,7 +3,7 @@
import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;
-import de.caritas.cob.videoservice.config.SpringFoxConfig;
+import de.caritas.cob.videoservice.config.security.WebSecurityConfig;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.Cookie;
@@ -74,7 +74,7 @@ public static final class DefaultRequiresCsrfMatcher implements RequestMatcher {
@Override
public boolean matches(HttpServletRequest request) {
- if (Arrays.stream(SpringFoxConfig.WHITE_LIST)
+ if (Arrays.stream(WebSecurityConfig.WHITE_LIST)
.parallel()
.anyMatch(request.getRequestURI().toLowerCase()::contains)) {
return false;
diff --git a/src/main/resources/application-testing.properties b/src/main/resources/application-testing.properties
index cb637d2..6999e1e 100644
--- a/src/main/resources/application-testing.properties
+++ b/src/main/resources/application-testing.properties
@@ -31,7 +31,9 @@ spring.liquibase.enabled=false
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1
spring.datasource.schema=classpath*:database/VideoServiceDatabase.sql,classpath*:database/VideoData.sql
+spring.sql.init.schema-locations=classpath*:database/VideoServiceDatabase.sql,classpath*:database/VideoData.sql
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
+
spring.jpa.open-in-view=false
spring.jpa.hibernate.ddl-auto=none
spring.data.jpa.repositories.bootstrap-mode=default
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index b542b10..a2b1680 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -72,4 +72,11 @@ spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDB103Dialect
spring.datasource.url=jdbc:mariadb://localhost:3306/videoservice
spring.datasource.username=videoservice
-spring.datasource.password=
\ No newline at end of file
+spring.datasource.password=
+
+spring.security.oauth2.resourceserver.jwt.issuer-uri: https://localhost/auth/realms/onlineberatung
+spring.security.oauth2.resourceserver.jwt.jwk-set-uri: https://localhost/auth/realms/onlineberatung/protocol/openid-connect/certs
+spring.jwt.auth.converter.resource-id: app
+spring.jwt.auth.converter.principal-attribute: preferred_username
+
+springdoc.api-docs.enabled=false
\ No newline at end of file
diff --git a/src/test/java/de/caritas/cob/videoservice/ApiDefaultResponseEntityExceptionHandlerTest.java b/src/test/java/de/caritas/cob/videoservice/ApiDefaultResponseEntityExceptionHandlerTest.java
index 44a165c..6eee9c7 100644
--- a/src/test/java/de/caritas/cob/videoservice/ApiDefaultResponseEntityExceptionHandlerTest.java
+++ b/src/test/java/de/caritas/cob/videoservice/ApiDefaultResponseEntityExceptionHandlerTest.java
@@ -1,41 +1,29 @@
package de.caritas.cob.videoservice;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.eq;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.powermock.reflect.Whitebox.setInternalState;
-import de.caritas.cob.videoservice.api.service.LogService;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.slf4j.Logger;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
import org.springframework.web.context.request.WebRequest;
-@RunWith(MockitoJUnitRunner.class)
-public class ApiDefaultResponseEntityExceptionHandlerTest {
+@ExtendWith(MockitoExtension.class)
+class ApiDefaultResponseEntityExceptionHandlerTest {
@InjectMocks private ApiDefaultResponseEntityExceptionHandler exceptionHandler;
- @Mock private Logger logger;
-
- @Before
- public void setup() {
- setInternalState(LogService.class, "LOGGER", logger);
- }
-
@Test
- public void handleInternal_Should_logInternalServerError_When_exceptionIsGiven() {
+ void handleInternal_Should_respondWithStatusInternalServerError_When_exceptionIsGiven() {
RuntimeException exception = new RuntimeException("error");
- this.exceptionHandler.handleInternal(exception, mock(WebRequest.class));
+ ResponseEntity