-
Notifications
You must be signed in to change notification settings - Fork 207
Allowing transport layer to be customized #169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
cbe98f3
Initial commit
abhidnya13 e64332f
Iteration 1
abhidnya13 2a7d5e3
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
abhidnya13 aed0e8d
Iteration 2 rectifying tests
abhidnya13 30f7d99
Iteration 3 modifying some more failing tests
abhidnya13 34e8e16
Iteration 4
abhidnya13 f60bbb5
Removing tests whose implementation was removed
abhidnya13 d54fb8b
Iteration 5
abhidnya13 be389d5
Replacing generic exception to specific Http error
abhidnya13 dcec4af
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
abhidnya13 e37f0c3
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
abhidnya13 b3a4e09
Refactor according to new interface
abhidnya13 96988f8
Changing one reference to new interface left in the previous one
abhidnya13 1d05615
Modified one more missed change
abhidnya13 ccafcf9
Few more changes and refactor
abhidnya13 2670e25
Adding raw response to response object
abhidnya13 cb70a37
Cleaning None values
abhidnya13 53520fd
PR review iteration
abhidnya13 293b081
Removing default http client
abhidnya13 fcac05e
cleaning up
abhidnya13 229ad26
Adding deleted single empty line back
abhidnya13 340210f
Updating filtering of non values from dictionary
abhidnya13 ca8a129
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
abhidnya13 d993950
Capturing editorial changes
abhidnya13 e5ebd28
Review changes 1
abhidnya13 8901269
Fixing broken test
abhidnya13 7774be8
Cleaning up
abhidnya13 42ca7a2
PR review changes part 1
abhidnya13 d38d38d
PR review changes part 2
abhidnya13 3226bc4
PR review changes part 3
abhidnya13 90afb94
Minor indent change
abhidnya13 a1ce0d1
PR review changes part 4
abhidnya13 ad245a7
Adding back accidentally deleted blank line
abhidnya13 34bb127
Removing extra indent
abhidnya13 a745949
Minor line add in authority.py
abhidnya13 b636baa
Making changes for backward compatibility
abhidnya13 d24d575
Some more editorial changes
abhidnya13 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Cleaning up
- Loading branch information
commit 7774be83e160fff78e27df89710c31de68f38201
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,8 +2,6 @@ | |
|
|
||
| from msal.authority import * | ||
| from tests import unittest | ||
| import requests | ||
|
|
||
| from tests.http_client import MinimalHttpClient | ||
|
|
||
|
|
||
|
|
@@ -13,7 +11,8 @@ class TestAuthority(unittest.TestCase): | |
| def test_wellknown_host_and_tenant(self): | ||
| # Assert all well known authority hosts are using their own "common" tenant | ||
| for host in WELL_KNOWN_AUTHORITY_HOSTS: | ||
| a = Authority('https://{}/common'.format(host), MinimalHttpClient()) | ||
| a = Authority( | ||
| 'https://{}/common'.format(host), http_client=MinimalHttpClient()) | ||
rayluo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| self.assertEqual( | ||
| a.authorization_endpoint, | ||
| 'https://%s/common/oauth2/v2.0/authorize' % host) | ||
|
|
@@ -26,18 +25,22 @@ def test_lessknown_host_will_return_a_set_of_v1_endpoints(self): | |
| # It is probably not a strict API contract. I simply mention it here. | ||
| less_known = 'login.windows.net' # less.known.host/ | ||
| v1_token_endpoint = 'https://{}/common/oauth2/token'.format(less_known) | ||
| a = Authority('https://{}/common'.format(less_known), MinimalHttpClient()) | ||
| a = Authority( | ||
| 'https://{}/common'.format(less_known), http_client=MinimalHttpClient()) | ||
rayluo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| self.assertEqual(a.token_endpoint, v1_token_endpoint) | ||
| self.assertNotIn('v2.0', a.token_endpoint) | ||
|
|
||
| def test_unknown_host_wont_pass_instance_discovery(self): | ||
| _assert = getattr(self, "assertRaisesRegex", self.assertRaisesRegexp) # Hack | ||
| with _assert(ValueError, "invalid_instance"): | ||
| Authority('https://example.com/tenant_doesnt_matter_in_this_case', MinimalHttpClient()) | ||
| Authority('https://example.com/tenant_doesnt_matter_in_this_case', | ||
| http_client=MinimalHttpClient()) | ||
rayluo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| def test_invalid_host_skipping_validation_can_be_turned_off(self): | ||
| try: | ||
| Authority('https://example.com/invalid', validate_authority=False) | ||
| Authority( | ||
| 'https://example.com/invalid', | ||
| http_client=MinimalHttpClient(), validate_authority=False) | ||
rayluo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| except ValueError as e: | ||
| if "invalid_instance" in str(e): # Imprecise but good enough | ||
| self.fail("validate_authority=False should turn off validation") | ||
|
|
@@ -81,7 +84,8 @@ def test_memorize(self): | |
| # We use a real authority so the constructor can finish tenant discovery | ||
| authority = "https://login.microsoftonline.com/common" | ||
| self.assertNotIn(authority, Authority._domains_without_user_realm_discovery) | ||
| a = Authority(authority, MinimalHttpClient(), validate_authority=False) | ||
| a = Authority(authority, http_client=MinimalHttpClient(), | ||
| validate_authority=False) | ||
rayluo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| # We now pretend this authority supports no User Realm Discovery | ||
| class MockResponse(object): | ||
|
|
@@ -92,4 +96,4 @@ class MockResponse(object): | |
| Authority._domains_without_user_realm_discovery, | ||
| "user_realm_discovery() should memorize domains not supporting URD") | ||
| a.user_realm_discovery("[email protected]", | ||
| response="This would cause exception if memorization did not work") | ||
| response="This would cause exception if memorization did not work") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.