ServiceStack authentication in tests

被刻印的时光 ゝ 提交于 2019-12-11 19:55:54

问题


I want to be able to test my Servicestack endpoints using basic or credentials auth but don't want to have to login for each test, save the ss-id and then use that to actually exercise the end point.

Ideally I would be able to create a user using something like (this already works using credentials auth) http://devapi.someapi.com/register?username=blah&password=test&x-http-method-override=POST

then actually hit a secured url with something like:

http://devapi.someapi.com/users/123?username=blah&password=test

Is there anything like this available?


回答1:


For testing I recommend using Config.AdminAuthSecret to specify a special string to give you admin access without having to login by adding ?authsecret=xxx to the query string.



来源:https://stackoverflow.com/questions/21533859/servicestack-authentication-in-tests

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