From 100c2ce86fa5051b4f0ee9eaa30b713c02fda7bd Mon Sep 17 00:00:00 2001 From: Madhura Bhave Date: Tue, 12 Dec 2017 09:42:03 -0800 Subject: [PATCH] Remove spring-boot-security-tests module Closes gh-11321 --- .../spring-boot-integration-tests/pom.xml | 1 - .../spring-boot-security-tests/pom.xml | 19 ----- .../pom.xml | 36 --------- .../sample/HelloWebSecurityApplication.java | 38 --------- .../HelloWebSecurityApplicationTests.java | 78 ------------------- 5 files changed, 172 deletions(-) delete mode 100644 spring-boot-tests/spring-boot-integration-tests/spring-boot-security-tests/pom.xml delete mode 100644 spring-boot-tests/spring-boot-integration-tests/spring-boot-security-tests/spring-boot-security-test-web-helloworld/pom.xml delete mode 100644 spring-boot-tests/spring-boot-integration-tests/spring-boot-security-tests/spring-boot-security-test-web-helloworld/src/main/java/sample/HelloWebSecurityApplication.java delete mode 100644 spring-boot-tests/spring-boot-integration-tests/spring-boot-security-tests/spring-boot-security-test-web-helloworld/src/test/java/sample/HelloWebSecurityApplicationTests.java diff --git a/spring-boot-tests/spring-boot-integration-tests/pom.xml b/spring-boot-tests/spring-boot-integration-tests/pom.xml index dc0e7fddb5b..3d63ecc7d6d 100644 --- a/spring-boot-tests/spring-boot-integration-tests/pom.xml +++ b/spring-boot-tests/spring-boot-integration-tests/pom.xml @@ -19,7 +19,6 @@ spring-boot-devtools-tests spring-boot-server-tests spring-boot-launch-script-tests - spring-boot-security-tests diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-security-tests/pom.xml b/spring-boot-tests/spring-boot-integration-tests/spring-boot-security-tests/pom.xml deleted file mode 100644 index 0190e6323a7..00000000000 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-security-tests/pom.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-integration-tests - ${revision} - - spring-boot-security-tests - pom - Spring Boot Security Tests - ${project.name} - - ${basedir}/../../.. - - - spring-boot-security-test-web-helloworld - - diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-security-tests/spring-boot-security-test-web-helloworld/pom.xml b/spring-boot-tests/spring-boot-integration-tests/spring-boot-security-tests/spring-boot-security-test-web-helloworld/pom.xml deleted file mode 100644 index b5b68b716c3..00000000000 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-security-tests/spring-boot-security-test-web-helloworld/pom.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-security-tests - ${revision} - ../ - - spring-boot-security-test-web-helloworld - Spring Boot Security Tests - Web Hello World - ${project.name} - - ${basedir}/../../../.. - - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-security - - - org.springframework.boot - spring-boot-starter-test - test - - - diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-security-tests/spring-boot-security-test-web-helloworld/src/main/java/sample/HelloWebSecurityApplication.java b/spring-boot-tests/spring-boot-integration-tests/spring-boot-security-tests/spring-boot-security-test-web-helloworld/src/main/java/sample/HelloWebSecurityApplication.java deleted file mode 100644 index e120a7856c4..00000000000 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-security-tests/spring-boot-security-test-web-helloworld/src/main/java/sample/HelloWebSecurityApplication.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2012-2017 the original author or authors. - * - * Licensed 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 sample; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.security.core.userdetails.User; -import org.springframework.security.provisioning.InMemoryUserDetailsManager; - -@SpringBootApplication -public class HelloWebSecurityApplication { - - @Bean - public InMemoryUserDetailsManager inMemoryUserDetailsManager() { - return new InMemoryUserDetailsManager(User.withDefaultPasswordEncoder() - .username("user").password("password").roles("USER").build()); - } - - public static void main(String[] args) { - SpringApplication.run(HelloWebSecurityApplication.class, args); - } - -} diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-security-tests/spring-boot-security-test-web-helloworld/src/test/java/sample/HelloWebSecurityApplicationTests.java b/spring-boot-tests/spring-boot-integration-tests/spring-boot-security-tests/spring-boot-security-test-web-helloworld/src/test/java/sample/HelloWebSecurityApplicationTests.java deleted file mode 100644 index 616073a65af..00000000000 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-security-tests/spring-boot-security-test-web-helloworld/src/test/java/sample/HelloWebSecurityApplicationTests.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2012-2017 the original author or authors. - * - * Licensed 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 sample; - -import java.nio.charset.StandardCharsets; -import java.util.Base64; - -import javax.servlet.http.HttpServletResponse; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.mock.web.MockFilterChain; -import org.springframework.mock.web.MockHttpServletRequest; -import org.springframework.mock.web.MockHttpServletResponse; -import org.springframework.security.web.FilterChainProxy; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.assertj.core.api.Assertions.assertThat; - -@RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -public class HelloWebSecurityApplicationTests { - - @Autowired - private FilterChainProxy springSecurityFilterChain; - - private MockHttpServletRequest request; - - private MockHttpServletResponse response; - - private MockFilterChain chain; - - @Before - public void setup() { - this.request = new MockHttpServletRequest(); - this.response = new MockHttpServletResponse(); - this.chain = new MockFilterChain(); - } - - @Test - public void requiresAuthentication() throws Exception { - this.request.addHeader("Accept", "application/json"); - this.springSecurityFilterChain.doFilter(this.request, this.response, this.chain); - assertThat(this.response.getStatus()) - .isEqualTo(HttpServletResponse.SC_UNAUTHORIZED); - } - - @Test - public void userAuthenticates() throws Exception { - this.request.addHeader("Accept", "application/json"); - this.request.addHeader("Authorization", "Basic " + new String( - Base64.getEncoder().encode("user:password".getBytes(StandardCharsets.UTF_8)))); - - this.springSecurityFilterChain.doFilter(this.request, this.response, this.chain); - - assertThat(this.response.getStatus()).isEqualTo(HttpServletResponse.SC_OK); - } - -}