我尝试测试注入 UserPrincipal 的 mvcControllers 的访问权限:
restPockMockMvc .perform(get("/pocs").principal(authToken)) .andReturn();
这是我尝试测试的控制器的方法:
@PreAuthorize(value = "hasRole('AK_ADMIN')") @RequestMapping(method = RequestMethod.GET,produces = "application/json; charset=utf-8") public PagedResources collectionList(HttpServletRequest httpServletRequest){ ..... .......}
httpServletRequest.getUserPrincipal() 始终为空,而我注入 userPrincipal 但我不明白为什么......
欢迎您的帮助。谢谢