Integration testing of secured controller spring security

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Integration testing of secured controller spring security

Vladimir Havenchyk
Hi, is there way to test secured access to controller from integration tests with spring security?

I have request map with secured url and role e.g. "/person/**", "ROLE_SUPER_ADMIN".

Now I want to test access for user with another role e.g. "ROLE_USER". Is it possible in integration tests or should I use functional tests instead?

I tried also something like

 SpringSecurityUtils.doWithAuth("superadmin") {
            controller.index()
 }

but there is not needed to use doWithAuth, because I have access to controller.index() without doWithAuth.

Thanks in advance.
Vladimir
Reply | Threaded
Open this post in threaded view
|

Re: Integration testing of secured controller spring security

burtbeckwith
You need functional tests. Integration tests start up most of Grails, but there's no running web server (the requests and responses are mocks) so the servlet filters that handle access control aren't there.

Burt

Vladimir Havenchyk wrote
Hi, is there way to test secured access to controller from integration tests with spring security?

I have request map with secured url and role e.g. "/person/**", "ROLE_SUPER_ADMIN".

Now I want to test access for user with another role e.g. "ROLE_USER". Is it possible in integration tests or should I use functional tests instead?

I tried also something like

 SpringSecurityUtils.doWithAuth("superadmin") {
            controller.index()
 }

but there is not needed to use doWithAuth, because I have access to controller.index() without doWithAuth.

Thanks in advance.
Vladimir
Reply | Threaded
Open this post in threaded view
|

Re: Integration testing of secured controller spring security

Vladimir Havenchyk
Thanks, Burt. Already found your talk from grech http://www.youtube.com/watch?v=RhdobAADx70
It's very helpful!