当前位置: 首页>>代码示例>>Python>>正文


Python OneLogin_Saml2_Logout_Request.get_nameid_data方法代码示例

本文整理汇总了Python中onelogin.saml2.logout_request.OneLogin_Saml2_Logout_Request.get_nameid_data方法的典型用法代码示例。如果您正苦于以下问题:Python OneLogin_Saml2_Logout_Request.get_nameid_data方法的具体用法?Python OneLogin_Saml2_Logout_Request.get_nameid_data怎么用?Python OneLogin_Saml2_Logout_Request.get_nameid_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在onelogin.saml2.logout_request.OneLogin_Saml2_Logout_Request的用法示例。


在下文中一共展示了OneLogin_Saml2_Logout_Request.get_nameid_data方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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_nameid_data [as 别名]
    def testGetNameIdData(self):
        """
        Tests the get_nameid_data method of the OneLogin_Saml2_LogoutRequest
        """
        expected_name_id_data = {
            'Value': 'ONELOGIN_1e442c129e1f822c8096086a1103c5ee2c7cae1c',
            'Format': 'urn:oasis:names:tc:SAML:1.1: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_nameid_data(request)
        self.assertEqual(expected_name_id_data, name_id_data)

        dom = parseString(request)
        name_id_data_2 = OneLogin_Saml2_Logout_Request.get_nameid_data(dom.toxml())
        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'))
        with self.assertRaises(Exception) as context:
            OneLogin_Saml2_Logout_Request.get_nameid(request_2)
            exception = context.exception
            self.assertIn("Key is required in order to decrypt the NameID", str(exception))

        settings = OneLogin_Saml2_Settings(self.loadSettingsJSON())
        key = settings.get_sp_key()
        name_id_data_4 = OneLogin_Saml2_Logout_Request.get_nameid_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)
        with self.assertRaises(Exception) as context:
            OneLogin_Saml2_Logout_Request.get_nameid(dom_2.toxml(), key)
            exception = context.exception
            self.assertIn("Not NameID found in the Logout Request", str(exception))

        inv_request = self.file_contents(join(self.data_path, 'logout_requests', 'invalids', 'no_nameId.xml'))
        with self.assertRaises(Exception) as context:
            OneLogin_Saml2_Logout_Request.get_nameid(inv_request)
            exception = context.exception
            self.assertIn("Not NameID found in the Logout Request", str(exception))
开发者ID:catalyst,项目名称:python3-saml,代码行数:50,代码来源:logout_request_test.py

示例2: testConstructorWithoutNameIdFormat

# 需要导入模块: from onelogin.saml2.logout_request import OneLogin_Saml2_Logout_Request [as 别名]
# 或者: from onelogin.saml2.logout_request.OneLogin_Saml2_Logout_Request import get_nameid_data [as 别名]
 def testConstructorWithoutNameIdFormat(self):
     """
     Tests the OneLogin_Saml2_LogoutRequest Constructor.
     Case: Checks that NameIDFormat is not added
     """
     settings_info = self.loadSettingsJSON()
     name_id = 'ONELOGIN_1e442c129e1f822c8096086a1103c5ee2c7cae1c'
     name_id_format = 'urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified'
     settings_info['sp']['NameIDFormat'] = name_id_format
     settings = OneLogin_Saml2_Settings(settings_info)
     logout_request = OneLogin_Saml2_Logout_Request(settings, name_id=name_id)
     logout_request_xml = OneLogin_Saml2_Utils.decode_base64_and_inflate(logout_request.get_request())
     name_id_data = OneLogin_Saml2_Logout_Request.get_nameid_data(logout_request_xml)
     expected_name_id_data = {
         'Value': name_id
     }
     self.assertEqual(expected_name_id_data, name_id_data)
开发者ID:onelogin,项目名称:python-saml,代码行数:19,代码来源:logout_request_test.py

示例3: testConstructorWithNameIdFormatOnSettings

# 需要导入模块: from onelogin.saml2.logout_request import OneLogin_Saml2_Logout_Request [as 别名]
# 或者: from onelogin.saml2.logout_request.OneLogin_Saml2_Logout_Request import get_nameid_data [as 别名]
 def testConstructorWithNameIdFormatOnSettings(self):
     """
     Tests the OneLogin_Saml2_LogoutRequest Constructor.
     Case: Defines NameIDFormat from settings
     """
     settings_info = self.loadSettingsJSON()
     name_id = 'ONELOGIN_1e442c129e1f822c8096086a1103c5ee2c7cae1c'
     name_id_format = 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient'
     settings_info['sp']['NameIDFormat'] = name_id_format
     settings = OneLogin_Saml2_Settings(settings_info)
     logout_request = OneLogin_Saml2_Logout_Request(settings, name_id=name_id)
     logout_request_xml = OneLogin_Saml2_Utils.decode_base64_and_inflate(logout_request.get_request())
     name_id_data = OneLogin_Saml2_Logout_Request.get_nameid_data(logout_request_xml)
     expected_name_id_data = {
         'Value': name_id,
         'Format': name_id_format
     }
     self.assertEqual(expected_name_id_data, name_id_data)
开发者ID:onelogin,项目名称:python-saml,代码行数:20,代码来源:logout_request_test.py


注:本文中的onelogin.saml2.logout_request.OneLogin_Saml2_Logout_Request.get_nameid_data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。