4

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

Özgün
  • 318
  • 3
  • 11
  • have a look at https://stackoverflow.com/questions/23894010/spring-boot-security-disable-security – Devilluminati Apr 28 '20 at 15:23
  • 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 option – gkc123 Apr 28 '20 at 23:47
  • @gkc123 I am not using mockMvc, as stated in the question I am using webflux, so a `@WebFluxTest` config and A WebTestClient – Özgün Apr 29 '20 at 09:48

1 Answers1

8

you can add :

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

Meriam
  • 181
  • 2
  • 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 Review](/review/low-quality-posts/27627043) – Chathuranga Chandrasekara Nov 15 '20 at 23:26
  • 2
    @ChathurangaChandrasekara: You may want to review [this post regarding low quality answers](https://meta.stackoverflow.com/questions/287563/youre-doing-it-wrong-a-plea-for-sanity-in-the-low-quality-posts-queue). Code only answers that make a sincere attempt to answer the question are, in fact, answers and should not be deleted. – Jeremy Caney Nov 15 '20 at 23:41
  • 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? – Jeremy Caney Nov 15 '20 at 23:43