Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Commit

Permalink
Update Dependencies (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
f11h authored Apr 19, 2022
1 parent 2e73d7f commit 2a73274
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 40 deletions.
33 changes: 17 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,21 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- dependencies -->
<spring.boot.version>2.5.7</spring.boot.version>
<spring.cloud.version>2020.0.4</spring.cloud.version>
<keycloak.version>10.0.1</keycloak.version>
<lombok.version>1.18.12</lombok.version>
<springdoc.version>1.3.9</springdoc.version>
<log4j.version>2.17.0</log4j.version>
<spring.boot.version>2.6.6</spring.boot.version>
<spring.session.version>2.6.2</spring.session.version>
<spring.testaddons.version>3.2.0</spring.testaddons.version>
<spring.cloud.version>2021.0.1</spring.cloud.version>
<keycloak.version>15.1.1</keycloak.version>
<lombok.version>1.18.24</lombok.version>
<springdoc.version>1.6.7</springdoc.version>
<!-- plugins -->
<plugin.checkstyle.version>3.1.1</plugin.checkstyle.version>
<plugin.sonar.version>3.6.1.1688</plugin.sonar.version>
<plugin.jacoco.version>0.8.5</plugin.jacoco.version>
<guava.version>30.0-jre</guava.version>
<plugin.checkstyle.version>3.1.2</plugin.checkstyle.version>
<plugin.sonar.version>3.9.1.2184</plugin.sonar.version>
<plugin.jacoco.version>0.8.8</plugin.jacoco.version>
<guava.version>31.1-jre</guava.version>
<surefire.version>3.0.0-M5</surefire.version>
<sonar.coverage.exclusions>
**/VerificationPortalApplication.java,
**/VerificationPortalApplication.java,
**/SecurityConfig.java,
**/client/*
</sonar.coverage.exclusions>
Expand Down Expand Up @@ -157,10 +158,10 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.c4-soft.springaddons</groupId>
<artifactId>spring-security-oauth2-test-webmvc-addons</artifactId>
<version>2.1.0</version>
<scope>test</scope>
<groupId>com.c4-soft.springaddons</groupId>
<artifactId>spring-security-oauth2-test-webmvc-addons-jdk11</artifactId>
<version>${spring.testaddons.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
Expand All @@ -178,7 +179,7 @@
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-core</artifactId>
<version>2.3.0.RELEASE</version>
<version>${spring.session.version}</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Corona-Warn-App / cwa-verification-portal
*
* (C) 2020, T-Systems International GmbH
*
* Deutsche Telekom AG and all other contributors /
* copyright owners license this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package app.coronawarn.verification.portal.config;

import org.keycloak.adapters.springboot.KeycloakSpringBootConfigResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class KeycloakConfigResolverConfig {

@Bean
public KeycloakSpringBootConfigResolver keycloakConfigResolver() {
return new KeycloakSpringBootConfigResolver();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,6 @@ public void configureGlobal(AuthenticationManagerBuilder auth) {
auth.authenticationProvider(keycloakAuthenticationProvider);
}

@Bean
public KeycloakSpringBootConfigResolver keycloakConfigResolver() {
return new KeycloakSpringBootConfigResolver();
}

@Bean
@Override
protected SessionAuthenticationStrategy sessionAuthenticationStrategy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import app.coronawarn.verification.portal.config.VerificationPortalConfigurationProperties;
import app.coronawarn.verification.portal.service.HealthAuthorityService;
import app.coronawarn.verification.portal.service.TeleTanService;
import com.c4_soft.springaddons.security.oauth2.test.annotations.OpenIdClaims;
import com.c4_soft.springaddons.security.oauth2.test.annotations.keycloak.WithMockKeycloakAuth;
import com.c4_soft.springaddons.security.oauth2.test.mockmvc.ServletUnitTestingSupport;
import feign.FeignException;
Expand Down Expand Up @@ -114,7 +115,7 @@ public void testIndex() throws Exception {
* @throws Exception if the test cannot be performed.
*/
@Test
@WithMockKeycloakAuth(name = "tester1", authorities = {"ROLE_c19hotline", "ROLE_c19hotline_event"})
@WithMockKeycloakAuth(claims = @OpenIdClaims(preferredUsername = "tester1"), authorities = {"ROLE_c19hotline", "ROLE_c19hotline_event"})
public void testStart() throws Exception {
log.info("process testStart() RequestMethod.GET");
mockMvc.perform(get("/cwa/start"))
Expand All @@ -138,7 +139,7 @@ public void testStart() throws Exception {
}

@Test
@WithMockKeycloakAuth(name = "tester2", authorities = {"ROLE_c19hotline"})
@WithMockKeycloakAuth(claims = @OpenIdClaims(preferredUsername = "tester2"), authorities = {"ROLE_c19hotline"})
public void testStartOnlyTestRole() throws Exception {
log.info("process testStartOnlyTestRole()");
mockMvc.perform(get("/cwa/start"))
Expand All @@ -151,7 +152,7 @@ public void testStartOnlyTestRole() throws Exception {
}

@Test
@WithMockKeycloakAuth(name = "tester3", authorities = {"ROLE_c19hotline_event"})
@WithMockKeycloakAuth(claims = @OpenIdClaims(preferredUsername = "tester3"), authorities = {"ROLE_c19hotline_event"})
public void testStartOnlyEventRole() throws Exception {
log.info("process testStartOnlyEventRole()");
mockMvc.perform(get("/cwa/start"))
Expand All @@ -164,7 +165,7 @@ public void testStartOnlyEventRole() throws Exception {
}

@Test
@WithMockKeycloakAuth(name = "tester4", authorities = {})
@WithMockKeycloakAuth(claims = @OpenIdClaims(preferredUsername = "tester4"), authorities = {})
public void testStartNoRole() throws Exception {
log.info("process testStartNoRole()");
mockMvc.perform(get("/cwa/start"))
Expand All @@ -182,7 +183,7 @@ public void testStartNoRole() throws Exception {
* @throws Exception if the test cannot be performed.
*/
@Test
@WithMockKeycloakAuth(name = "tester5", value = "Role_Test")
@WithMockKeycloakAuth(claims = @OpenIdClaims(preferredUsername = "tester5"), value = "Role_Test")
public void testStartNotFound() throws Exception {
log.info("process testStartNotFound()");
mockMvc.perform(get("/corona/start"))
Expand All @@ -195,7 +196,7 @@ public void testStartNotFound() throws Exception {
* @throws Exception if the test cannot be performed.
*/
@Test
@WithMockKeycloakAuth(name = "tester6.1", authorities = {"ROLE_c19hotline", "ROLE_c19hotline_event"})
@WithMockKeycloakAuth(claims = @OpenIdClaims(preferredUsername = "tester6.1"), authorities = {"ROLE_c19hotline", "ROLE_c19hotline_event"})
public void testTeletanEvent() throws Exception {
log.info("process testTeletanEvent()");

Expand Down Expand Up @@ -228,7 +229,7 @@ public void testTeletanEvent() throws Exception {
* @throws Exception if the test cannot be performed.
*/
@Test
@WithMockKeycloakAuth(name = "tester6", authorities = {"ROLE_c19hotline", "ROLE_c19hotline_event"})
@WithMockKeycloakAuth(claims = @OpenIdClaims(preferredUsername = "tester6"), authorities = {"ROLE_c19hotline", "ROLE_c19hotline_event"})
public void testTeletanEvent_InvalidHaId() throws Exception {
log.info("process testTeletanEvent()");

Expand All @@ -249,7 +250,7 @@ public void testTeletanEvent_InvalidHaId() throws Exception {
* @throws Exception if the test cannot be performed.
*/
@Test
@WithMockKeycloakAuth(name = "tester6.2", authorities = {"ROLE_c19hotline", "ROLE_c19hotline_event"})
@WithMockKeycloakAuth(authorities = {"ROLE_c19hotline", "ROLE_c19hotline_event"})
public void testTeletanEvent_MissingHaId() throws Exception {
log.info("process testTeletanEvent()");

Expand All @@ -264,7 +265,7 @@ public void testTeletanEvent_MissingHaId() throws Exception {
}

@Test
@WithMockKeycloakAuth(name = "tester7", authorities = {"ROLE_c19hotline", "ROLE_c19hotline_event"})
@WithMockKeycloakAuth(claims = @OpenIdClaims(preferredUsername = "tester7"), authorities = {"ROLE_c19hotline", "ROLE_c19hotline_event"})
public void testTeletanTest() throws Exception {
log.info("process testTeletanTest()");

Expand All @@ -291,7 +292,7 @@ public void testTeletanTest() throws Exception {
}

@Test
@WithMockKeycloakAuth(name = "tester8", authorities = {"ROLE_c19hotline"})
@WithMockKeycloakAuth(claims = @OpenIdClaims(preferredUsername = "tester8"), authorities = {"ROLE_c19hotline"})
public void testRoleMappingOnlyHotline() throws Exception {
log.info("process testRoleMappingOnlyHotline()");

Expand All @@ -318,7 +319,7 @@ public void testRoleMappingOnlyHotline() throws Exception {
}

@Test
@WithMockKeycloakAuth(name = "tester9", authorities = {"ROLE_c19hotline_event"})
@WithMockKeycloakAuth(claims = @OpenIdClaims(preferredUsername = "tester9"), authorities = {"ROLE_c19hotline_event"})
public void testRoleMappingOnlyEvent() throws Exception {
log.info("process testRoleMappingOnlyEvent()");

Expand Down Expand Up @@ -361,10 +362,10 @@ public void testLogout() throws Exception {
}

@Test
@WithMockKeycloakAuth(name = "tester10", value = "ROLE_c19hotline")
@WithMockKeycloakAuth(claims = @OpenIdClaims(preferredUsername = "tester10"), value = "ROLE_c19hotline")
public void testIfRateLimitExceptionIsHandledCorrectly() throws Exception {
Request dummyRequest = Request.create(Request.HttpMethod.GET, "url", Collections.emptyMap(), null, null, null);
Mockito.doThrow(new FeignException.TooManyRequests("", dummyRequest, null)).when(teleTanService).createTeleTan(any(String.class), any(String.class));
Mockito.doThrow(new FeignException.TooManyRequests("", dummyRequest, null, Collections.emptyMap())).when(teleTanService).createTeleTan(any(String.class), any(String.class));

mockMvc.perform(post("/cwa/teletan")
.param("EVENT", "")
Expand All @@ -375,7 +376,7 @@ public void testIfRateLimitExceptionIsHandledCorrectly() throws Exception {
}

@Test
@WithMockKeycloakAuth(name = "tester11", value = "Role_Test")
@WithMockKeycloakAuth(claims = @OpenIdClaims(preferredUsername = "tester11"), value = "Role_Test")
public void testIfAnyOtherExceptionIsJustForwared() {
given(teleTanService.createTeleTan(any(String.class), any(String.class))).willAnswer(invocation -> {
throw new Exception("Dummy Exception");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;

import com.c4_soft.springaddons.security.oauth2.test.annotations.OpenIdClaims;
import com.c4_soft.springaddons.security.oauth2.test.annotations.keycloak.WithMockKeycloakAuth;
import com.c4_soft.springaddons.security.oauth2.test.mockmvc.ServletUnitTestingSupport;
import javax.servlet.RequestDispatcher;
Expand Down Expand Up @@ -79,7 +80,7 @@ public void setup() {
}

@Test
@WithMockKeycloakAuth(name = "tester", value = "Role_Test")
@WithMockKeycloakAuth(claims = @OpenIdClaims(preferredUsername = "tester"), value = "Role_Test")
public void handleErrorHandlesNotFoundCorrectly() throws Exception {
log.info("process handleErrorHandlesNotFoundCorrectly() RequestMethod.POST");
mockMvc.perform(post("/error")
Expand All @@ -91,7 +92,7 @@ public void handleErrorHandlesNotFoundCorrectly() throws Exception {
}

@Test
@WithMockKeycloakAuth(name = "tester", value = "Role_Test")
@WithMockKeycloakAuth(claims = @OpenIdClaims(preferredUsername = "tester"), value = "Role_Test")
public void handleErrorHandlesForbiddenCorrectly() throws Exception {
log.info("process handleErrorHandlesForbiddenCorrectly() RequestMethod.POST");
mockMvc.perform(post("/error")
Expand All @@ -103,7 +104,7 @@ public void handleErrorHandlesForbiddenCorrectly() throws Exception {
}

@Test
@WithMockKeycloakAuth(name = "tester", value = "Role_Test")
@WithMockKeycloakAuth(claims = @OpenIdClaims(preferredUsername = "tester"), value = "Role_Test")
public void handleErrorHandlesTooManyRequestsWithRateLimitCorrectly() throws Exception {
log.info("process handleErrorHandlesTooManyRequestsWithRateLimitCorrectly() RequestMethod.POST");
mockMvc.perform(post("/error")
Expand All @@ -116,7 +117,7 @@ public void handleErrorHandlesTooManyRequestsWithRateLimitCorrectly() throws Exc
}

@Test
@WithMockKeycloakAuth(name = "tester", value = "Role_Test")
@WithMockKeycloakAuth(claims = @OpenIdClaims(preferredUsername = "tester"), value = "Role_Test")
public void handleErrorHandlesTooManyRequestsCorrectly() throws Exception {
log.info("process handleErrorHandlesTooManyRequestsCorrectly() RequestMethod.POST");
mockMvc.perform(post("/error")
Expand All @@ -129,7 +130,7 @@ public void handleErrorHandlesTooManyRequestsCorrectly() throws Exception {
}

@Test
@WithMockKeycloakAuth(name = "tester", value = "Role_Test")
@WithMockKeycloakAuth(claims = @OpenIdClaims(preferredUsername = "tester"), value = "Role_Test")
public void handleErrorHandlesDefaultCorrectly() throws Exception {
log.info("process handleErrorHandlesDefaultCorrectly() RequestMethod.POST");
mockMvc.perform(post("/error")
Expand Down

0 comments on commit 2a73274

Please sign in to comment.