我正在使用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));
Run Code Online (Sandbox Code Playgroud)
我有什么想法可以轻松地做到这一点?