Saved Bookmarks
| 1. |
How do you write test cases for basic authentication in Postman? |
|
Answer» Basic Authentication is one of the authentication techniques provided in Postman that ENSURES that we can set the username and password along with the API requests. We can do this by first setting the CREDENTIALS of the API by:
The test CASES can be WRITTEN as follows: pm.test("Is the Request Authenticated?", FUNCTION () { var jsonData = pm.response.json(); //if authenticated then assert to true pm.expect(jsonData.authenticated).to.eql(true); }); pm.test("Is the Content-Type present?", function () { pm.response.to.have.header("Content-Type"); }); pm.test("Is it a successful POST Request?", function () { pm.response.to.have.status(200); }); |
|