forked from ansible/django-ansible-base
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RR] Obtain an auth token given user/pw
Signed-off-by: Rick Elrod <[email protected]>
- Loading branch information
Showing
7 changed files
with
93 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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 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
Empty file.
This file contains 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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
def test_settings_override_mutable(settings_override_mutable, settings): | ||
""" | ||
Ensure that when we modify a mutable setting, it gets reverted. | ||
""" | ||
assert settings.LOGGING['handlers']['console']['formatter'] == "simple" | ||
|
||
with settings_override_mutable('LOGGING'): | ||
settings.LOGGING['handlers']['console']['formatter'] = "not so simple" | ||
assert settings.LOGGING['handlers']['console']['formatter'] == "not so simple" | ||
|
||
del settings.LOGGING['handlers']['console']['formatter'] | ||
assert 'formattter' not in settings.LOGGING['handlers']['console'] | ||
|
||
assert settings.LOGGING['handlers']['console']['formatter'] == "simple" |
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from ansible_base.lib.utils.response import get_relative_url | ||
|
||
|
||
def test_validate_local_user(unauthenticated_api_client, admin_user, local_authenticator, settings_override_mutable, settings): | ||
url = get_relative_url('validate-local-account') | ||
data = { | ||
"username": admin_user.username, | ||
"password": "password", | ||
} | ||
response = unauthenticated_api_client.post(url, data=data) | ||
assert response.status_code == 200 | ||
assert 'ansible_id' in response.data | ||
assert response.data['auth_code'] is not None | ||
|
||
# If we're missing RESOURCE_SERVER, we can't generate an auth code, so return null instead. | ||
with settings_override_mutable('RESOURCE_SERVER'): | ||
delattr(settings, 'RESOURCE_SERVER') | ||
|
||
response = unauthenticated_api_client.post(url, data=data) | ||
assert response.status_code == 200 | ||
assert 'ansible_id' in response.data | ||
assert response.data['auth_code'] is None |
This file contains 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