How to disable Spring Security on Tests for Webflux Functional Endpoints
Asked Answered
G

1

5

I would like to disable security on endpoints during some unit tests. I am using webflux functional endpoints so the below configuration does not work.

@AutoConfigureMockMvc(secure = false)

I desactivated it by using profiles, but that means I cannot test security with test profile anymore. Is there another way to do it with webflux ?

Thanks in advance for your helps

Griselgriselda answered 28/4, 2020 at 10:38 Comment(3)
have a look at #23894510Dumbhead
can you post your endpoint and the mockmvc test you are trying to test against. Also the version of spring that you are using. It not very clear what you are trying to achieve. After spring boot 2.2 disabling spring security with secure=false in MockMvc is not even an optionMetamorphosis
@Metamorphosis I am not using mockMvc, as stated in the question I am using webflux, so a @WebFluxTest config and A WebTestClientResponsive
M
9

you can add :

@WebFluxTest(controllers = XXXX , excludeAutoConfiguration = {ReactiveSecurityAutoConfiguration.class})

Mimir answered 15/11, 2020 at 23:6 Comment(3)
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From ReviewStormy
@ChathurangaChandrasekara: You may want to review this post regarding low quality answers. Code only answers that make a sincere attempt to answer the question are, in fact, answers and should not be deleted.Bertrand
That said, @meriam, please edit your answer to provide more explanation. Remember, we're not just here to the answer specific, narrow question that the OP asked, but to help developers with very similar problems solve their problems. By offering explanation, you help developers understand not just the what but also the why. Will you kindly edit your answer to provide that?Bertrand

© 2022 - 2024 — McMap. All rights reserved.