-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #283 from intuitem/feat/implement-knox-token-authe…
…ntication Implement django-rest-knox token authentication
- Loading branch information
Showing
10 changed files
with
177 additions
and
134 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
from test_vars import GROUPS_PERMISSIONS | ||
from iam.models import User, UserGroup | ||
from core.apps import startup | ||
from knox.auth import AuthToken | ||
|
||
|
||
class Test(dict): | ||
|
@@ -30,14 +31,24 @@ def authenticated_client(app_config): | |
admin = User.objects.create_superuser("[email protected]") | ||
UserGroup.objects.get(name="BI-UG-ADM").user_set.add(admin) | ||
client = APIClient() | ||
client.force_login(admin) | ||
_auth_token = AuthToken.objects.create(user=admin) | ||
auth_token = _auth_token[1] | ||
client.credentials(HTTP_AUTHORIZATION=f"Token {auth_token}") | ||
return client | ||
|
||
|
||
@pytest.fixture( | ||
params=[(role, folder) for role in GROUPS_PERMISSIONS.keys() for folder in ["test", "test_outside_domain"]], | ||
ids=[GROUPS_PERMISSIONS[key]["name"]+folder_name for key in GROUPS_PERMISSIONS.keys() for folder_name in ["", "_outside_domain"]] | ||
) | ||
params=[ | ||
(role, folder) | ||
for role in GROUPS_PERMISSIONS.keys() | ||
for folder in ["test", "test_outside_domain"] | ||
], | ||
ids=[ | ||
GROUPS_PERMISSIONS[key]["name"] + folder_name | ||
for key in GROUPS_PERMISSIONS.keys() | ||
for folder_name in ["", "_outside_domain"] | ||
], | ||
) | ||
def test(authenticated_client, request) -> Test: | ||
"""Get the elements used by the tests such as client and associated folder""" | ||
client, folder, assigned_folder = EndpointTestsUtils.get_test_client_and_folder( | ||
|
Oops, something went wrong.