commit 6364dd38034cc6621c7d75957b8110261501bf0f Author: Robin H. Johnson Date: Tue Feb 7 16:15:31 2023 -0800 tox: update versions Signed-off-by: Robin H. Johnson :100644 100644 d725881 e81a210 M tox.ini diff --git a/tox.ini b/tox.ini index d725881..e81a210 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = flake8,py27,py34,py35,gae,cover +envlist = flake8,py27,py34,py35,py38,py39,py310,py311,gae,cover [testenv] basedeps = mock>=1.3.0 commit 5c636d31426a7ced72ad0c833c458f844934e2ab Author: Robin H. Johnson Date: Tue Feb 7 16:18:45 2023 -0800 Convert pycrypto -> pycryptodome Signed-off-by: Robin H. Johnson :100644 100644 433a833 936d092 M docs/requirements.txt :100644 100644 e81a210 885ed77 M tox.ini diff --git a/docs/requirements.txt b/docs/requirements.txt index 433a833..936d092 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -2,7 +2,7 @@ django flask keyring mock -pycrypto>=2.6 +pycryptodome>=2.6 pyopenssl>=0.14 python-gflags pyyaml diff --git a/tox.ini b/tox.ini index e81a210..885ed77 100644 --- a/tox.ini +++ b/tox.ini @@ -3,7 +3,7 @@ envlist = flake8,py27,py34,py35,py38,py39,py310,py311,gae,cover [testenv] basedeps = mock>=1.3.0 - pycrypto>=2.6 + pycryptodome>=2.6 cryptography>=1.0 pyopenssl>=0.14 webtest @@ -68,7 +68,7 @@ basepython = commands = {toxinidir}/scripts/run_system_tests.sh deps = - pycrypto>=2.6 + pycryptodome>=2.6 cryptography>=1.0 pyopenssl>=0.14 passenv = GOOGLE_* OAUTH2CLIENT_* TRAVIS* encrypted_* @@ -79,7 +79,7 @@ basepython = commands = {toxinidir}/scripts/run_system_tests.sh deps = - pycrypto>=2.6 + pycryptodome>=2.6 cryptography>=1.0 pyopenssl>=0.14 passenv = {[testenv:system-tests]passenv} @@ -90,7 +90,7 @@ basepython = commands = python {toxinidir}/scripts/run_gce_system_tests.py deps = - pycrypto>=2.6 + pycryptodome>=2.6 passenv = {[testenv:system-tests]passenv} [testenv:flake8] commit ec8f9dda65ee706e8816decdbc9a324ff5a38622 Author: Robin H. Johnson Date: Tue Feb 7 16:24:24 2023 -0800 xsrfutil: hmac.new now requires digestmod Signed-off-by: Robin H. Johnson Reference: https://docs.python.org/3/library/hmac.html#hmac.new :100644 100644 7c3ec03 20f35c9 M oauth2client/contrib/xsrfutil.py :100644 100644 3115827 86bef82 M tests/contrib/test_xsrfutil.py diff --git a/oauth2client/contrib/xsrfutil.py b/oauth2client/contrib/xsrfutil.py index 7c3ec03..20f35c9 100644 --- a/oauth2client/contrib/xsrfutil.py +++ b/oauth2client/contrib/xsrfutil.py @@ -44,7 +44,7 @@ def generate_token(key, user_id, action_id='', when=None): Returns: A string XSRF protection token. """ - digester = hmac.new(_helpers._to_bytes(key, encoding='utf-8')) + digester = hmac.new(_helpers._to_bytes(key, encoding='utf-8'), digestmod='MD5') digester.update(_helpers._to_bytes(str(user_id), encoding='utf-8')) digester.update(DELIMITER) digester.update(_helpers._to_bytes(action_id, encoding='utf-8')) diff --git a/tests/contrib/test_xsrfutil.py b/tests/contrib/test_xsrfutil.py index 3115827..86bef82 100644 --- a/tests/contrib/test_xsrfutil.py +++ b/tests/contrib/test_xsrfutil.py @@ -54,7 +54,8 @@ class Test_generate_token(unittest.TestCase): TEST_USER_ID_1, action_id=TEST_ACTION_ID_1, when=TEST_TIME) - hmac.new.assert_called_once_with(TEST_KEY) + hmac.new.assert_called_once_with(TEST_KEY, + digestmod='MD5') digester.digest.assert_called_once_with() expected_digest_calls = [ @@ -87,7 +88,8 @@ class Test_generate_token(unittest.TestCase): TEST_USER_ID_1, action_id=TEST_ACTION_ID_1) - hmac.new.assert_called_once_with(TEST_KEY) + hmac.new.assert_called_once_with(TEST_KEY, + digestmod='MD5') time.time.assert_called_once_with() digester.digest.assert_called_once_with() commit 6d7d5cffb5b87f183a734aeb9b9f5ea87af27a94 Author: Robin H. Johnson Date: Tue Feb 7 16:35:20 2023 -0800 oauth2client/_helpers: convert inspect.getargspec -> inspect.getfullargspec Signed-off-by: Robin H. Johnson Reference: https://docs.python.org/3.11/whatsnew/3.11.html#removed Reference: https://docs.python.org/3.10/library/inspect.html#module-inspect :100644 100644 e912397 5206682 M oauth2client/_helpers.py diff --git a/oauth2client/_helpers.py b/oauth2client/_helpers.py index e912397..5206682 100644 --- a/oauth2client/_helpers.py +++ b/oauth2client/_helpers.py @@ -136,7 +136,7 @@ def positional(max_positional_args): if isinstance(max_positional_args, six.integer_types): return positional_decorator else: - args, _, _, defaults = inspect.getargspec(max_positional_args) + args, _varargs, _varkw, defaults, _kwonlyargs, _kwonlydefaults, _annotations = inspect.getfullargspec(max_positional_args) return positional(len(args) - len(defaults))(max_positional_args) commit 3c86393d78596a988df38a8e4919365c8efaa186 Author: Robin H. Johnson Date: Tue Feb 7 16:39:58 2023 -0800 setup.py: update desc Signed-off-by: Robin H. Johnson :100644 100644 47d86b7 3ac28f4 M setup.py diff --git a/setup.py b/setup.py index 47d86b7..3ac28f4 100644 --- a/setup.py +++ b/setup.py @@ -70,6 +70,12 @@ setup( 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', 'Development Status :: 7 - Inactive', 'Intended Audience :: Developers', 'License :: OSI Approved :: Apache Software License', commit 72c4a5dd963800fa1b55298d9cd40d6a0bc6c086 Author: John Kelly Date: Tue Feb 15 18:04:18 2022 -0800 django 2 :100644 100644 644a8f9 f237741 M oauth2client/contrib/django_util/__init__.py :100644 100644 1835208 195a874 M oauth2client/contrib/django_util/views.py diff --git a/oauth2client/contrib/django_util/__init__.py b/oauth2client/contrib/django_util/__init__.py index 644a8f9..f237741 100644 --- a/oauth2client/contrib/django_util/__init__.py +++ b/oauth2client/contrib/django_util/__init__.py @@ -230,7 +230,7 @@ import importlib import django.conf from django.core import exceptions -from django.core import urlresolvers +import django.urls as urlresolvers from six.moves.urllib import parse from oauth2client import clientsecrets diff --git a/oauth2client/contrib/django_util/views.py b/oauth2client/contrib/django_util/views.py index 1835208..195a874 100644 --- a/oauth2client/contrib/django_util/views.py +++ b/oauth2client/contrib/django_util/views.py @@ -26,7 +26,7 @@ import os from django import http from django import shortcuts from django.conf import settings -from django.core import urlresolvers +import django.urls as urlresolvers from django.shortcuts import redirect from django.utils import html import jsonpickle commit 837358a565b511e9e640a788f7324585daa5237b Author: Robin H. Johnson Date: Tue Feb 7 16:48:31 2023 -0800 tests: update function names Signed-off-by: Robin H. Johnson :100644 100644 36d2713 9b67c8e M tests/contrib/appengine/test_appengine.py :100644 100644 1346080 381397f M tests/contrib/test_devshell.py :100644 100644 0f8090d 2a72c36 M tests/contrib/test_keyring_storage.py :100644 100644 18b7df4 34764d4 M tests/test_client.py :100644 100644 3fa9c30 360bacb M tests/test_clientsecrets.py :100644 100644 80324d6 f916e43 M tests/test_file.py :100644 100644 6756d49 62e64b9 M tests/test_service_account.py diff --git a/tests/contrib/appengine/test_appengine.py b/tests/contrib/appengine/test_appengine.py index 36d2713..9b67c8e 100644 --- a/tests/contrib/appengine/test_appengine.py +++ b/tests/contrib/appengine/test_appengine.py @@ -906,7 +906,7 @@ class DecoratorTests(unittest.TestCase): self.decorator = decorator self.test_required() http = self.decorator.http() - self.assertEquals('foo_access_token', + self.assertEqual('foo_access_token', http.request.credentials.access_token) # revoke_uri is not required diff --git a/tests/contrib/test_devshell.py b/tests/contrib/test_devshell.py index 1346080..381397f 100644 --- a/tests/contrib/test_devshell.py +++ b/tests/contrib/test_devshell.py @@ -205,7 +205,7 @@ class DevshellCredentialsTests(unittest.TestCase): def test_no_refresh_token(self): with _AuthReferenceServer(): creds = devshell.DevshellCredentials() - self.assertEquals(None, creds.refresh_token) + self.assertEqual(None, creds.refresh_token) @mock.patch('oauth2client.client._UTCNOW') def test_reads_credentials(self, utcnow): diff --git a/tests/contrib/test_keyring_storage.py b/tests/contrib/test_keyring_storage.py index 0f8090d..2a72c36 100644 --- a/tests/contrib/test_keyring_storage.py +++ b/tests/contrib/test_keyring_storage.py @@ -104,7 +104,7 @@ class KeyringStorageTests(unittest.TestCase): autospec=True) as get_password: store = keyring_storage.Storage('my_unit_test', 'me') credentials = store.get() - self.assertEquals(None, credentials) + self.assertEqual(None, credentials) get_password.assert_called_once_with('my_unit_test', 'me') def test_get_with_malformed_json_credentials_stored(self): @@ -113,7 +113,7 @@ class KeyringStorageTests(unittest.TestCase): autospec=True) as get_password: store = keyring_storage.Storage('my_unit_test', 'me') credentials = store.get() - self.assertEquals(None, credentials) + self.assertEqual(None, credentials) get_password.assert_called_once_with('my_unit_test', 'me') def test_get_and_set_with_json_credentials_stored(self): @@ -139,7 +139,7 @@ class KeyringStorageTests(unittest.TestCase): return_value=None, autospec=True) as set_password: store = keyring_storage.Storage('my_unit_test', 'me') - self.assertEquals(None, store.get()) + self.assertEqual(None, store.get()) store.put(credentials) diff --git a/tests/test_client.py b/tests/test_client.py index 18b7df4..34764d4 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -436,7 +436,7 @@ class GoogleCredentialsTests(unittest.TestCase): 'File {0} \(pointed by {1} environment variable\) does not ' 'exist!'.format( nonexistent_file, client.GOOGLE_APPLICATION_CREDENTIALS)) - with self.assertRaisesRegexp(client.ApplicationDefaultCredentialsError, + with self.assertRaisesRegex(client.ApplicationDefaultCredentialsError, expected_err_msg): client._get_environment_variable_file() @@ -541,7 +541,7 @@ class GoogleCredentialsTests(unittest.TestCase): "'{1}' values\)".format(client.AUTHORIZED_USER, client.SERVICE_ACCOUNT)) - with self.assertRaisesRegexp(client.ApplicationDefaultCredentialsError, + with self.assertRaisesRegex(client.ApplicationDefaultCredentialsError, expected_err_msg): client._get_application_default_credential_from_file( credentials_file) @@ -552,7 +552,7 @@ class GoogleCredentialsTests(unittest.TestCase): 'application_default_credentials_malformed_2.json')) expected_err_msg = ( 'The following field\(s\) must be defined: private_key_id') - with self.assertRaisesRegexp(client.ApplicationDefaultCredentialsError, + with self.assertRaisesRegex(client.ApplicationDefaultCredentialsError, expected_err_msg): client._get_application_default_credential_from_file( credentials_file) @@ -569,7 +569,7 @@ class GoogleCredentialsTests(unittest.TestCase): missing_fields = ['first', 'second', 'third'] expected_err_msg = ('The following field\(s\) must be defined: ' + ', '.join(missing_fields)) - with self.assertRaisesRegexp(client.ApplicationDefaultCredentialsError, + with self.assertRaisesRegex(client.ApplicationDefaultCredentialsError, expected_err_msg): client._raise_exception_for_missing_fields(missing_fields) @@ -580,7 +580,7 @@ class GoogleCredentialsTests(unittest.TestCase): expected_err_msg = ('An error was encountered while reading ' 'json file: ' + credential_file + extra_help + ': ' + str(error)) - with self.assertRaisesRegexp(client.ApplicationDefaultCredentialsError, + with self.assertRaisesRegex(client.ApplicationDefaultCredentialsError, expected_err_msg): client._raise_exception_for_reading_json( credential_file, extra_help, error) @@ -721,7 +721,7 @@ class GoogleCredentialsTests(unittest.TestCase): credentials_filename = None expected_err_msg = (r'The parameter passed to the from_stream\(\) ' r'method should point to a file.') - with self.assertRaisesRegexp(client.ApplicationDefaultCredentialsError, + with self.assertRaisesRegex(client.ApplicationDefaultCredentialsError, expected_err_msg): self.get_a_google_credentials_object().from_stream( credentials_filename) @@ -737,7 +737,7 @@ class GoogleCredentialsTests(unittest.TestCase): "'type' field should be defined \(and have one of the '" + client.AUTHORIZED_USER + "' or '" + client.SERVICE_ACCOUNT + "' values\)") - with self.assertRaisesRegexp(client.ApplicationDefaultCredentialsError, + with self.assertRaisesRegex(client.ApplicationDefaultCredentialsError, expected_err_msg): self.get_a_google_credentials_object().from_stream( credentials_file) @@ -752,7 +752,7 @@ class GoogleCredentialsTests(unittest.TestCase): ' \(provided as parameter to the from_stream\(\) method\): ' 'The following field\(s\) must be defined: ' 'private_key_id') - with self.assertRaisesRegexp(client.ApplicationDefaultCredentialsError, + with self.assertRaisesRegex(client.ApplicationDefaultCredentialsError, expected_err_msg): self.get_a_google_credentials_object().from_stream( credentials_file) @@ -1872,7 +1872,7 @@ class OAuth2WebServerFlowTest(unittest.TestCase): data=b'error=invalid_request', ) - with self.assertRaisesRegexp(client.FlowExchangeError, + with self.assertRaisesRegex(client.FlowExchangeError, 'invalid_request'): self.flow.step2_exchange(code='some random code', http=http) @@ -2055,7 +2055,7 @@ class OAuth2WebServerFlowTest(unittest.TestCase): http = http_mock.HttpMock(data=payload) code = {'error': 'thou shall not pass'} - with self.assertRaisesRegexp( + with self.assertRaisesRegex( client.FlowExchangeError, 'shall not pass'): self.flow.step2_exchange(code=code, http=http) @@ -2188,7 +2188,7 @@ class FlowFromCachedClientsecrets(unittest.TestCase): err_msg = ('This OAuth 2.0 flow is unsupported: ' '{0!r}'.format(client_type)) - with self.assertRaisesRegexp(client.UnknownClientSecretsFlowError, + with self.assertRaisesRegex(client.UnknownClientSecretsFlowError, err_msg): client.flow_from_clientsecrets(filename, None, cache=cache) diff --git a/tests/test_clientsecrets.py b/tests/test_clientsecrets.py index 3fa9c30..360bacb 100644 --- a/tests/test_clientsecrets.py +++ b/tests/test_clientsecrets.py @@ -215,8 +215,8 @@ class OAuth2CredentialsTests(unittest.TestCase): clientsecrets.InvalidClientSecretsError) as exc_manager: clientsecrets._loadfile(NONEXISTENT_FILE) - self.assertEquals(exc_manager.exception.args[1], NONEXISTENT_FILE) - self.assertEquals(exc_manager.exception.args[3], errno.ENOENT) + self.assertEqual(exc_manager.exception.args[1], NONEXISTENT_FILE) + self.assertEqual(exc_manager.exception.args[3], errno.ENOENT) class CachedClientsecretsTests(unittest.TestCase): diff --git a/tests/test_file.py b/tests/test_file.py index 80324d6..f916e43 100644 --- a/tests/test_file.py +++ b/tests/test_file.py @@ -122,9 +122,9 @@ class OAuth2ClientFileTests(unittest.TestCase): with open(FILENAME) as credentials_file: data = json.load(credentials_file) - self.assertEquals(data['access_token'], 'foo') - self.assertEquals(data['_class'], 'OAuth2Credentials') - self.assertEquals(data['_module'], client.OAuth2Credentials.__module__) + self.assertEqual(data['access_token'], 'foo') + self.assertEqual(data['_class'], 'OAuth2Credentials') + self.assertEqual(data['_module'], client.OAuth2Credentials.__module__) def test_token_refresh_store_expired(self): expiration = (datetime.datetime.utcnow() - @@ -144,7 +144,7 @@ class OAuth2ClientFileTests(unittest.TestCase): http = http_mock.HttpMock(data=response_content) credentials._refresh(http) - self.assertEquals(credentials.access_token, access_token) + self.assertEqual(credentials.access_token, access_token) # Verify mocks. self.assertEqual(http.requests, 1) @@ -207,7 +207,7 @@ class OAuth2ClientFileTests(unittest.TestCase): storage.put(new_cred) credentials._refresh(None) - self.assertEquals(credentials.access_token, 'bar') + self.assertEqual(credentials.access_token, 'bar') def test_token_refresh_stream_body(self): expiration = (datetime.datetime.utcnow() + @@ -263,10 +263,10 @@ class OAuth2ClientFileTests(unittest.TestCase): credentials = storage.get() self.assertIsNotNone(credentials) - self.assertEquals('foo', credentials.access_token) + self.assertEqual('foo', credentials.access_token) self.assertTrue(os.path.exists(FILENAME)) if os.name == 'posix': # pragma: NO COVER mode = os.stat(FILENAME).st_mode - self.assertEquals('0o600', oct(stat.S_IMODE(mode))) + self.assertEqual('0o600', oct(stat.S_IMODE(mode))) diff --git a/tests/test_service_account.py b/tests/test_service_account.py index 6756d49..62e64b9 100644 --- a/tests/test_service_account.py +++ b/tests/test_service_account.py @@ -571,7 +571,7 @@ class JWTAccessCredentialsTests(unittest.TestCase): utcnow.return_value = T3_DATE transport.request(http, self.url) token_2 = self.jwt.access_token - self.assertEquals(self.jwt.token_expiry, T3_EXPIRY_DATE) + self.assertEqual(self.jwt.token_expiry, T3_EXPIRY_DATE) self.assertNotEqual(token_1, token_2) # Verify mocks. @@ -615,7 +615,7 @@ class JWTAccessCredentialsTests(unittest.TestCase): utcnow.return_value = T2_DATE response, _ = transport.request(http, self.url) - self.assertEquals(response.status, http_client.OK) + self.assertEqual(response.status, http_client.OK) token_2 = self.jwt.access_token # Check the 401 forced a new token self.assertNotEqual(token_1, token_2) @@ -654,5 +654,5 @@ class JWTAccessCredentialsTests(unittest.TestCase): utcnow.return_value = T2_DATE self.jwt.refresh(None) token_2 = self.jwt.access_token - self.assertEquals(self.jwt.token_expiry, T2_EXPIRY_DATE) + self.assertEqual(self.jwt.token_expiry, T2_EXPIRY_DATE) self.assertNotEqual(token_1, token_2) commit e7a25d6a4a7cd8c1182eb59852ed8a2947572b0c Author: Robin H. Johnson Date: Tue Feb 7 16:57:27 2023 -0800 tox: ignore flask & django due to missing updates Signed-off-by: Robin H. Johnson :100644 100644 885ed77 12e3cf6 M tox.ini diff --git a/tox.ini b/tox.ini index 885ed77..12e3cf6 100644 --- a/tox.ini +++ b/tox.ini @@ -19,7 +19,7 @@ setenv = pypy: with_gmp=no DJANGO_SETTINGS_MODULE=tests.contrib.django_util.settings commands = - py.test {posargs} + py.test --ignore-glob='*django_util*' --ignore-glob='*flask*' {posargs} [coverbase] basepython = python2.7