Spring security authentication mockmvc not installed

I am writing a bunch of unit tests for some protected controllers. My controllers are looking for loggedInUser to do some things with the object viaSecurityContextHolder.getContext().getAuthentication().getPrincipal()

I am writing unit tests and wrote this to create an authenticated user:

Any ideas?

+3


source to share


1 answer


I was able to fix it with this mechanism:



@Test
    public void lsoStaffPanelIsRight() throws Exception {
 }

      

+2


source







All Articles