Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6641d0d

Browse files
committed
Add test coverage
1 parent 5cf6553 commit 6641d0d

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

auth0/v3/test/authentication/test_token_verifier.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ def test_passes_when_org_present_and_matches(self):
390390
audience=expectations['audience']
391391
)
392392
tv._clock = MOCKED_CLOCK
393-
tv.verify(token, organization='org_123')
393+
tv.verify(token, organization='org_123')
394394

395395
def test_fails_when_org_specified_but_not_present(self):
396396
token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhdXRoMHxzZGs0NThma3MiLCJhdWQiOiJ0b2tlbnMtdGVzdC0xMjMiLCJpc3MiOiJodHRwczovL3Rva2Vucy10ZXN0LmF1dGgwLmNvbS8iLCJleHAiOjE1ODc3NjUzNjEsImlhdCI6MTU4NzU5MjU2MX0.wotJnUdD5IfdZMewF_-BnHc0pI56uwzwr5qaSXvSu9w"
@@ -402,4 +402,22 @@ def test_fails_when_org_specified_but_not_(self):
402402

403403
def test_fails_when_org_specified_but_does_not_match(self):
404404
token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhdXRoMHxzZGs0NThma3MiLCJhdWQiOiJ0b2tlbnMtdGVzdC0xMjMiLCJvcmdfaWQiOiJvcmdfMTIzIiwiaXNzIjoiaHR0cHM6Ly90b2tlbnMtdGVzdC5hdXRoMC5jb20vIiwiZXhwIjoxNTg3NzY1MzYxLCJpYXQiOjE1ODc1OTI1NjF9.hjSPgJpg0Dn2z0giCdGqVLD5Kmqy_yMYlSkgwKD7ahQ"
405-
self.assert_fails_with_error(token, 'Organization (org_id) claim mismatch in the ID token; expected "org_abc", found "org_123"', signature_verifier=SymmetricSignatureVerifier(HMAC_SHARED_SECRET), organization='org_abc')
405+
self.assert_fails_with_error(token, 'Organization (org_id) claim mismatch in the ID token; expected "org_abc", found "org_123"', signature_verifier=SymmetricSignatureVerifier(HMAC_SHARED_SECRET), organization='org_abc')
406+
407+
def test_verify_returns_payload(self):
408+
token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhdXRoMHxzZGs0NThma3MiLCJhdWQiOiJ0b2tlbnMtdGVzdC0xMjMiLCJvcmdfaWQiOiJvcmdfMTIzIiwiaXNzIjoiaHR0cHM6Ly90b2tlbnMtdGVzdC5hdXRoMC5jb20vIiwiZXhwIjoxNTg3NzY1MzYxLCJpYXQiOjE1ODc1OTI1NjF9.hjSPgJpg0Dn2z0giCdGqVLD5Kmqy_yMYlSkgwKD7ahQ"
409+
sv = SymmetricSignatureVerifier(HMAC_SHARED_SECRET)
410+
tv = TokenVerifier(
411+
signature_verifier=sv,
412+
issuer=expectations['issuer'],
413+
audience=expectations['audience']
414+
)
415+
tv._clock = MOCKED_CLOCK
416+
response = tv.verify(token)
417+
self.assertIn('sub', response);
418+
self.assertIn('aud', response);
419+
self.assertIn('org_id', response);
420+
self.assertIn('iss', response);
421+
self.assertIn('exp', response);
422+
self.assertIn('iat', response);
423+
self.assertEqual('org_123', response['org_id'])

0 commit comments

Comments
 (0)