I am creating a two test case one of them validates the OK message in response with valid Authentication token and the other validates Unauthorized message with the invalid/missing token.
In first test case the valid Authentication token is provided (as header) which passes the test case. But when I created second test case with missing token it still got passed even though I did not provide any token there. How it is getting passed without the token.
I have already tried request.AddorUpdateParameter, it did not work.
Test Case I
RestClient client = new RestClient(clientName);
RestRequest request = new RestRequest("Products", Method.GET);
request.AddParameter(Common.AuthenticationKey, Common.AuthenticationValue);
IRestResponse response = client.Execute(request);
Test Case II
RestClient client = new RestClient(clientName);
RestRequest request = new RestRequest("Products", Method.GET);
IRestResponse response = client.Execute(request);
It still gives me OK status. It is taking reference of the first test case request?
The second test case should fail since authentication token is not provided.
添加您自己的标头应该覆盖所有现有标头,因此添加"Accept","*"
或类似内容应该可以解决问题
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.