Skip to content

Commit

Permalink
Port PR #1062 by dotsbb
Browse files Browse the repository at this point in the history
  • Loading branch information
omab committed Dec 3, 2016
1 parent a842f5d commit 0de0e7d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Added Dockerfile to simplify the running of tests (`make docker-tox`)

### Changed
- Don't lose custom exception message on raising AuthCanceled (port from [#1062](https://github.com/omab/python-social-auth/pull/1062)
by dotsbb)
- Fixed VK backend (port from [#1007](https://github.com/omab/python-social-auth/pull/1007)
by DeKaN)
- Updated Dropbox backend (port from [#1018](https://github.com/omab/python-social-auth/pull/1018)
Expand Down
3 changes: 3 additions & 0 deletions social_core/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def __init__(self, *args, **kwargs):
super(AuthCanceled, self).__init__(*args, **kwargs)

def __str__(self):
msg = super(AuthCanceled, self).__str__()
if msg:
return 'Authentication process canceled: {0}'.format(msg)
return 'Authentication process canceled'


Expand Down
29 changes: 28 additions & 1 deletion social_core/tests/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
NotAllowedToDisconnect, AuthException, \
AuthCanceled, AuthUnknownError, \
AuthStateForbidden, AuthAlreadyAssociated, \
AuthTokenRevoked
AuthTokenRevoked, AuthForbidden, \
AuthUnreachableProvider, InvalidEmail, \
MissingBackend


class BaseExceptionTestCase(unittest.TestCase):
Expand Down Expand Up @@ -67,6 +69,11 @@ class AuthCanceledTest(BaseExceptionTestCase):
expected_message = 'Authentication process canceled'


class AuthCanceledWithExtraMessageTest(BaseExceptionTestCase):
exception = AuthCanceled('foobar', 'error_message')
expected_message = 'Authentication process canceled: error_message'


class AuthUnknownErrorTest(BaseExceptionTestCase):
exception = AuthUnknownError('foobar', 'some error')
expected_message = 'An unknown error happened while ' \
Expand All @@ -86,3 +93,23 @@ class AuthAlreadyAssociatedTest(BaseExceptionTestCase):
class AuthTokenRevokedTest(BaseExceptionTestCase):
exception = AuthTokenRevoked('foobar')
expected_message = 'User revoke access to the token'


class AuthForbiddenTest(BaseExceptionTestCase):
exception = AuthForbidden('foobar')
expected_message = 'Your credentials aren\'t allowed'


class AuthUnreachableProviderTest(BaseExceptionTestCase):
exception = AuthUnreachableProvider('foobar')
expected_message = 'The authentication provider could not be reached'


class InvalidEmailTest(BaseExceptionTestCase):
exception = InvalidEmail('foobar')
expected_message = 'Email couldn\'t be validated'


class MissingBackendTest(BaseExceptionTestCase):
exception = MissingBackend('backend')
expected_message = 'Missing backend "backend" entry'

0 comments on commit 0de0e7d

Please sign in to comment.