Class TestSecurityContextHolder
java.lang.Object
com.codename1.backend.test.TestSecurityContextHolder
Who the calling thread's tests are running as. WithMockUser sets it for a
test; a test that needs to change it part-way does so here.
TestSecurityContextHolder.setAuthentication(
UsernamePasswordAuthenticationToken.authenticated("ada", null, authorities));
While one is set, every request the thread sends through MockMvc is from
that authentication, and SecurityContextHolder on the thread holds it.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidRemoves what was put in place: the thread's tests run as nobody again.static SecurityContextThe context in place, or an empty one.static voidsetAuthentication(Authentication authentication) Putsauthenticationin place for this thread's tests.static voidsetContext(SecurityContext context) Putscontextin place for this thread's tests.
-
Method Details
-
getContext
The context in place, or an empty one. -
setContext
Putscontextin place for this thread's tests. -
setAuthentication
Putsauthenticationin place for this thread's tests. -
clearContext
public static void clearContext()Removes what was put in place: the thread's tests run as nobody again.
-