How to use the adal.authentication_parameters.create_authentication_parameters_from_url 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_authentication_parameters.py View on Github external
def test_create_from_url_no_header(self):

        httpretty.register_uri(httpretty.GET, uri=self.testUrl, body='foo', status=401)

        def _callback(err, resp):
            self.assertIsNotNone(err, "Did not receive expected error.")
            self.assertTrue(str(err).find('header') >= 0, 'Error did not include message about missing header')

        adal.authentication_parameters.create_authentication_parameters_from_url(self.testUrl, _callback)

        req = httpretty.last_request()
        util.match_standard_request_headers(req)
github AzureAD / azure-activedirectory-library-for-python / tests / test_authentication_parameters.py View on Github external
httpretty.register_uri(httpretty.GET, uri=self.testUrl, body='foo', status=401, **{'www-authenticate':'Bearer authorization_uri="foobar,lkfj,;l,", fruitcake="f",resource="clark, &^()- q32,shark" , f="foo"'})

        url_obj = urlparse(self.testUrl)

        def _callback(err, parameters):
            self.assertIsNone(err, "An error was raised during function {0}".format(err))
            test_params = {
                'authorizationUri' : 'foobar,lkfj,;l,',
                'resource' : 'clark, &^()- q32,shark',
            }
            self.assertEqual(parameters.authorization_uri, test_params['authorizationUri'],
                                'Parsed authorizationUri did not match expected value.: {0}'.format(parameters.authorization_uri))
            self.assertEqual(parameters.resource, test_params['resource'],
                                'Parsed resource  did not match expected value.: {0}'.format(parameters.resource))

        adal.authentication_parameters.create_authentication_parameters_from_url(url_obj, _callback)

        req = httpretty.last_request()
        util.match_standard_request_headers(req)
github AzureAD / azure-activedirectory-library-for-python / tests / test_authentication_parameters.py View on Github external
def test_create_from_url_network_error(self):

        try:
            adal.authentication_parameters.create_authentication_parameters_from_url('https://0.0.0.0/foobar')
        except Exception as err:
            self.assertIsNotNone(err, "Did not receive expected error.")
github AzureAD / azure-activedirectory-library-for-python / tests / test_authentication_parameters.py View on Github external
    @httpretty.activate
    def test_create_from_url_happy_string_url(self):

        httpretty.register_uri(httpretty.GET, uri=self.testUrl, body='foo', status=401, **{'www-authenticate':'Bearer authorization_uri="foobar,lkfj,;l,", fruitcake="f",resource="clark, &^()- q32,shark" , f="foo"'})

        # maybe try-catch here to catch the error
        parameters = adal.authentication_parameters.create_authentication_parameters_from_url(self.testUrl)

        test_params = {
            'authorizationUri' : 'foobar,lkfj,;l,',
            'resource' : 'clark, &^()- q32,shark',
        }
        self.assertEqual(parameters.authorization_uri, test_params['authorizationUri'],
                            'Parsed authorizationUri did not match expected value.: {0}'.format(parameters.authorization_uri))
        self.assertEqual(parameters.resource, test_params['resource'],
                            'Parsed resource  did not match expected value.: {0}'.format(parameters.resource))

        req = httpretty.last_request()
        util.match_standard_request_headers(req)
github AzureAD / azure-activedirectory-library-for-python / tests / test_authentication_parameters.py View on Github external
    @httpretty.activate
    def test_create_from_url_happy_path_url_object(self):

        httpretty.register_uri(httpretty.GET, uri=self.testUrl, body='foo', status=401, **{'www-authenticate':'Bearer authorization_uri="foobar,lkfj,;l,", fruitcake="f",resource="clark, &^()- q32,shark" , f="foo"'})

        url_obj = urlparse(self.testUrl)

        try:
            parameters = adal.authentication_parameters.create_authentication_parameters_from_url(url_obj)
            test_params = {
                'authorizationUri' : 'foobar,lkfj,;l,',
                'resource' : 'clark, &^()- q32,shark',
            }
            self.assertEqual(parameters.authorization_uri, test_params['authorizationUri'],
                                'Parsed authorizationUri did not match expected value.: {0}'.format(parameters.authorization_uri))
            self.assertEqual(parameters.resource, test_params['resource'],
                                'Parsed resource  did not match expected value.: {0}'.format(parameters.resource))

        except Exception as err:
            self.assertIsNone(err, "An error was raised during function {0}".format(err))

        req = httpretty.last_request()
        util.match_standard_request_headers(req)
github AzureAD / azure-activedirectory-library-for-python / tests / test_authentication_parameters.py View on Github external
def test_create_from_url_happy_string_url(self):

        httpretty.register_uri(httpretty.GET, uri=self.testUrl, body='foo', status=401, **{'www-authenticate':'Bearer authorization_uri="foobar,lkfj,;l,", fruitcake="f",resource="clark, &^()- q32,shark" , f="foo"'})

        def _callback(err, parameters):
            self.assertIsNone(err, "An error was raised during function {0}".format(err))
            test_params = {
                'authorizationUri' : 'foobar,lkfj,;l,',
                'resource' : 'clark, &^()- q32,shark',
            }
            self.assertEqual(parameters.authorization_uri, test_params['authorizationUri'],
                                'Parsed authorizationUri did not match expected value.: {0}'.format(parameters.authorization_uri))
            self.assertEqual(parameters.resource, test_params['resource'],
                                'Parsed resource  did not match expected value.: {0}'.format(parameters.resource))
        adal.authentication_parameters.create_authentication_parameters_from_url(self.testUrl, _callback, None)

        req = httpretty.last_request()
        util.match_standard_request_headers(req)
github AzureAD / azure-activedirectory-library-for-python / tests / test_authentication_parameters.py View on Github external
    @httpretty.activate
    def test_create_from_url_no_header(self):

        httpretty.register_uri(httpretty.GET, uri=self.testUrl, body='foo', status=401)

        receivedException = False
        try:
            adal.authentication_parameters.create_authentication_parameters_from_url(self.testUrl)
        except Exception as err:
            receivedException = True
            self.assertTrue(str(err).find('header') >= 0, 'Error did not include message about missing header')
            pass
        finally:
            self.assertTrue(receivedException)

        req = httpretty.last_request()
        util.match_standard_request_headers(req)
github AzureAD / azure-activedirectory-library-for-python / tests / test_authentication_parameters.py View on Github external
def test_create_from_url_bad_object(self):
        
        def _callback(err, resp):
            self.assertIsNotNone(err, "Did not receive expected error.")

        adal.authentication_parameters.create_authentication_parameters_from_url({}, _callback)
github AzureAD / azure-activedirectory-library-for-python / tests / test_authentication_parameters.py View on Github external
def test_create_from_url_not_passed(self):

        try:
            parameters = adal.authentication_parameters.create_authentication_parameters_from_url(None)
        except Exception as exp:
            self.assertIsNotNone(exp, "Did not receive expected error.")
            pass

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