Play securesocial - developer environment and unit

2020-07-18 07:33发布

We are using securesocial module for authentication in Play 2 application.

I have two questions concerning this module.

Firstly, is there an easy way to disable the authorization checking in out development environment, preferably w/o commenting all @SecureSocial.SecuredAction annotations.

Secondly, what is the preferred way to unit test methods that use securesocial in Java? For example I have a call to ctx().args.get(SecureSocial.USER_KEY); in controller for getting the identity. If I would want to unit test this method, how can I mock out this identity? Or maybe secure social has some utility classes that can help unit testing?

1条回答
forever°为你锁心
2楼-- · 2020-07-18 07:48

We decided to create method getUser in our controller and then in unit-tests we are using http://www.javassist.org/ library to remove securesocial annotations and also to change return value of getUser to some mock that is created in test classes.

查看更多
登录 后发表回答