We switched to Spring Mock MVC but still didn't get this working. I am
pretty sure it works in Spring 4 but we are on 3.2 (see
http://spring.io/blog/2014/05/23/preview-spring-security-test-web-security).
We ended up side-stepping the issue by creating our own domain-specific
permissioning abstraction which is injected into our Spring MVC controllers.
- Nathan
> thrownewAccessDeniedException("User is not authenticated yet");
> }
> CustomUserDetailsuserDetails
> =(CustomUserDetails)authentication.getPrincipal();
> UserSessionInfouserInfo =newUserSessionInfo();
> userInfo.setUserName(userDetails.getUsername());
> returnuserInfo;
> }
>
> }
>
> |
>
> The JUnit test class is:
>
> |
> publicclassSessionControllerTest{
>
> privateSessionControllersessionController;
>
> @Before
> publicvoidsetUp(){
> sessionController =newSessionController();
> }
>
> @Test
> publicvoidtest(){
> given().
> standaloneSetup(sessionController).
> auth().principal(newUser("username","password")).
> when().
> get("/session").
> then().
> statusCode(200).
> body("username",equalTo("username"));
> }
>
> }
> |
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "REST assured" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to
rest-assured...@googlegroups.com
> <mailto:
rest-assured...@googlegroups.com>.
> --
> You received this message because you are subscribed to the Google
> Groups "REST assured" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
rest-assured...@googlegroups.com
> <mailto:
rest-assured...@googlegroups.com>.