parent
5f7e3d3952
commit
72d50ed2f8
|
@ -2527,7 +2527,7 @@ howto.spring-mvc.customize-view-resolvers
|
|||
|
||||
# 2 == Testing With Spring Security
|
||||
howto-use-test-with-spring-security=\
|
||||
howto.testing-with-spring-security
|
||||
howto.spring-mvc.testing.with-spring-security
|
||||
|
||||
# 2 == Jersey
|
||||
howto-jersey=\
|
||||
|
|
|
@ -404,7 +404,7 @@ If you define your own `webDriver` scope you may find it stops working when you
|
|||
|
||||
If you have Spring Security on the classpath, `@WebMvcTest` will also scan `WebSecurityConfigurer` beans.
|
||||
Instead of disabling security completely for such tests, you can use Spring Security's test support.
|
||||
More details on how to use Spring Security's `MockMvc` support can be found in this _<<howto#howto.testing-with-spring-security>>_ how-to section.
|
||||
More details on how to use Spring Security's `MockMvc` support can be found in this _<<howto#howto.testing.with-spring-security>>_ how-to section.
|
||||
|
||||
TIP: Sometimes writing Spring MVC tests is not enough; Spring Boot can help you run <<features#features.testing.spring-boot-applications.with-running-server, full end-to-end tests with an actual server>>.
|
||||
|
||||
|
|
|
@ -23,8 +23,6 @@ include::howto/webserver.adoc[]
|
|||
|
||||
include::howto/spring-mvc.adoc[]
|
||||
|
||||
include::howto/testing-with-spring-security.adoc[]
|
||||
|
||||
include::howto/jersey.adoc[]
|
||||
|
||||
include::howto/http-clients.adoc[]
|
||||
|
@ -45,6 +43,8 @@ include::howto/security.adoc[]
|
|||
|
||||
include::howto/hotswapping.adoc[]
|
||||
|
||||
include::howto/testing.adoc[]
|
||||
|
||||
include::howto/build.adoc[]
|
||||
|
||||
include::howto/traditional-deployment.adoc[]
|
||||
|
|
|
@ -1,11 +1,18 @@
|
|||
[[howto.testing-with-spring-security]]
|
||||
== Testing With Spring Security
|
||||
[[howto.testing]]
|
||||
== Testing
|
||||
Spring Boot includes a number of testing utilities and support classes as well as a dedicated starter that provides common test dependencies.
|
||||
This section answers common questions about testing.
|
||||
|
||||
|
||||
|
||||
[[howto.testing.with-spring-security]]
|
||||
=== Testing With Spring Security
|
||||
Spring Security provides support for running tests as a specific user.
|
||||
For example, the test in the snippet below will run with an authenticated user that has the `ADMIN` role.
|
||||
|
||||
[source,java,indent=0,subs="verbatim"]
|
||||
----
|
||||
include::{docs-java}/howto/testingwithspringsecurity/MySecurityTests.java[]
|
||||
include::{docs-java}/howto/testing/withspringsecurity/MySecurityTests.java[]
|
||||
----
|
||||
|
||||
Spring Security provides comprehensive integration with Spring MVC Test and this can also be used when testing controllers using the `@WebMvcTest` slice and `MockMvc`.
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.docs.howto.testingwithspringsecurity;
|
||||
package org.springframework.boot.docs.howto.testing.withspringsecurity;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.docs.howto.testingwithspringsecurity;
|
||||
package org.springframework.boot.docs.howto.testing.withspringsecurity;
|
||||
|
||||
class UserController {
|
||||
|
Loading…
Reference in New Issue