-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
92 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from tests import unittest | ||
|
||
from msal import oauth2cli | ||
|
||
|
||
class TestIdToken(unittest.TestCase): | ||
|
||
EXPIRED_ID_TOKEN = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJPbmxpbmUgSldUIEJ1aWxkZXIiLCJpYXQiOjE3MzE3NDE1MDUsImV4cCI6MTcwNTMwMzEwNSwiYXVkIjoid3d3LmV4YW1wbGUuY29tIiwic3ViIjoiYWJjZDEyMzQiLCJHaXZlbk5hbWUiOiJKb2huIiwiU3VybmFtZSI6IkRvZSIsIkVtYWlsIjoiam9obmRvZUBleGFtcGxlLmNvbSJ9.hsLO_xEImdyVrzwTSu8OYZrHToOyDyv2kDe6DQCmeWc" | ||
|
||
def test_id_token_should_tolerate_time_error(self): | ||
self.assertEqual(oauth2cli.oidc.decode_id_token(self.EXPIRED_ID_TOKEN), { | ||
"iss": "Online JWT Builder", | ||
"iat": 1731741505, # 2024-11-16 | ||
"exp": 1705303105, # 2024-01-15 | ||
"aud": "www.example.com", | ||
"sub": "abcd1234", | ||
"GivenName": "John", | ||
"Surname": "Doe", | ||
"Email": "johndoe@example.com" | ||
}, "id_token is decoded correctly, without raising exception") | ||
|
||
def test_id_token_should_error_out_on_client_id_error(self): | ||
with self.assertRaises(oauth2cli.oidc.IdTokenAudienceError): | ||
oauth2cli.oidc.decode_id_token(self.EXPIRED_ID_TOKEN, client_id="foo") | ||
|