且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

测试中的ServiceStack身份验证

更新时间:2023-12-04 21:19:22

对于测试,我建议使用Config.AdminAuthSecret指定特殊字符串,以使您无需通过在查询字符串中添加?authsecret=xxx即可登录,而无需登录即可获得管理员访问权限./p>

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?

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.