-
-
Notifications
You must be signed in to change notification settings - Fork 891
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into kerberos-source-reworked
- Loading branch information
Showing
42 changed files
with
707 additions
and
390 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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
"""Test Devices API""" | ||
|
||
from json import loads | ||
|
||
from django.urls import reverse | ||
from rest_framework.test import APITestCase | ||
|
||
from authentik.core.tests.utils import create_test_admin_user, create_test_user | ||
|
||
|
||
class TestDevicesAPI(APITestCase): | ||
"""Test applications API""" | ||
|
||
def setUp(self) -> None: | ||
self.admin = create_test_admin_user() | ||
self.user1 = create_test_user() | ||
self.device1 = self.user1.staticdevice_set.create() | ||
self.user2 = create_test_user() | ||
self.device2 = self.user2.staticdevice_set.create() | ||
|
||
def test_user_api(self): | ||
"""Test user API""" | ||
self.client.force_login(self.user1) | ||
response = self.client.get( | ||
reverse( | ||
"authentik_api:device-list", | ||
) | ||
) | ||
self.assertEqual(response.status_code, 200) | ||
body = loads(response.content.decode()) | ||
self.assertEqual(len(body), 1) | ||
self.assertEqual(body[0]["pk"], self.device1.pk) | ||
|
||
def test_user_api_as_admin(self): | ||
"""Test user API""" | ||
self.client.force_login(self.admin) | ||
response = self.client.get( | ||
reverse( | ||
"authentik_api:device-list", | ||
) | ||
) | ||
self.assertEqual(response.status_code, 200) | ||
body = loads(response.content.decode()) | ||
self.assertEqual(len(body), 0) | ||
|
||
def test_admin_api(self): | ||
"""Test admin API""" | ||
self.client.force_login(self.admin) | ||
response = self.client.get( | ||
reverse( | ||
"authentik_api:admin-device-list", | ||
) | ||
) | ||
self.assertEqual(response.status_code, 200) | ||
body = loads(response.content.decode()) | ||
self.assertEqual(len(body), 2) | ||
self.assertEqual({body[0]["pk"], body[1]["pk"]}, {self.device1.pk, self.device2.pk}) |
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
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
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
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
Oops, something went wrong.