Guest User

Untitled

a guest
Dec 16th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. @Test
  2. @WithMockUser(username="user@example.com", password="Test@777", roles="Manager")
  3. public void getDataSuccess() throws Exception {
  4.  
  5. mockMvc.perform(get("URL" ))
  6. .andDo(print())
  7. .andExpect(status().isInternalServerError());
  8. }
  9.  
  10. MyUser user = (MyUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
  11. Long uId = Long.valueOf(user.getId());
  12.  
  13. import org.springframework.security.core.GrantedAuthority;
  14. import org.springframework.security.core.userdetails.UserDetails;
  15.  
  16. public class MyUser implements UserDetails {
  17.  
  18. // properties
  19.  
  20. public MyUser ( MyJwtUserDetails userDetails , String userToken , Collection<? extends GrantedAuthority> authorities) {
  21. this..
  22. }
  23.  
  24. java.lang.ClassCastException: org.springframework.security.core.userdetails.User cannot be cast to com.example.MyUser
Add Comment
Please, Sign In to add comment