[英]Is there a way to delete a header of a request using RestSharp
我正在创建两个测试用例,其中一个用有效的Authentication令牌验证OK消息,另一个用无效/缺少的令牌验证Unauthorized消息。
在第一个测试用例中,提供了有效的身份验证令牌(作为标头),该令牌通过了测试用例。 但是,当我创建缺少令牌的第二个测试用例时,即使我在那里没有提供任何令牌,它仍然通过了。 没有令牌的传递方式。
我已经尝试过request.AddorUpdateParameter,它没有用。
测试案例一
RestClient client = new RestClient(clientName);
RestRequest request = new RestRequest("Products", Method.GET);
request.AddParameter(Common.AuthenticationKey, Common.AuthenticationValue);
IRestResponse response = client.Execute(request);
测试案例二
RestClient client = new RestClient(clientName);
RestRequest request = new RestRequest("Products", Method.GET);
IRestResponse response = client.Execute(request);
它仍然给我OK状态。 它正在参考第一个测试用例的请求?
第二个测试用例应该失败,因为未提供身份验证令牌。
添加您自己的标头应该覆盖所有现有标头,因此添加"Accept","*"
或类似内容应该可以解决问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.