/usr/lib/python2.7/dist-packages/social/tests/backends/legacy.py is in python-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 | import requests
from httpretty import HTTPretty
from social.utils import parse_qs
from social.tests.backends.base import BaseBackendTest
class BaseLegacyTest(BaseBackendTest):
form = ''
response_body = ''
def setUp(self):
super(BaseLegacyTest, self).setUp()
self.strategy.set_settings({
'SOCIAL_AUTH_{0}_FORM_URL'.format(self.name):
self.strategy.build_absolute_uri('/login/{0}'.format(
self.backend.name))
})
def extra_settings(self):
return {'SOCIAL_AUTH_{0}_FORM_URL'.format(self.name):
'/login/{0}'.format(self.backend.name)}
def do_start(self):
start_url = self.strategy.build_absolute_uri(self.backend.start().url)
HTTPretty.register_uri(
HTTPretty.GET,
start_url,
status=200,
body=self.form.format(self.complete_url)
)
HTTPretty.register_uri(
HTTPretty.POST,
self.complete_url,
status=200,
body=self.response_body,
content_type='application/x-www-form-urlencoded'
)
response = requests.get(start_url)
self.assertEqual(response.text, self.form.format(self.complete_url))
response = requests.post(
self.complete_url,
data=parse_qs(self.response_body)
)
self.strategy.set_request_data(parse_qs(response.text), self.backend)
return self.backend.complete()
|