0
0
Postmantesting~20 mins

Why auth testing secures APIs in Postman - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
API Auth Testing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why is authentication testing important for API security?

Authentication testing ensures that only valid users can access the API. What is the main reason this protects the API?

AIt speeds up the API response time by caching user data.
BIt prevents unauthorized users from accessing sensitive data or functions.
CIt automatically fixes bugs in the API code.
DIt allows anyone to use the API without restrictions.
Attempts:
2 left
💡 Hint

Think about what happens if someone who shouldn't access the API tries to do so.

Predict Output
intermediate
2:00remaining
What is the result of this Postman test script?

Given this Postman test script that checks for a valid token in the response header, what will be the test result?

Postman
pm.test('Token is present', function () {
    pm.response.to.have.header('Authorization');
});
ATest passes if the response includes an 'Authorization' header.
BTest passes only if the response body contains the word 'token'.
CTest fails if the response includes an 'Authorization' header.
DTest fails if the response status code is 200.
Attempts:
2 left
💡 Hint

Look at what the test is checking in the response.

assertion
advanced
2:00remaining
Which assertion correctly verifies a 401 Unauthorized status in Postman?

You want to confirm that an API returns a 401 status code when authentication fails. Which assertion is correct?

Apm.test('Status is 401', () => pm.response.to.have.status(401));
Bpm.test('Status is 401', () => pm.response.status === 401);
Cpm.test('Status is 401', () => pm.response.statusCode === '401');
Dpm.test('Status is 401', () => pm.response.statusCode == 401);
Attempts:
2 left
💡 Hint

Check the Postman syntax for status code assertions.

🔧 Debug
advanced
2:00remaining
Why does this Postman test fail to detect missing token?

Consider this test script meant to check if the 'Authorization' header is missing. Why does it fail even when the header is absent?

Postman
pm.test('Authorization header missing', function () {
    pm.expect(pm.response.headers.get('Authorization')).to.not.be.null;
});
AThe test should check for undefined instead of null.
BThe method headers.get() is incorrect and causes an error.
CThe test expects the header to NOT be null, so it fails when header is missing.
DThe test is missing a semicolon causing a syntax error.
Attempts:
2 left
💡 Hint

Look carefully at what the test expects about the header's presence.

framework
expert
3:00remaining
Which Postman test script correctly validates a JWT token format in the response header?

You want to verify that the 'Authorization' header contains a JWT token with three parts separated by dots. Which script correctly tests this?

A
pm.test('JWT token format', () => {
  const token = pm.response.headers.get('Authorization');
  pm.expect(token.split('.').length).to.eql(2);
});
B
pm.test('JWT token format', () => {
  const token = pm.response.headers.get('Authorization');
  pm.expect(token.includes('.')).to.be.true;
});
C
pm.test('JWT token format', () => {
  const token = pm.response.headers.get('Authorization');
  pm.expect(token.length).to.be.above(10);
});
D
pm.test('JWT token format', () => {
  const token = pm.response.headers.get('Authorization');
  pm.expect(token.split('.').length).to.eql(3);
});
Attempts:
2 left
💡 Hint

JWT tokens have three parts separated by two dots.