测试中的ServiceStack身份验证 [英] ServiceStack authentication in tests
问题描述
我希望能够使用基本身份验证或凭据身份验证来测试我的Servicestack端点,但是不想每次登录都必须登录,保存ss-id,然后使用它来实际行使终点.
理想情况下,我可以使用类似方式创建用户(使用凭据身份验证已经可以使用此方式) http://devapi.someapi.com/users/123? username = blah& password = test
有没有类似的东西?
对于测试,我建议使用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.
这篇关于测试中的ServiceStack身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!