-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enterprise/rac: fix API Schema for invalidation_flow (#11907)
* enterprise/rac: fix API Schema for invalidation_flow Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix tests Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add tests Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io>
- Loading branch information
Showing
5 changed files
with
70 additions
and
29 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,46 @@ | ||
"""Test RAC Provider""" | ||
|
||
from datetime import timedelta | ||
from time import mktime | ||
from unittest.mock import MagicMock, patch | ||
|
||
from django.urls import reverse | ||
from django.utils.timezone import now | ||
from rest_framework.test import APITestCase | ||
|
||
from authentik.core.tests.utils import create_test_admin_user, create_test_flow | ||
from authentik.enterprise.license import LicenseKey | ||
from authentik.enterprise.models import License | ||
from authentik.lib.generators import generate_id | ||
|
||
|
||
class TestAPI(APITestCase): | ||
"""Test Provider API""" | ||
|
||
def setUp(self) -> None: | ||
self.user = create_test_admin_user() | ||
|
||
@patch( | ||
"authentik.enterprise.license.LicenseKey.validate", | ||
MagicMock( | ||
return_value=LicenseKey( | ||
aud="", | ||
exp=int(mktime((now() + timedelta(days=3000)).timetuple())), | ||
name=generate_id(), | ||
internal_users=100, | ||
external_users=100, | ||
) | ||
), | ||
) | ||
def test_create(self): | ||
"""Test creation of RAC Provider""" | ||
License.objects.create(key=generate_id()) | ||
self.client.force_login(self.user) | ||
response = self.client.post( | ||
reverse("authentik_api:racprovider-list"), | ||
data={ | ||
"name": generate_id(), | ||
"authorization_flow": create_test_flow().pk, | ||
}, | ||
) | ||
self.assertEqual(response.status_code, 201) |
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