Bird
0
0

A developer wrote this code snippet to revoke an API key:

medium📝 Analysis Q14 of 15
Microservices - Authentication and Authorization
A developer wrote this code snippet to revoke an API key:
function revokeKey(key) {
  if key in activeKeys:
    activeKeys.remove(key)
  else:
    print('Key not found')
}
But the key is still accepted after revocation. What is the likely issue?
AThe remove method does not delete keys properly
BThe key is not removed from the validKeys list used for validation
CThe function does not print 'Key revoked' message
DThe key is being re-added automatically elsewhere
Step-by-Step Solution
Solution:
  1. Step 1: Understand key revocation logic

    The function removes the key from activeKeys, but validation likely checks validKeys.
  2. Step 2: Identify mismatch in key storage

    If validation uses validKeys and revoke removes from activeKeys, the key remains valid.
  3. Final Answer:

    The key is not removed from the validKeys list used for validation -> Option B
  4. Quick Check:

    Revocation must remove key from validation list [OK]
Quick Trick: Revoking must remove key from validation store [OK]
Common Mistakes:
MISTAKES
  • Removing key from wrong list
  • Assuming print messages affect logic
  • Ignoring other code re-adding keys

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Microservices Quizzes