How to prevent NestedServletException when testing Spring endpoints?

前端 未结 3 1253
耶瑟儿~
耶瑟儿~ 2021-02-05 13:11

I am trying to test the security configuration of some of my endpoints which are secured with @PreAuthorize(#oauth2.hasScope(\'scope\'). When acces

3条回答
  •  伪装坚强ぢ
    2021-02-05 13:36

    I fixed it by adding an @ExceptionHandler for that exception. Seems like if MockMvc throws an actual exception it means you don't "handle" this case which is not ideal.

提交回复
热议问题