0
0
Postmantesting~10 mins

Inheriting auth from collection in Postman - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set the request to inherit authentication from the collection.

Postman
pm.request.auth = [1];
Drag options to blanks, or click blank then click option'
Apm.request.auth.inheritFromCollection()
Bpm.request.auth = null
C{ type: 'inherit' }
D{ type: 'noauth' }
Attempts:
3 left
💡 Hint
Common Mistakes
Using null instead of the inherit object
Trying to call a non-existent function inheritFromCollection
Setting auth type to 'noauth' which disables authentication
2fill in blank
medium

Complete the code to check if the current request is inheriting auth from the collection.

Postman
if (pm.request.auth && pm.request.auth.type === [1]) {
    console.log('Inheriting auth');
}
Drag options to blanks, or click blank then click option'
A'noauth'
B'basic'
C'apikey'
D'inherit'
Attempts:
3 left
💡 Hint
Common Mistakes
Checking for 'noauth' which means no authentication
Using 'apikey' or 'basic' which are specific auth types
3fill in blank
hard

Fix the error in the code to correctly inherit auth from the collection.

Postman
pm.request.auth = [1];
// Incorrect: pm.request.auth = 'inherit';
Drag options to blanks, or click blank then click option'
A{ type: 'inherit' }
B'inherit'
Cnull
D{ type: 'noauth' }
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning a string instead of an object
Using null which disables auth
Using 'noauth' which disables auth
4fill in blank
hard

Fill both blanks to set the request to inherit auth and then verify it.

Postman
pm.request.auth = [1];
if (pm.request.auth.type === [2]) {
    console.log('Auth inherited');
}
Drag options to blanks, or click blank then click option'
A{ type: 'inherit' }
B'inherit'
C'noauth'
D{ type: 'noauth' }
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing object and string types
Checking for 'noauth' instead of 'inherit'
5fill in blank
hard

Fill all three blanks to set inheritance, check type, and log a message.

Postman
pm.request.auth = [1];
if (pm.request.auth.type === [2]) {
    console.log([3]);
}
Drag options to blanks, or click blank then click option'
A{ type: 'inherit' }
B'inherit'
C'Authentication inherited successfully'
D'Auth disabled'
Attempts:
3 left
💡 Hint
Common Mistakes
Logging the wrong message
Using wrong auth type or object
Confusing 'noauth' with 'inherit'