Skip to content

Commit

Permalink
Update README.MD
Browse files Browse the repository at this point in the history
  • Loading branch information
ch4mpy authored Nov 26, 2024
1 parent 60facc0 commit d49c256
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ Proxy configuration is applied by default to REST clients as soon as the `HTTP_P

## Unit & Integration Testing With Security

Testing access control requires configuring the test security context. The `MockMvc` request post-processors and `WebTestClient` mutators provided by `spring-security-test` work only in the context of a request, which limits its usage to controllers. **To test any type of `@Component`** (`@Controller`, of course, but also `@Service` and `@Repository`) there are only two options:
Testing access control requires configuring the test security context with a fine-tuned `Authentication` instance.

For that, `spring-security-test` provides `MockMvc` request post-processors and `WebTestClient` mutators, but it can work only in the context of a request, which limits its usage to controllers. **To test any type of `@Component`** (`@Controller`, of course, but also `@Service` and `@Repository`) there are only two options:
- build tests security context by ourself and populate it with stubbed / mocked authentications :cry:
- **use annotations** to do it for us (this is where [spring-addons-oauth2-test](https://github.com/ch4mpy/spring-addons/tree/master/spring-addons-oauth2-test) jumps in) :smiley:

Expand Down

0 comments on commit d49c256

Please sign in to comment.