设为首页 - 加入收藏 ASP站长网(Aspzz.Cn)- 科技、建站、经验、云计算、5G、大数据,站长网!
热搜: 创业者 数据 手机
当前位置: 首页 > 服务器 > 搭建环境 > Windows > 正文

身份验证 – 向Microsoft.Owin.Testing.TestServer验证请求

发布时间:2020-12-30 20:55 所属栏目:117 来源:网络整理
导读:我正在使用owin TestServer类单元测试我的web api.除了我不确定如何验证请求之外,它的工作非常好,所以我不能真正测试需要身份验证的端点,而不是确保未经身份验证的请求是未经授权的. 我正在将WebApi配置为仅使用承载令牌验证,如下所示: // Web API configur

我正在使用owin TestServer类单元测试我的web api.除了我不确定如何验证请求之外,它的工作非常好,所以我不能真正测试需要身份验证的端点,而不是确保未经身份验证的请求是未经授权的.

我正在将WebApi配置为仅使用承载令牌验证,如下所示:

// Web API configuration and services
// Configure Web API to use only bearer token authentication.
config.SuppressDefaultHostAuthentication();
config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

任何想法,我怎么能这样容易吗

我发现使用TestServer OAuth身份验证的有用的文档
http://www.aaron-powell.com/posts/2014-01-12-integration-testing-katana-with-auth.html

他还在GitHub上提供整个VS解决方案.
https://github.com/aaronpowell/Owin.AuthenticatedTests/tree/a154931dd82e5180daf7163c2129f3a90401df55

(编辑:ASP站长网)

    网友评论
    推荐文章
      热点阅读