Skip to content

Commit f26bb9c

Browse files
committed
Merge pull request #103 from Jeff-Meadows/redis_import
Bugfixes from dev token release.
2 parents c36945d + 5acea7b commit f26bb9c

File tree

8 files changed

+48
-17
lines changed

8 files changed

+48
-17
lines changed

HISTORY.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ Release History
66
Upcoming
77
++++++++
88

9+
1.3.3 (2016-01-04)
10+
++++++++++++++++++
11+
12+
**Bugfixes**
13+
14+
- Fixed import error for installations that don't have redis installed.
15+
- Fixed use of ``raw_input`` in the developer token auth for py3 compatibility.
16+
17+
918
1.3.3 (2015-12-22)
1019
++++++++++++++++++
1120

boxsdk/auth/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77
try:
88
from .jwt_auth import JWTAuth
99
except ImportError:
10-
JWTAuth = None # If extras are not installed, JWTAuth won't be available.
10+
JWTAuth = None # If extras[jwt] are not installed, JWTAuth won't be available.
1111
from .oauth2 import OAuth2
12-
from .redis_managed_oauth2 import RedisManagedJWTAuth, RedisManagedOAuth2
12+
try:
13+
from .redis_managed_oauth2 import RedisManagedOAuth2
14+
except ImportError:
15+
RedisManagedOAuth2 = None # If extras[redis] are not installed, RedisManagedOAuth2 won't be available.
16+
try:
17+
from .redis_managed_jwt_auth import RedisManagedJWTAuth
18+
except ImportError:
19+
RedisManagedJWTAuth = None # If extras[jwt,redis] are not installed, RedisManagedJWTAuth won't be available.
1320
from .remote_managed_oauth2 import RemoteOAuth2

boxsdk/auth/developer_token_auth.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from __future__ import unicode_literals, absolute_import
44

5+
from six.moves import input # pylint:disable=redefined-builtin
6+
57
from .oauth2 import OAuth2
68

79

@@ -21,7 +23,7 @@ def _refresh_developer_token(self):
2123
if self._get_new_token is not None:
2224
return self._get_new_token()
2325
else:
24-
return raw_input(self.ENTER_TOKEN_PROMPT)
26+
return input(self.ENTER_TOKEN_PROMPT)
2527

2628
def _refresh(self, access_token):
2729
"""
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# coding: utf-8
2+
3+
from __future__ import unicode_literals, absolute_import
4+
5+
from .jwt_auth import JWTAuth
6+
from .redis_managed_oauth2 import RedisManagedOAuth2Mixin
7+
8+
9+
class RedisManagedJWTAuth(RedisManagedOAuth2Mixin, JWTAuth):
10+
"""
11+
JWT Auth subclass which uses Redis to manage access tokens.
12+
"""
13+
def _auth_with_jwt(self, sub, sub_type):
14+
"""
15+
Base class override. Returns the access token in a tuple to match the OAuth2 interface.
16+
"""
17+
return super(RedisManagedJWTAuth, self)._auth_with_jwt(sub, sub_type), None

boxsdk/auth/redis_managed_oauth2.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from redis import StrictRedis
88
from redis.lock import Lock
99

10-
from .jwt_auth import JWTAuth
1110
from .oauth2 import OAuth2
1211

1312

@@ -69,14 +68,3 @@ class RedisManagedOAuth2(RedisManagedOAuth2Mixin):
6968
OAuth2 subclass which uses Redis to manage tokens.
7069
"""
7170
pass
72-
73-
74-
class RedisManagedJWTAuth(RedisManagedOAuth2Mixin, JWTAuth):
75-
"""
76-
JWT Auth subclass which uses Redis to manage access tokens.
77-
"""
78-
def _auth_with_jwt(self, sub, sub_type):
79-
"""
80-
Base class override. Returns the access token in a tuple to match the OAuth2 interface.
81-
"""
82-
return super(RedisManagedJWTAuth, self)._auth_with_jwt(sub, sub_type), None

docs/source/boxsdk.auth.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ boxsdk.auth.oauth2 module
3636
:undoc-members:
3737
:show-inheritance:
3838

39+
boxsdk.auth.redis_managed_jwt_auth module
40+
-----------------------------------------
41+
42+
.. automodule:: boxsdk.auth.redis_managed_jwt_auth
43+
:members:
44+
:undoc-members:
45+
:show-inheritance:
46+
3947
boxsdk.auth.redis_managed_oauth2 module
4048
---------------------------------------
4149

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def main():
6161
install_requires.append('ordereddict>=1.1')
6262
setup(
6363
name='boxsdk',
64-
version='1.3.3',
64+
version='1.3.4',
6565
description='Official Box Python SDK',
6666
long_description=open(join(base_dir, 'README.rst')).read(),
6767
author='Box',

test/unit/auth/test_developer_token_auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_developer_token_auth_calls_callback_during_init_and_refresh(access_toke
1919

2020

2121
def test_developer_token_auth_uses_raw_input_by_default(access_token):
22-
with patch('boxsdk.auth.developer_token_auth.raw_input', create=True) as mock_raw_input:
22+
with patch('boxsdk.auth.developer_token_auth.input', create=True) as mock_raw_input:
2323
mock_raw_input.return_value = access_token
2424
auth = developer_token_auth.DeveloperTokenAuth()
2525
mock_raw_input.assert_called_once_with(auth.ENTER_TOKEN_PROMPT)

0 commit comments

Comments
 (0)