-
-
Notifications
You must be signed in to change notification settings - Fork 679
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add JWK support for HMAC and RSA keys
- Loading branch information
1 parent
dac1dba
commit 41c24b2
Showing
6 changed files
with
247 additions
and
22 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
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
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,28 @@ | ||
from jwt.utils import from_base64url_uint, to_base64url_uint | ||
|
||
import pytest | ||
|
||
|
||
@pytest.mark.parametrize("inputval,expected", [ | ||
(0, b'AA'), | ||
(1, b'AQ'), | ||
(255, b'_w'), | ||
(65537, b'AQAB'), | ||
(123456789, b'B1vNFQ'), | ||
pytest.mark.xfail((-1, ''), raises=ValueError) | ||
]) | ||
def test_to_base64url_uint(inputval, expected): | ||
actual = to_base64url_uint(inputval) | ||
assert actual == expected | ||
|
||
|
||
@pytest.mark.parametrize("inputval,expected", [ | ||
(b'AA', 0), | ||
(b'AQ', 1), | ||
(b'_w', 255), | ||
(b'AQAB', 65537), | ||
(b'B1vNFQ', 123456789, ), | ||
]) | ||
def test_from_base64url_uint(inputval, expected): | ||
actual = from_base64url_uint(inputval) | ||
assert actual == expected |