Skip to content

Commit

Permalink
Remove deprecation warning from IDTokenVerifier
Browse files Browse the repository at this point in the history
  • Loading branch information
serhiibuniak-okta authored Oct 28, 2021
1 parent b71735c commit e4e72d2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ python:
install:
- pip install -U -r requirements.txt
- pip install -U -r test_requirements.txt
- pip install -U flake8

script:
- echo "Running tests in job stages..."
Expand All @@ -28,4 +29,4 @@ jobs:
name: "Flake8 Check"
script:
- echo "Code Style check..."
- "flake8 okta_jwt_verifier/"
- "flake8 --extend-ignore=E501 okta_jwt_verifier/"
22 changes: 11 additions & 11 deletions okta_jwt_verifier/jwt_verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def __init__(self,
proxy=proxy)


class AccessTokenVerifier(BaseJWTVerifier):
class AccessTokenVerifier():
def __init__(self,
issuer=None,
audience='api://default',
Expand Down Expand Up @@ -339,16 +339,16 @@ def __init__(self,
leeway: int, amount of time to expand the window for token expiration (to work around clock skew)
cache_jwks: bool, optional
"""
self._jwt_verifier = JWTVerifier(issuer,
client_id,
audience,
request_executor,
max_retries,
request_timeout,
max_requests,
leeway,
cache_jwks,
proxy)
self._jwt_verifier = BaseJWTVerifier(issuer,
client_id,
audience,
request_executor,
max_retries,
request_timeout,
max_requests,
leeway,
cache_jwks,
proxy)

async def verify(self, token, claims_to_verify=('iss', 'exp'), nonce=None):
await self._jwt_verifier.verify_id_token(token, claims_to_verify, nonce)
21 changes: 21 additions & 0 deletions tests/unit/test_jwt_verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,24 @@ def test_verify_expiration(mocker):
def test_deprecation_warning():
with pytest.warns(DeprecationWarning):
jwt_verifier = JWTVerifier(issuer='https://test_issuer.com')


def test_no_deprecation_warning():
# there is no nice way to check it, so use workaround with try/except/else
try:
with pytest.warns(DeprecationWarning):
jwt_verifier = AccessTokenVerifier(issuer='https://test_issuer.com')
except:
# this means "no deprecation warning"
assert True
else:
assert False

try:
with pytest.warns(DeprecationWarning):
jwt_verifier = IDTokenVerifier(issuer='https://test_issuer.com')
except:
# this means "no deprecation warning"
assert True
else:
assert False

0 comments on commit e4e72d2

Please sign in to comment.