0
0
Postmantesting~10 mins

Basic authentication in Postman - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test sends a request with Basic Authentication headers to verify the server accepts valid credentials and returns a successful response.

Test Code - Postman
Postman
pm.test("Status code is 200", function () {
    pm.response.to.have.status(200);
});

pm.test("Response contains authenticated user info", function () {
    const jsonData = pm.response.json();
    pm.expect(jsonData).to.have.property('authenticated', true);
});
Execution Trace - 7 Steps
StepActionSystem StateAssertionResult
1Test startsPostman is ready to send the request-PASS
2Postman sends HTTP GET request with Basic Auth header (username and password encoded in header)Request is sent to the server endpoint requiring Basic Authentication-PASS
3Server receives request and validates Basic Auth credentialsServer checks Authorization header for correct username and password-PASS
4Server responds with HTTP 200 status and JSON body indicating authentication successResponse contains status 200 and JSON {"authenticated": true}Check response status is 200PASS
5Postman test script runs assertion to verify status code is 200Response status code is 200pm.response.to.have.status(200)PASS
6Postman test script runs assertion to verify response JSON has property 'authenticated' set to trueResponse JSON contains {"authenticated": true}pm.expect(jsonData).to.have.property('authenticated', true)PASS
7Test ends with all assertions passingTest report shows pass for all checks-PASS
Failure Scenario
Failing Condition: Incorrect or missing Basic Auth credentials cause server to reject request
Execution Trace Quiz - 3 Questions
Test your understanding
What does the test verify after sending the request?
AThe server returns status 200 and confirms authentication
BThe server returns status 404 for missing page
CThe server returns status 500 due to error
DThe server ignores the Authorization header
Key Result
Always verify that authentication credentials are correctly set and encoded in your test requests to avoid false failures.