-
Notifications
You must be signed in to change notification settings - Fork 141
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
1 parent
d236292
commit ed45f4e
Showing
2 changed files
with
27 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from okta.jwt import JWT | ||
import tests.mocks as mocks | ||
|
||
""" | ||
Testing JWT functions with different inputs | ||
""" | ||
|
||
|
||
def test_private_key_with_kid_in_private_key(mocker): | ||
mocked_encode = mocker.patch('jose.jwt.encode') | ||
JWT.create_token("test.com", "test-client-id", mocks.SAMPLE_JWK_WITH_KID) | ||
expected_kid = mocks.SAMPLE_JWK_WITH_KID["kid"] | ||
_, kwargs = mocked_encode.call_args | ||
mocked_encode.assert_called_once() | ||
assert "kid" in kwargs["headers"] | ||
assert kwargs["headers"]["kid"] == expected_kid | ||
|
||
|
||
def test_private_key_with_kid_in_config(mocker): | ||
mocked_encode = mocker.patch('jose.jwt.encode') | ||
expected_kid = "test-kid" | ||
JWT.create_token("test.com", "test-client-id", mocks.SAMPLE_JWK, kid=expected_kid) | ||
_, kwargs = mocked_encode.call_args | ||
mocked_encode.assert_called_once() | ||
assert "kid" in kwargs["headers"] | ||
assert kwargs["headers"]["kid"] == expected_kid |
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