Linked Questions

8 votes
1 answer
18k views

Spring Boot: Disable security for Spring Boot Unit Test [duplicate]

Spring Boot version: 2.0.4.RELEASE For the Spring Boot Test below, the test returns an unwanted 401 response: "401" status, "error": "unauthorized" What is the best way to disable Spring Security ...
Jim Eadon's user avatar
6 votes
2 answers
19k views

Spring-Boot module based integration testing

I have a multi-module Spring-Boot project. I was wondering how I can set up integration testing just to test Spring Data JPA repositories? The following approach fails with this exception: HV000183: ...
led's user avatar
  • 633
7 votes
3 answers
3k views

Spring disable @EnableResourceServer

I have resource server, when it's starts - it's sending request to Authentication server ("http://localhost:xxxx/auth/oauth/token_key"), and it's okay when all up and running. But when I testing my ...
Evgenii's user avatar
  • 447
3 votes
1 answer
16k views

Why spring test is fail, does not work @MockBean

I try to create my first the test for a simple spring-boot controller but I get Handler: Type = null. In browser code is work but a test fails. My App use spring-security. Please help me fix it an ...
Pavel's user avatar
  • 2,121
4 votes
2 answers
13k views

MockBean doesn't work in Spring boot integration test

I have Spring Integration test where I'm trying to Mock some of my Beans. For some reason although I Mocked them they are NULL. Here is code snippet: The Bean which I want to Mock @Component public ...
Tsvetoslav Tsvetkov's user avatar
10 votes
1 answer
4k views

@WithMockUser doesn't work in Integration Test - Spring boot

I am still getting Access Denied although my test method is annotated with @WithMockUser. Why this is not working in integration test? Everything is fine with test with @WebAppConfiguration and ...
Mcmil's user avatar
  • 917
5 votes
4 answers
1k views

@DataJpaTest fails when using Eureka / Feign

I have the the following Spring Boot application (using Eureka and Feign): @SpringBootApplication @EnableFeignClients @EnableRabbit @EnableDiscoveryClient @EnableTransactionManagement(...
Alessandro Dionisi's user avatar
2 votes
0 answers
5k views

How to disable SpringSecurity in Junit Test class using spring boot

I have created simple Rest Api service using spring boot 2.2.5.RELEASE, I have just enabled Spring Security in the application. The JUnits are not working. I tried some of the ways to solve this issue ...
Akarsh Sinha's user avatar
3 votes
2 answers
3k views

How to disable security in integration tests in Spring Boot 2.2.0?

I need to disable spring-security in my integration test. I'm using Spring boot 2.2.0 and in this version, I didn't find some methods to do it. @EnableAutoConfiguration(exclude = {...
John's user avatar
  • 1,631
3 votes
0 answers
1k views

Spring Boot disable security for tests

I am trying to create a REST Api with Spring-Boot and I need to disable security for testing purposes. I want to be able to use PostMan without any security constrain. I have tried several ways but ...
user avatar
0 votes
1 answer
1k views

SpringBoot: WebMvcTest with authorization

I have a basic SpringBoot app. using Spring Initializer, embedded Tomcat, Thymeleaf template engine, and package as an executable JAR file. I have this test: @RunWith(SpringRunner.class) @...
Nunyet Calçada's user avatar
1 vote
2 answers
1k views

MockMvc testing controller not throwing exception

I am testing my AppUserController with MockMvc. Here is the case; If the user is not found then I expect a ResourceNotFoundException to be thrown. This is my test @Test void ...
Demir's user avatar
  • 859