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.
[CI] Drop pyfakefs, use custom auth fixture
- Introduces a custom auth fixture with a few broken "plugins" and a "working" plugin to test. - Tests that the broken ones fail properly and that the working one can be used to auth. Signed-off-by: Rick Elrod <[email protected]>
- Loading branch information
Showing
9 changed files
with
82 additions
and
16 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
Empty file.
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,3 @@ | ||
import sys # noqa: F401 | ||
|
||
from nothing import this_does_not_exist # noqa: F401 |
23 changes: 23 additions & 0 deletions
23
ansible_base/tests/fixtures/authenticator_plugins/custom.py
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,23 @@ | ||
import logging | ||
|
||
from django.contrib.auth import get_user_model | ||
|
||
from ansible_base.authenticator_plugins.base import AbstractAuthenticatorPlugin | ||
|
||
logger = logging.getLogger('ansible_base.tests.fixtures.authenticator_plugins') | ||
|
||
|
||
class AuthenticatorPlugin(AbstractAuthenticatorPlugin): | ||
def __init__(self, database_instance=None, *args, **kwargs): | ||
super().__init__(database_instance, *args, **kwargs) | ||
self.configuration_encrypted_fields = [] | ||
self.type = "custom" | ||
self.set_logger(logger) | ||
self.category = "password" | ||
|
||
def authenticate(self, request, username=None, password=None, **kwargs): | ||
if username == "admin" and password == "hello123": | ||
user = get_user_model().objects.get(username=username) | ||
return user | ||
|
||
return None |
3 changes: 3 additions & 0 deletions
3
ansible_base/tests/fixtures/authenticator_plugins/really_broken.py
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,3 @@ | ||
import sys # noqa: F401 | ||
|
||
from nothing import this_does_not_exist # noqa: F401 |
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
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