/usr/lib/python3/dist-packages/social/tests/test_exceptions.py is in python3-social-auth 1:0.2.21+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | import unittest2 as unittest
from social.exceptions import SocialAuthBaseException, WrongBackend, \
AuthFailed, AuthTokenError, \
AuthMissingParameter, AuthStateMissing, \
NotAllowedToDisconnect, AuthException, \
AuthCanceled, AuthUnknownError, \
AuthStateForbidden, AuthAlreadyAssociated, \
AuthTokenRevoked
class BaseExceptionTestCase(unittest.TestCase):
exception = None
expected_message = ''
def test_exception_message(self):
if self.exception is None and self.expected_message == '':
return
try:
raise self.exception
except SocialAuthBaseException as err:
self.assertEqual(str(err), self.expected_message)
class WrongBackendTest(BaseExceptionTestCase):
exception = WrongBackend('foobar')
expected_message = 'Incorrect authentication service "foobar"'
class AuthFailedTest(BaseExceptionTestCase):
exception = AuthFailed('foobar', 'wrong_user')
expected_message = 'Authentication failed: wrong_user'
class AuthFailedDeniedTest(BaseExceptionTestCase):
exception = AuthFailed('foobar', 'access_denied')
expected_message = 'Authentication process was canceled'
class AuthTokenErrorTest(BaseExceptionTestCase):
exception = AuthTokenError('foobar', 'Incorrect tokens')
expected_message = 'Token error: Incorrect tokens'
class AuthMissingParameterTest(BaseExceptionTestCase):
exception = AuthMissingParameter('foobar', 'username')
expected_message = 'Missing needed parameter username'
class AuthStateMissingTest(BaseExceptionTestCase):
exception = AuthStateMissing('foobar')
expected_message = 'Session value state missing.'
class NotAllowedToDisconnectTest(BaseExceptionTestCase):
exception = NotAllowedToDisconnect()
expected_message = ''
class AuthExceptionTest(BaseExceptionTestCase):
exception = AuthException('foobar', 'message')
expected_message = 'message'
class AuthCanceledTest(BaseExceptionTestCase):
exception = AuthCanceled('foobar')
expected_message = 'Authentication process canceled'
class AuthUnknownErrorTest(BaseExceptionTestCase):
exception = AuthUnknownError('foobar', 'some error')
expected_message = 'An unknown error happened while ' \
'authenticating some error'
class AuthStateForbiddenTest(BaseExceptionTestCase):
exception = AuthStateForbidden('foobar')
expected_message = 'Wrong state parameter given.'
class AuthAlreadyAssociatedTest(BaseExceptionTestCase):
exception = AuthAlreadyAssociated('foobar')
expected_message = ''
class AuthTokenRevokedTest(BaseExceptionTestCase):
exception = AuthTokenRevoked('foobar')
expected_message = 'User revoke access to the token'
|