From 82dc2334924d7a5d346ed3380a33d355b981ed2e Mon Sep 17 00:00:00 2001 From: Philipp Ossler Date: Fri, 24 Feb 2023 14:46:34 +0100 Subject: [PATCH] test: fix CORS test cases (#153) --- pom.xml | 13 ++++++------- .../zeebe/tasklist/CorsSettingsControllerTest.java | 8 +++++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index e98de87..335fc0c 100644 --- a/pom.xml +++ b/pom.xml @@ -189,17 +189,16 @@ - org.junit.jupiter - junit-jupiter - 5.9.1 + org.springframework.security + spring-security-test test - - org.springframework.boot - spring-boot-devtools - true + org.junit.jupiter + junit-jupiter + 5.9.1 + test diff --git a/src/test/java/io/zeebe/tasklist/CorsSettingsControllerTest.java b/src/test/java/io/zeebe/tasklist/CorsSettingsControllerTest.java index 0c773a3..b2172d0 100644 --- a/src/test/java/io/zeebe/tasklist/CorsSettingsControllerTest.java +++ b/src/test/java/io/zeebe/tasklist/CorsSettingsControllerTest.java @@ -12,7 +12,7 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.boot.web.server.LocalServerPort; -import org.springframework.test.context.ActiveProfiles; +import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.web.servlet.MockMvc; @SpringBootTest( @@ -22,7 +22,6 @@ "logging.level.io.zeebe.tasklist: info", }) @AutoConfigureMockMvc -@ActiveProfiles("junittest") public class CorsSettingsControllerTest { @LocalServerPort protected int port; @@ -32,17 +31,20 @@ public class CorsSettingsControllerTest { @MockBean protected HazelcastService zeebeHazelcastService; @Test + @WithMockUser(username = "demo", password = "demo") public void access_control_origin_request_header_is_checked() throws Exception { mockMvc .perform( options("/") .header("Access-Control-Request-Method", "GET") .header("Host", "localhost") - .header("Origin", "http://a.bad-person.internet")) + .header("Origin", "http://a.bad-person.internet") + ) .andExpect(status().isForbidden()); } @Test + @WithMockUser(username = "demo", password = "demo") public void access_control_allow_origin_response_header_is_send() throws Exception { mockMvc .perform(