/usr/lib/python2.7/dist-packages/social/tests/backends/test_livejournal.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 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 89 90 91 92 93 94 95 96 97 98 99 | import datetime
from httpretty import HTTPretty
from social.p3 import urlencode
from social.exceptions import AuthMissingParameter
from social.tests.backends.open_id import OpenIdTest
JANRAIN_NONCE = datetime.datetime.now().strftime('%Y-%m-%dT%H:%M:%SZ')
class LiveJournalOpenIdTest(OpenIdTest):
backend_path = 'social.backends.livejournal.LiveJournalOpenId'
expected_username = 'foobar'
discovery_body = ''.join([
'<xrds:XRDS xmlns:xrds="xri://$xrds" xmlns="xri://$xrd*($v*2.0)">',
'<XRD>',
'<Service priority="0">',
'<Type>http://specs.openid.net/auth/2.0/signon</Type>',
'<URI>http://www.livejournal.com/openid/server.bml</URI>',
'<LocalID>http://foobar.livejournal.com/</LocalID>',
'</Service>',
'</XRD>',
'</xrds:XRDS>'
])
server_response = urlencode({
'janrain_nonce': JANRAIN_NONCE,
'openid.mode': 'id_res',
'openid.claimed_id': 'http://foobar.livejournal.com/',
'openid.identity': 'http://foobar.livejournal.com/',
'openid.op_endpoint': 'http://www.livejournal.com/openid/server.bml',
'openid.return_to': 'http://myapp.com/complete/livejournal/?'
'janrain_nonce=' + JANRAIN_NONCE,
'openid.response_nonce': JANRAIN_NONCE + 'wGp2rj',
'openid.assoc_handle': '1364932966:ZTiur8sem3r2jzZougMZ:4d1cc3b44e',
'openid.ns': 'http://specs.openid.net/auth/2.0',
'openid.signed': 'mode,claimed_id,identity,op_endpoint,return_to,'
'response_nonce,assoc_handle',
'openid.sig': 'Z8MOozVPTOBhHG5ZS1NeGofxs1Q=',
})
server_bml_body = '\n'.join([
'assoc_handle:1364935340:ZhruPQ7DJ9eGgUkeUA9A:27f8c32464',
'assoc_type:HMAC-SHA1',
'dh_server_public:WzsRyLomvAV3vwvGUrfzXDgfqnTF+m1l3JWb55fyHO7visPT4tmQ'
'iTjqFFnSVAtAOvQzoViMiZQisxNwnqSK4lYexoez1z6pP5ry3pqxJAEYj60vFGvRztict'
'Eo0brjhmO1SNfjK1ppjOymdykqLpZeaL5fsuLtMCwTnR/JQZVA=',
'enc_mac_key:LiOEVlLJSVUqfNvb5zPd76nEfvc=',
'expires_in:1207060',
'ns:http://specs.openid.net/auth/2.0',
'session_type:DH-SHA1',
''
])
def openid_url(self):
return super(LiveJournalOpenIdTest, self).openid_url() + '/data/yadis'
def post_start(self):
self.strategy.remove_from_request_data('openid_lj_user')
def _setup_handlers(self):
HTTPretty.register_uri(
HTTPretty.POST,
'http://www.livejournal.com/openid/server.bml',
headers={'Accept-Encoding': 'identity',
'Content-Type': 'application/x-www-form-urlencoded'},
status=200,
body=self.server_bml_body
)
HTTPretty.register_uri(
HTTPretty.GET,
'http://foobar.livejournal.com/',
headers={
'Accept-Encoding': 'identity',
'Accept': 'text/html; q=0.3,'
'application/xhtml+xml; q=0.5,'
'application/xrds+xml'
},
status=200,
body=self.discovery_body
)
def test_login(self):
self.strategy.set_request_data({'openid_lj_user': 'foobar'},
self.backend)
self._setup_handlers()
self.do_login()
def test_partial_pipeline(self):
self.strategy.set_request_data({'openid_lj_user': 'foobar'},
self.backend)
self._setup_handlers()
self.do_partial_pipeline()
def test_failed_login(self):
self._setup_handlers()
with self.assertRaises(AuthMissingParameter):
self.do_login()
|