5 changed files with 138 additions and 3 deletions
@ -1 +1,3 @@
@@ -1 +1,3 @@
|
||||
org.springframework.security.config.annotation.web.WebSecurityConfigurer |
||||
org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer |
||||
org.springframework.security.web.SecurityFilterChain |
||||
|
||||
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
/* |
||||
* Copyright 2012-present 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 |
||||
* |
||||
* https://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 org.springframework.boot.security.test.autoconfigure.webmvc; |
||||
|
||||
import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; |
||||
import org.springframework.security.config.annotation.web.WebSecurityConfigurer; |
||||
import org.springframework.security.config.annotation.web.builders.WebSecurity; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
/** |
||||
* {@link WebSecurityConfigurer} used to test their inclusion in |
||||
* {@link WebMvcTest @WebMvcTest}. |
||||
* |
||||
* @author Andy Wilkinson |
||||
*/ |
||||
@Component |
||||
class ExampleWebSecurityConfigurer implements WebSecurityConfigurer<WebSecurity> { |
||||
|
||||
@Override |
||||
public void init(WebSecurity builder) { |
||||
} |
||||
|
||||
@Override |
||||
public void configure(WebSecurity builder) { |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
/* |
||||
* Copyright 2012-present 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 |
||||
* |
||||
* https://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 org.springframework.boot.security.test.autoconfigure.webmvc; |
||||
|
||||
import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; |
||||
import org.springframework.security.config.annotation.web.builders.WebSecurity; |
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
/** |
||||
* {@link WebSecurityCustomizer} used to test their inclusion in |
||||
* {@link WebMvcTest @WebMvcTest}. |
||||
* |
||||
* @author Andy Wilkinson |
||||
*/ |
||||
@Component |
||||
class ExampleWebSecurityCustomizer implements WebSecurityCustomizer { |
||||
|
||||
@Override |
||||
public void customize(WebSecurity web) { |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,57 @@
@@ -0,0 +1,57 @@
|
||||
/* |
||||
* Copyright 2012-present 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 |
||||
* |
||||
* https://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 org.springframework.boot.security.test.autoconfigure.webmvc; |
||||
|
||||
import org.junit.jupiter.api.Test; |
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.boot.test.context.assertj.AssertableApplicationContext; |
||||
import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest; |
||||
import org.springframework.context.ConfigurableApplicationContext; |
||||
import org.springframework.security.web.SecurityFilterChain; |
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat; |
||||
|
||||
/** |
||||
* Integration tests for SpringSecurity with {@link WebMvcTest @WebMvcTest}. |
||||
* |
||||
* @author Andy Wilkinson |
||||
*/ |
||||
@WebMvcTest |
||||
class SecurityWebMvcTestIntegrationTests { |
||||
|
||||
@Autowired |
||||
private ConfigurableApplicationContext context; |
||||
|
||||
@Test |
||||
void includesWebSecurityConfigurer() { |
||||
assertThat(AssertableApplicationContext.get(() -> this.context)) |
||||
.hasSingleBean(ExampleWebSecurityConfigurer.class); |
||||
} |
||||
|
||||
@Test |
||||
void includesWebSecurityCustomizer() { |
||||
assertThat(AssertableApplicationContext.get(() -> this.context)) |
||||
.hasSingleBean(ExampleWebSecurityCustomizer.class); |
||||
} |
||||
|
||||
@Test |
||||
void includesSecurityFilterChain() { |
||||
assertThat(AssertableApplicationContext.get(() -> this.context)).hasSingleBean(SecurityFilterChain.class); |
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue