本文整理汇总了Python中onelogin.saml2.logout_request.OneLogin_Saml2_Logout_Request.get_name_id_data方法的典型用法代码示例。如果您正苦于以下问题:Python OneLogin_Saml2_Logout_Request.get_name_id_data方法的具体用法?Python OneLogin_Saml2_Logout_Request.get_name_id_data怎么用?Python OneLogin_Saml2_Logout_Request.get_name_id_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类onelogin.saml2.logout_request.OneLogin_Saml2_Logout_Request
的用法示例。
在下文中一共展示了OneLogin_Saml2_Logout_Request.get_name_id_data方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testGetNameIdData
# 需要导入模块: from onelogin.saml2.logout_request import OneLogin_Saml2_Logout_Request [as 别名]
# 或者: from onelogin.saml2.logout_request.OneLogin_Saml2_Logout_Request import get_name_id_data [as 别名]
def testGetNameIdData(self):
"""
Tests the get_name_id_data method of the OneLogin_Saml2_LogoutRequest
"""
expected_name_id_data = {
'Value': 'ONELOGIN_1e442c129e1f822c8096086a1103c5ee2c7cae1c',
'Format': 'urn:oasis:names:tc:SAML:2.0:nameid-format:unspecified',
'SPNameQualifier': 'http://idp.example.com/'
}
request = self.file_contents(join(self.data_path, 'logout_requests', 'logout_request.xml'))
name_id_data = OneLogin_Saml2_Logout_Request.get_name_id_data(request)
self.assertEqual(expected_name_id_data, name_id_data)
dom = parseString(request)
name_id_data_2 = OneLogin_Saml2_Logout_Request.get_name_id_data(dom)
self.assertEqual(expected_name_id_data, name_id_data_2)
request_2 = self.file_contents(join(self.data_path, 'logout_requests', 'logout_request_encrypted_nameid.xml'))
try:
OneLogin_Saml2_Logout_Request.get_name_id_data(request_2)
self.assertTrue(False)
except Exception as e:
self.assertIn('Key is required in order to decrypt the NameID', e.message)
settings = OneLogin_Saml2_Settings(self.loadSettingsJSON())
key = settings.get_sp_key()
name_id_data_4 = OneLogin_Saml2_Logout_Request.get_name_id_data(request_2, key)
expected_name_id_data = {
'Value': 'ONELOGIN_9c86c4542ab9d6fce07f2f7fd335287b9b3cdf69',
'Format': 'urn:oasis:names:tc:SAML:2.0:nameid-format:emailAddress',
'SPNameQualifier': 'https://pitbulk.no-ip.org/newonelogin/demo1/metadata.php'
}
self.assertEqual(expected_name_id_data, name_id_data_4)
dom_2 = parseString(request_2)
encrypted_id_nodes = dom_2.getElementsByTagName('saml:EncryptedID')
encrypted_data = encrypted_id_nodes[0].firstChild.nextSibling
encrypted_id_nodes[0].removeChild(encrypted_data)
try:
OneLogin_Saml2_Logout_Request.get_name_id_data(dom_2.toxml(), key)
self.assertTre(False)
except Exception as e:
self.assertIn('Not NameID found in the Logout Request', e.message)
inv_request = self.file_contents(join(self.data_path, 'logout_requests', 'invalids', 'no_nameId.xml'))
try:
OneLogin_Saml2_Logout_Request.get_name_id_data(inv_request)
self.assertTre(False)
except Exception as e:
self.assertIn('Not NameID found in the Logout Request', e.message)