Skip to content

Commit

Permalink
Merge pull request #1829 from andrewwhitehead/upd/pyjwt
Browse files Browse the repository at this point in the history
Update pyjwt to 2.4
  • Loading branch information
swcurran committed Jun 21, 2022
2 parents 8421116 + 4356060 commit aefd95a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion aries_cloudagent/multitenant/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ async def create_auth_token(

jwt_payload["wallet_key"] = wallet_key

token = jwt.encode(jwt_payload, jwt_secret, algorithm="HS256").decode()
token = jwt.encode(jwt_payload, jwt_secret, algorithm="HS256")

# Store iat for verification later on
wallet_record.jwt_iat = iat
Expand Down
16 changes: 8 additions & 8 deletions aries_cloudagent/multitenant/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ async def test_create_auth_token_managed(self):

expected_token = jwt.encode(
{"wallet_id": wallet_record.wallet_id, "iat": iat}, "very_secret_jwt"
).decode()
)

with async_mock.patch.object(test_module, "datetime") as mock_datetime:
mock_datetime.utcnow.return_value = utc_now
Expand Down Expand Up @@ -459,7 +459,7 @@ async def test_create_auth_token_unmanaged(self):
"wallet_key": "test_key",
},
"very_secret_jwt",
).decode()
)

with async_mock.patch.object(test_module, "datetime") as mock_datetime:
mock_datetime.utcnow.return_value = utc_now
Expand All @@ -471,7 +471,7 @@ async def test_create_auth_token_unmanaged(self):
async def test_get_profile_for_token_invalid_token_raises(self):
self.profile.settings["multitenant.jwt_secret"] = "very_secret_jwt"

token = jwt.encode({"wallet_id": "test"}, "some_random_key").decode()
token = jwt.encode({"wallet_id": "test"}, "some_random_key")

with self.assertRaises(jwt.InvalidTokenError):
await self.manager.get_profile_for_token(self.profile.context, token)
Expand All @@ -486,7 +486,7 @@ async def test_get_profile_for_token_wallet_key_missing_raises(self):
await wallet_record.save(session)
token = jwt.encode(
{"wallet_id": wallet_record.wallet_id}, "very_secret_jwt", algorithm="HS256"
).decode()
)

with self.assertRaises(WalletKeyMissingError):
await self.manager.get_profile_for_token(self.profile.context, token)
Expand All @@ -503,7 +503,7 @@ async def test_get_profile_for_token_managed_wallet_no_iat(self):

token = jwt.encode(
{"wallet_id": wallet_record.wallet_id}, "very_secret_jwt", algorithm="HS256"
).decode()
)

with async_mock.patch.object(
BaseMultitenantManager, "get_wallet_profile"
Expand Down Expand Up @@ -540,7 +540,7 @@ async def test_get_profile_for_token_managed_wallet_iat(self):
{"wallet_id": wallet_record.wallet_id, "iat": iat},
"very_secret_jwt",
algorithm="HS256",
).decode()
)

with async_mock.patch.object(
BaseMultitenantManager, "get_wallet_profile"
Expand Down Expand Up @@ -578,7 +578,7 @@ async def test_get_profile_for_token_managed_wallet_x_iat_no_match(self):
{"wallet_id": wallet_record.wallet_id, "iat": 200},
"very_secret_jwt",
algorithm="HS256",
).decode()
)

with async_mock.patch.object(
BaseMultitenantManager, "get_wallet_profile"
Expand Down Expand Up @@ -614,7 +614,7 @@ async def test_get_profile_for_token_unmanaged_wallet(self):
{"wallet_id": wallet_record.wallet_id, "wallet_key": "wallet_key"},
"very_secret_jwt",
algorithm="HS256",
).decode()
)

with async_mock.patch.object(
BaseMultitenantManager, "get_wallet_profile"
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ packaging~=20.4
pyld~=2.0.3
pyyaml~=5.4.0
ConfigArgParse~=1.5.3
pyjwt~=1.7.1
pyjwt~=2.4.0
pydid~=0.3.3
jsonpath_ng==1.5.2
pytz~=2021.1
Expand Down

0 comments on commit aefd95a

Please sign in to comment.