How to use the adal.wstrust_response.WSTrustResponse function in adal

To help you get started, we’ve selected a few adal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AzureAD / azure-activedirectory-library-for-python / tests / test_wstrust_response.py View on Github external
def test_rstr_empty_string(self):
        with six.assertRaisesRegex(self, Exception, 'Received empty RSTR response body.') as cm:
            wstrustResponse = WSTrustResponse(_call_context, '', WSTrustVersion.WSTRUST13)
            wstrustResponse.parse()
github AzureAD / azure-activedirectory-library-for-python / tests / test_username_password.py View on Github external
def create_wstrust_request_stub(self, err, tokenType, noToken=None):
            wstrust_response = WSTrustResponse(cp['callContext'],'')
            wstrust_response.error_code = err
            wstrust_response.parse = mock.MagicMock()
            if not noToken:
                wstrust_response.token = 'This is a stubbed token'
                wstrust_response._tokenType = tokenType
                wstrust_response.token_type = tokenType

            wstrust_request = WSTrustRequest(cp['callContext'], '', '')

            def side_effect (username, password):
                if err:
                    raise AdalError("Throwing error from Unit test")
                return wstrust_response
            wstrust_request.acquire_token = mock.MagicMock(side_effect=side_effect)

            return wstrust_request
github AzureAD / azure-activedirectory-library-for-python / tests / test_wstrust_response.py View on Github external
def test_rstr_unparseable_xml(self):
        with six.assertRaisesRegex(self, Exception, 'Failed to parse RSTR in to DOM'):
            wstrustResponse = WSTrustResponse(_call_context, '
github AzureAD / azure-activedirectory-library-for-python / tests / test_wstrust_response.py View on Github external
def test_token_parsing_happy_path(self):
        wstrustFile = open(os.path.join(os.getcwd(), 'tests', 'wstrust', 'RSTR.xml'))
        wstrustResponse = WSTrustResponse(_call_context, wstrustFile.read(), WSTrustVersion.WSTRUST13)
        wstrustResponse.parse()
        wstrustFile.close()

        self.assertEqual(wstrustResponse.token_type, 'urn:oasis:names:tc:SAML:1.0:assertion', 'TokenType did not match expected value: ' + wstrustResponse.token_type)

        attribute_values = ET.fromstring(wstrustResponse.token).findall('saml:AttributeStatement/saml:Attribute/saml:AttributeValue', _namespaces)
        self.assertEqual(2, len(attribute_values))
        self.assertEqual('1TIu064jGEmmf+hnI+F0Jg==', attribute_values[1].text)

adal

Note: This library is already replaced by MSAL Python, available here: https://pypi.org/project/msal/ .ADAL Python remains available here as a legacy. The ADAL for Python library makes it easy for python application to authenticate to Azure Active Directory (AAD) in order to access AAD protected web resources.

MIT
Latest version published 3 years ago

Package Health Score

58 / 100
Full package analysis

Similar packages