@WithUserDetails does not seem to work
<p>I have an application in which I use Spring Social Security for authentication and authorization. Unfortunately I am having some problems with mocking Spring Security. It seems that it does not work at all.</p>

<p>I have a REST controller that returns 404 Not Found if the identifier of the entity it should return is not available. If the user is not logged in then any page redirects to the social login page of my app.</p>

<p>I have read <a href="http://docs.spring.io/spring-security/site/docs/current/reference/html/test-method.html" rel="nofollow noreferrer">here</a> that the <code>@WithUserDetails</code> annotation would suit me the best.</p>

<p>So my test method looks like this</p>

<pre class="lang-java prettyprint-override"><code>@Test
@SqlGroup({
    @Sql(executionPhase = ExecutionPhase.BEFORE_TEST_METHOD, statements = "INSERT INTO UserAccount(id, creationtime, modificationtime, version, email, firstname, lastname, role, signinprovider) VALUES (1, '2008-08-08 20:08:08', '2008-08-08 20:08:08', 1, 'user', 'John', 'Doe', 'ROLE_USER', 'FACEBOOK')"), })
@Rollback
@WithUserDetails
public void ifNoTeamsInTheDatabaseThenTheRestControllerShouldReturnNotFoundHttpStatus() {
    ResponseEntity&lt;String&gt; response = restTemplate.getForEntity("/getTeamHistory/{team}", String.class, "Team");
    Assert.assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode());
}
</code></pre>

<p>But this does not seem to work at all. It looks like the test method is executed with anonymous user, because the status I get is 200 OK.</p>

<p>My test class is annotated like this</p>

<pre class="lang-java prettyprint-override"><code>@RunWith(SpringRunner.class)
@ActiveProfiles("dev")
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@Transactional
public class TeamRestControllerTest {
    //...
}
</code></pre>

<p>Has anyone ever experienced such an issue with mocking Spring Security that is delivered by Spring Social?</p>