Play securesocial - developer environment and unit testing

主宰稳场 提交于 2019-12-06 06:46:59

问题


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:


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.



来源:https://stackoverflow.com/questions/16244541/play-securesocial-developer-environment-and-unit-testing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!