测试中的ServiceStack身份验证 [英] ServiceStack authentication in tests

查看:84
本文介绍了测试中的ServiceStack身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够使用基本身份验证或凭据身份验证来测试我的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆