diff --git a/.github/workflows/test-and-deploy.yml b/.github/workflows/test-and-deploy.yml index de29674a15..58be384898 100644 --- a/.github/workflows/test-and-deploy.yml +++ b/.github/workflows/test-and-deploy.yml @@ -38,8 +38,7 @@ jobs: - name: Install Dependencies run: | pip install virtualenv --upgrade - make install - make test-install + make install test-install - name: Run the tests run: make test-with-coverage diff --git a/tests/unit/jwt/test_access_token.py b/tests/unit/jwt/test_access_token.py index a1f8e0f898..d5d9d04ead 100644 --- a/tests/unit/jwt/test_access_token.py +++ b/tests/unit/jwt/test_access_token.py @@ -8,7 +8,6 @@ SyncGrant, VoiceGrant, VideoGrant, - ConversationsGrant, TaskRouterGrant, ChatGrant, PlaybackGrant, @@ -95,7 +94,7 @@ def test_identity(self): def test_conversations_grant(self): scat = AccessToken(ACCOUNT_SID, SIGNING_KEY_SID, 'secret') - scat.add_grant(ConversationsGrant(configuration_profile_sid='CP123')) + scat.add_grant(VoiceGrant(outgoing_application_sid='CP123')) token = scat.to_jwt() assert token is not None @@ -103,8 +102,10 @@ def test_conversations_grant(self): self._validate_claims(decoded_token.payload) assert 1 == len(decoded_token.payload['grants']) assert { - 'configuration_profile_sid': 'CP123' - } == decoded_token.payload['grants']['rtc'] + 'outgoing': { + 'application_sid': 'CP123' + } + } == decoded_token.payload['grants']['voice'] def test_video_grant(self): scat = AccessToken(ACCOUNT_SID, SIGNING_KEY_SID, 'secret') diff --git a/tests/unit/jwt/test_client_validation.py b/tests/unit/jwt/test_client_validation.py index 60c183fc8f..7acb234dcc 100644 --- a/tests/unit/jwt/test_client_validation.py +++ b/tests/unit/jwt/test_client_validation.py @@ -1,5 +1,5 @@ -import unittest import time +import unittest from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives.asymmetric import rsa @@ -11,7 +11,6 @@ ) from twilio.http.validation_client import ValidationPayload -from twilio.jwt import Jwt from twilio.jwt.validation import ClientValidationJwt @@ -231,12 +230,12 @@ def test_jwt_payload(self): jwt = ClientValidationJwt('AC123', 'SK123', 'CR123', 'secret', vp) - self.assertDictContainsSubset({ + self.assertEqual(jwt.payload, {**jwt.payload, **{ 'hrh': 'authorization;host', 'rqh': expected_hash, 'iss': 'SK123', 'sub': 'AC123', - }, jwt.payload) + }}) self.assertGreaterEqual(jwt.payload['exp'], time.time(), 'JWT exp is before now') self.assertLessEqual(jwt.payload['exp'], time.time() + 301, 'JWT exp is after now + 5mins') self.assertDictEqual({ @@ -268,12 +267,12 @@ def test_jwt_signing(self): jwt = ClientValidationJwt('AC123', 'SK123', 'CR123', private_key, vp) decoded = ClientValidationJwt.from_jwt(jwt.to_jwt(), public_key) - self.assertDictContainsSubset({ + self.assertEqual(decoded.payload, {**decoded.payload, **{ 'hrh': 'authorization;host', 'rqh': expected_hash, 'iss': 'SK123', 'sub': 'AC123', - }, decoded.payload) + }}) self.assertGreaterEqual(decoded.payload['exp'], time.time(), 'JWT exp is before now') self.assertLessEqual(decoded.payload['exp'], time.time() + 501, 'JWT exp is after now + 5m') self.assertDictEqual({ diff --git a/tests/unit/jwt/test_jwt.py b/tests/unit/jwt/test_jwt.py index eee05d61d9..e1d89394b6 100644 --- a/tests/unit/jwt/test_jwt.py +++ b/tests/unit/jwt/test_jwt.py @@ -203,11 +203,11 @@ def test_encode_decode(self): self.assertEqual(decoded_jwt.subject, 'hey') self.assertEqual(decoded_jwt.headers, {'typ': 'JWT', 'alg': 'HS256'}) - self.assertDictContainsSubset({ + self.assertEqual(decoded_jwt.payload, {**decoded_jwt.payload, **{ 'iss': 'issuer', 'sub': 'hey', 'sick': 'sick', - }, decoded_jwt.payload) + }}) def test_encode_decode_mismatched_algorithms(self): jwt = DummyJwt('secret_key', 'issuer', algorithm='HS512', subject='hey', payload={'sick': 'sick'}) diff --git a/tox.ini b/tox.ini index 92d4c5a158..3211fed626 100644 --- a/tox.ini +++ b/tox.ini @@ -1,9 +1,9 @@ [tox] -envlist = py3{6,7,8,9,10,11}, pypy +env_list = py3{6,7,8,9,10,11}, pypy skip_missing_interpreters = true [testenv] -deps= -r{toxinidir}/tests/requirements.txt -commands= - nosetests \ - [] +deps = -r{tox_root}/tests/requirements.txt +commands = + pytest \ + []