Spring Boot 1.4 testing with Security enabled? : <p>I'm wondering how I should go about authenticating a user for my tests? As it stands now all tests I will write will fail because the endpoints require authorization.</p>

<p>Test code:</p>

<pre><code>@RunWith(SpringRunner.class)
@WebMvcTest(value = PostController.class)
public class PostControllerTest {

    @Autowired
    private MockMvc mvc;

    @MockBean
    private PostService postService;

    @Test
    public void testHome() throws Exception {
        this.mvc.perform(get("/")).andExpect(status().isOk()).andExpect(view().name("posts"));
    }


}
</code></pre>

<p>One solution I found is to disable it by setting secure to false in @WebMvcTest. But that's not what I'm trying to do.</p>

<p>Any ideas?</p>
