/usr/lib/python3/dist-packages/social/tests/actions/test_disconnect.py is in python3-social-auth 0.2.13-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 | import requests
from httpretty import HTTPretty
from social.actions import do_disconnect
from social.exceptions import NotAllowedToDisconnect
from social.utils import parse_qs
from social.tests.models import User, TestUserSocialAuth
from social.tests.actions.actions import BaseActionTest
class DisconnectActionTest(BaseActionTest):
def test_not_allowed_to_disconnect(self):
self.do_login()
user = User.get(self.expected_username)
with self.assertRaises(NotAllowedToDisconnect):
do_disconnect(self.backend, user)
def test_disconnect(self):
self.do_login()
user = User.get(self.expected_username)
user.password = 'password'
do_disconnect(self.backend, user)
self.assertEqual(len(user.social), 0)
def test_disconnect_with_association_id(self):
self.do_login()
user = User.get(self.expected_username)
user.password = 'password'
association_id = user.social[0].id
second_usa = TestUserSocialAuth(user, user.social[0].provider, "uid2")
self.assertEqual(len(user.social), 2)
do_disconnect(self.backend, user, association_id)
self.assertEqual(len(user.social), 1)
self.assertEqual(user.social[0], second_usa)
def test_disconnect_with_partial_pipeline(self):
self.strategy.set_settings({
'SOCIAL_AUTH_DISCONNECT_PIPELINE': (
'social.pipeline.partial.save_status_to_session',
'social.tests.pipeline.ask_for_password',
'social.tests.pipeline.set_password',
'social.pipeline.disconnect.allowed_to_disconnect',
'social.pipeline.disconnect.get_entries',
'social.pipeline.disconnect.revoke_tokens',
'social.pipeline.disconnect.disconnect'
)
})
self.do_login()
user = User.get(self.expected_username)
redirect = do_disconnect(self.backend, user)
url = self.strategy.build_absolute_uri('/password')
self.assertEqual(redirect.url, url)
HTTPretty.register_uri(HTTPretty.GET, redirect.url, status=200,
body='foobar')
HTTPretty.register_uri(HTTPretty.POST, redirect.url, status=200)
password = 'foobar'
requests.get(url)
requests.post(url, data={'password': password})
data = parse_qs(HTTPretty.last_request.body)
self.assertEqual(data['password'], password)
self.strategy.session_set('password', data['password'])
redirect = do_disconnect(self.backend, user)
self.assertEqual(len(user.social), 0)
|