Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
ADAL 0.6.0 and some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lmazuel committed May 16, 2018
1 parent 5551c9a commit 35ae5aa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 60 deletions.
11 changes: 4 additions & 7 deletions msrestazure/azure_active_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,20 @@ def _configure(self, **kwargs):
resource = self.cloud_environment.endpoints.active_directory_resource_id

tenant = kwargs.get('tenant', self._tenant)
self.verify = kwargs.get('verify', True)
self.cred_store = kwargs.get('keyring', self._keyring)
self.resource = kwargs.get('resource', resource)
self.proxies = kwargs.get('proxies')
self.timeout = kwargs.get('timeout')
self.store_key = "{}_{}".format(
auth_endpoint.strip('/'), self.store_key)
self.secret = None

# Adal
self._context = adal.AuthenticationContext(
auth_endpoint + '/' + tenant,
timeout=self.timeout
timeout=kwargs.get('timeout'),
verify_ssl=kwargs.get('verify'), # None will honor ADAL_PYTHON_SSL_NO_VERIFY
proxies=kwargs.get('proxies'),
api_version=None
)
# Hacking ADAL to ensure backward compat
if not self.verify:
self._context._call_context['verify_ssl'] = False

def _convert_token(self, token):
"""Convert token fields from camel case.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
'Topic :: Software Development'],
install_requires=[
"msrest>=0.4.28,<2.0.0",
"adal>=0.5.0,<2.0.0",
"adal>=0.6.0,<2.0.0",
"keyring>=12.0.2"
],
)
52 changes: 0 additions & 52 deletions tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,58 +62,6 @@ def setUp(self):
self.cfg = AzureConfiguration("https://my_service.com")
return super(TestServicePrincipalCredentials, self).setUp()

def test_http(self):

test_uri = "http://my_service.com"
build = azure_active_directory._http(test_uri, "path")

self.assertEqual(build, "http://my_service.com/path")

test_uri = "HTTPS://my_service.com"
build = azure_active_directory._http(test_uri, "path")

self.assertEqual(build, "http://my_service.com/path")

test_uri = "my_service.com"
build = azure_active_directory._http(test_uri, "path")

self.assertEqual(build, "http://my_service.com/path")

def test_https(self):

test_uri = "http://my_service.com"
build = azure_active_directory._https(test_uri, "path")

self.assertEqual(build, "https://my_service.com/path")

test_uri = "HTTPS://my_service.com"
build = azure_active_directory._https(test_uri, "path")

self.assertEqual(build, "https://my_service.com/path")

test_uri = "my_service.com"
build = azure_active_directory._https(test_uri, "path")

self.assertEqual(build, "https://my_service.com/path")


def test_check_state(self):

mix = AADMixin(None, None)
mix.state = "abc"

with self.assertRaises(ValueError):
mix._check_state("server?test")
with self.assertRaises(ValueError):
mix._check_state("server?test&abc")
with self.assertRaises(ValueError):
mix._check_state("server?test&state=xyx")
with self.assertRaises(ValueError):
mix._check_state("server?test&state=xyx&")
with self.assertRaises(ValueError):
mix._check_state("server?test&state=abcd&")
mix._check_state("server?test&state=abc&")

def test_convert_token(self):

mix = AADMixin(None, None)
Expand Down

0 comments on commit 35ae5aa

Please sign in to comment.