本文整理匯總了Python中stormpath.resources.application.Application.build_saml_idp_redirect_url方法的典型用法代碼示例。如果您正苦於以下問題:Python Application.build_saml_idp_redirect_url方法的具體用法?Python Application.build_saml_idp_redirect_url怎麽用?Python Application.build_saml_idp_redirect_url使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類stormpath.resources.application.Application
的用法示例。
在下文中一共展示了Application.build_saml_idp_redirect_url方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_building_saml_redirect_uri
# 需要導入模塊: from stormpath.resources.application import Application [as 別名]
# 或者: from stormpath.resources.application.Application import build_saml_idp_redirect_url [as 別名]
def test_building_saml_redirect_uri(self):
try:
from urlparse import urlparse
except ImportError:
from urllib.parse import urlparse
app = Application(client=self.client, properties={'href': 'apphref'})
ret = app.build_saml_idp_redirect_url(
'http://localhost/', 'apphref/saml/sso/idpRedirect')
try:
jwt_response = urlparse(ret).query.split('=')[1]
except:
self.fail("Failed to parse ID site redirect uri")
try:
decoded_data = jwt.decode(
jwt_response, verify=False, algorithms=['HS256'])
except jwt.DecodeError:
self.fail("Invaid JWT generated.")
self.assertIsNotNone(decoded_data.get('iat'))
self.assertIsNotNone(decoded_data.get('jti'))
self.assertIsNotNone(decoded_data.get('iss'))
self.assertIsNotNone(decoded_data.get('sub'))
self.assertIsNotNone(decoded_data.get('cb_uri'))
self.assertEqual(decoded_data.get('cb_uri'), 'http://localhost/')
self.assertIsNone(decoded_data.get('path'))
self.assertIsNone(decoded_data.get('state'))
ret = app.build_saml_idp_redirect_url(
'http://testserver/',
'apphref/saml/sso/idpRedirect',
path='/#/register',
state='test')
try:
jwt_response = urlparse(ret).query.split('=')[1]
except:
self.fail("Failed to parse SAML redirect uri")
try:
decoded_data = jwt.decode(
jwt_response, verify=False, algorithms=['HS256'])
except jwt.DecodeError:
self.fail("Invaid JWT generated.")
self.assertEqual(decoded_data.get('path'), '/#/register')
self.assertEqual(decoded_data.get('state'), 'test')