本文整理匯總了Python中openid.consumer.discover.OpenIDServiceEndpoint.delegate方法的典型用法代碼示例。如果您正苦於以下問題:Python OpenIDServiceEndpoint.delegate方法的具體用法?Python OpenIDServiceEndpoint.delegate怎麽用?Python OpenIDServiceEndpoint.delegate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類openid.consumer.discover.OpenIDServiceEndpoint
的用法示例。
在下文中一共展示了OpenIDServiceEndpoint.delegate方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _test_success
# 需要導入模塊: from openid.consumer.discover import OpenIDServiceEndpoint [as 別名]
# 或者: from openid.consumer.discover.OpenIDServiceEndpoint import delegate [as 別名]
def _test_success(server_url, user_url, delegate_url, links, immediate=False):
store = _memstore.MemoryStore()
if immediate:
mode = 'checkid_immediate'
else:
mode = 'checkid_setup'
endpoint = OpenIDServiceEndpoint()
endpoint.identity_url = user_url
endpoint.server_url = server_url
endpoint.delegate = delegate_url
fetcher = TestFetcher(None, None, assocs[0])
fetchers.setDefaultFetcher(fetcher, wrap_exceptions=False)
def run():
trust_root = consumer_url
consumer = GenericConsumer(store)
request = consumer.begin(endpoint)
return_to = consumer_url
redirect_url = request.redirectURL(trust_root, return_to, immediate)
parsed = urlparse.urlparse(redirect_url)
qs = parsed[4]
q = parseQuery(qs)
new_return_to = q['openid.return_to']
del q['openid.return_to']
assert q == {
'openid.mode':mode,
'openid.identity':delegate_url,
'openid.trust_root':trust_root,
'openid.assoc_handle':fetcher.assoc_handle,
}, (q, user_url, delegate_url, mode)
assert new_return_to.startswith(return_to)
assert redirect_url.startswith(server_url)
query = {
'nonce':request.return_to_args['nonce'],
'openid.mode':'id_res',
'openid.return_to':new_return_to,
'openid.identity':delegate_url,
'openid.assoc_handle':fetcher.assoc_handle,
}
assoc = store.getAssociation(server_url, fetcher.assoc_handle)
assoc.addSignature(['mode', 'return_to', 'identity'], query)
info = consumer.complete(query, request.endpoint)
assert info.status == SUCCESS, info.message
assert info.identity_url == user_url
assert fetcher.num_assocs == 0
run()
assert fetcher.num_assocs == 1
# Test that doing it again uses the existing association
run()
assert fetcher.num_assocs == 1
# Another association is created if we remove the existing one
store.removeAssociation(server_url, fetcher.assoc_handle)
run()
assert fetcher.num_assocs == 2
# Test that doing it again uses the existing association
run()
assert fetcher.num_assocs == 2