From 75e82e1b2c4035ca590a8273cead41b58a169776 Mon Sep 17 00:00:00 2001 From: Madhura Bhave Date: Fri, 16 Feb 2018 16:49:38 -0800 Subject: [PATCH] Fix tests to use GET to bypass CsrfFilter --- .../src/test/java/sample/HelloWebSecurityApplicationTests.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spring-boot-integration-tests/spring-boot-security-tests/spring-boot-security-test-web-helloworld/src/test/java/sample/HelloWebSecurityApplicationTests.java b/spring-boot-integration-tests/spring-boot-security-tests/spring-boot-security-test-web-helloworld/src/test/java/sample/HelloWebSecurityApplicationTests.java index 681953ad4a..5346c7ec4d 100644 --- a/spring-boot-integration-tests/spring-boot-security-tests/spring-boot-security-test-web-helloworld/src/test/java/sample/HelloWebSecurityApplicationTests.java +++ b/spring-boot-integration-tests/spring-boot-security-tests/spring-boot-security-test-web-helloworld/src/test/java/sample/HelloWebSecurityApplicationTests.java @@ -56,6 +56,7 @@ public class HelloWebSecurityApplicationTests { @Test public void requiresAuthentication() throws Exception { + this.request.setMethod("GET"); this.springSecurityFilterChain.doFilter(this.request, this.response, this.chain); assertThat(this.response.getStatus()) .isEqualTo(HttpServletResponse.SC_UNAUTHORIZED); @@ -63,6 +64,7 @@ public class HelloWebSecurityApplicationTests { @Test public void userAuthenticates() throws Exception { + this.request.setMethod("GET"); this.request.addHeader("Authorization", "Basic " + new String(Base64.encode("user:password".getBytes("UTF-8"))));