From 989b5dd774f91bb42670ca3b9275111fccf454d1 Mon Sep 17 00:00:00 2001 From: Jordan Moldow Date: Fri, 2 Oct 2015 18:55:42 -0700 Subject: [PATCH] Rename uses of enterprise_token to enterprise_id This parameter is referred to as enterprise_id in the Box Developer documentation. Also, the noun "token" is already used to refer to the data returned at the end of the auth process. So rename this to reduce confusion. This is a backwards compatible change, because the method parameter name was already correct. This is only a change to private attributes, test code, and documentation. Also add a temporary pip version exclusion on the latest version of pytest, which is broken on Python 2. --- README.rst | 4 ++-- boxsdk/auth/jwt_auth.py | 4 ++-- requirements-dev.txt | 9 ++++++++- test/unit/auth/test_jwt_auth.py | 16 ++++++++-------- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/README.rst b/README.rst index 2551aca84..77ce25e75 100644 --- a/README.rst +++ b/README.rst @@ -248,7 +248,7 @@ instead use an instance of `JWTAuth`. auth = JWTAuth( client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET', - enterprise_token='YOUR_ENTERPRISE_TOKEN', + enterprise_id='YOUR_ENTERPRISE_ID', rsa_private_key_file_sys_path='CERT.PEM', store_tokens=your_store_tokens_callback_method, ) @@ -272,7 +272,7 @@ These users can then be authenticated: ned_auth = JWTAuth( client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET', - enterprise_token='YOUR_ENTERPRISE_TOKEN', + enterprise_id='YOUR_ENTERPRISE_ID', rsa_private_key_file_sys_path='CERT.PEM', store_tokens=your_store_tokens_callback_method, ) diff --git a/boxsdk/auth/jwt_auth.py b/boxsdk/auth/jwt_auth.py index b3a4c3523..bdefdcaf9 100644 --- a/boxsdk/auth/jwt_auth.py +++ b/boxsdk/auth/jwt_auth.py @@ -93,7 +93,7 @@ def __init__( password=rsa_private_key_passphrase, backend=default_backend(), ) - self._enterprise_token = enterprise_id + self._enterprise_id = enterprise_id self._jwt_algorithm = jwt_algorithm self._user_id = None @@ -170,7 +170,7 @@ def authenticate_instance(self): :rtype: `unicode` """ - return self._auth_with_jwt(self._enterprise_token, 'enterprise') + return self._auth_with_jwt(self._enterprise_id, 'enterprise') def _refresh(self, access_token): """ diff --git a/requirements-dev.txt b/requirements-dev.txt index 1be9559b3..f962a371b 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -4,7 +4,14 @@ jsonpatch mock<=1.0.1 pep8 pylint -pytest + +# Temporary version exclusion of the 2.8 release line. +# breaks pytest on Python 2, only in 2.8.1. Fixed in upcoming 2.8.2. +# breaks pytest on Python 2.6, on all currently existing 2.8.* +# releases. Has not yet been fixed in the master branch, so there isn't a guarantee that it will work in the upcoming +# 2.8.2 release. +pytest<2.8 + pytest-cov pytest-xdist sphinx diff --git a/test/unit/auth/test_jwt_auth.py b/test/unit/auth/test_jwt_auth.py index 8ac22fd09..621e736b0 100644 --- a/test/unit/auth/test_jwt_auth.py +++ b/test/unit/auth/test_jwt_auth.py @@ -48,7 +48,7 @@ def jwt_auth_init_mocks( successful_token_response, jwt_algorithm, rsa_passphrase, - enterprise_token=None, + enterprise_id=None, ): # pylint:disable=redefined-outer-name fake_client_id = 'fake_client_id' @@ -70,7 +70,7 @@ def jwt_auth_init_mocks( oauth = JWTAuth( client_id=fake_client_id, client_secret=fake_client_secret, - enterprise_id=enterprise_token, + enterprise_id=enterprise_id, rsa_private_key_file_sys_path=sentinel.rsa_path, rsa_private_key_passphrase=rsa_passphrase, network_layer=mock_network_layer, @@ -153,15 +153,15 @@ def test_authenticate_instance_sends_post_request_with_correct_params( rsa_passphrase, ): # pylint:disable=redefined-outer-name - enterprise_token = 'fake_enterprise_token' + enterprise_id = 'fake_enterprise_id' with jwt_auth_init_mocks( mock_network_layer, successful_token_response, jwt_algorithm, rsa_passphrase, - enterprise_token, + enterprise_id, ) as params: - with jwt_auth_auth_mocks(jti_length, jwt_algorithm, enterprise_token, 'enterprise', *params) as oauth: + with jwt_auth_auth_mocks(jti_length, jwt_algorithm, enterprise_id, 'enterprise', *params) as oauth: oauth.authenticate_instance() @@ -188,13 +188,13 @@ def test_refresh_instance_sends_post_request_with_correct_params( rsa_passphrase, ): # pylint:disable=redefined-outer-name - enterprise_token = 'fake_enterprise_token' + enterprise_id = 'fake_enterprise_id' with jwt_auth_init_mocks( mock_network_layer, successful_token_response, jwt_algorithm, rsa_passphrase, - enterprise_token, + enterprise_id, ) as params: - with jwt_auth_auth_mocks(jti_length, jwt_algorithm, enterprise_token, 'enterprise', *params) as oauth: + with jwt_auth_auth_mocks(jti_length, jwt_algorithm, enterprise_id, 'enterprise', *params) as oauth: oauth.refresh(None)