Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enterprise/rac: fix API Schema for invalidation_flow #11907

Merged
merged 3 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions authentik/enterprise/providers/rac/api/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,28 @@ class RACProviderSerializer(EnterpriseRequiredMixin, ProviderSerializer):

class Meta:
model = RACProvider
fields = ProviderSerializer.Meta.fields + [
fields = [
"pk",
"name",
"authentication_flow",
"authorization_flow",
"property_mappings",
"component",
"assigned_application_slug",
"assigned_application_name",
"assigned_backchannel_application_slug",
"assigned_backchannel_application_name",
"verbose_name",
"verbose_name_plural",
"meta_model_name",
"settings",
"outpost_set",
"connection_expiry",
"delete_token_on_disconnect",
]
extra_kwargs = ProviderSerializer.Meta.extra_kwargs
extra_kwargs = {
"authorization_flow": {"required": True, "allow_null": False},
}


class RACProviderViewSet(UsedByMixin, ModelViewSet):
Expand Down
46 changes: 46 additions & 0 deletions authentik/enterprise/providers/rac/tests/test_api.py
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

Check warning on line 5 in authentik/enterprise/providers/rac/tests/test_api.py

View check run for this annotation

Codecov / codecov/patch

authentik/enterprise/providers/rac/tests/test_api.py#L3-L5

Added lines #L3 - L5 were not covered by tests

from django.urls import reverse
from django.utils.timezone import now
from rest_framework.test import APITestCase

Check warning on line 9 in authentik/enterprise/providers/rac/tests/test_api.py

View check run for this annotation

Codecov / codecov/patch

authentik/enterprise/providers/rac/tests/test_api.py#L7-L9

Added lines #L7 - L9 were not covered by tests

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

Check warning on line 14 in authentik/enterprise/providers/rac/tests/test_api.py

View check run for this annotation

Codecov / codecov/patch

authentik/enterprise/providers/rac/tests/test_api.py#L11-L14

Added lines #L11 - L14 were not covered by tests


class TestAPI(APITestCase):

Check warning on line 17 in authentik/enterprise/providers/rac/tests/test_api.py

View check run for this annotation

Codecov / codecov/patch

authentik/enterprise/providers/rac/tests/test_api.py#L17

Added line #L17 was not covered by tests
"""Test Provider API"""

def setUp(self) -> None:
self.user = create_test_admin_user()

Check warning on line 21 in authentik/enterprise/providers/rac/tests/test_api.py

View check run for this annotation

Codecov / codecov/patch

authentik/enterprise/providers/rac/tests/test_api.py#L20-L21

Added lines #L20 - L21 were not covered by tests

@patch(

Check warning on line 23 in authentik/enterprise/providers/rac/tests/test_api.py

View check run for this annotation

Codecov / codecov/patch

authentik/enterprise/providers/rac/tests/test_api.py#L23

Added line #L23 was not covered by tests
"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):

Check warning on line 35 in authentik/enterprise/providers/rac/tests/test_api.py

View check run for this annotation

Codecov / codecov/patch

authentik/enterprise/providers/rac/tests/test_api.py#L35

Added line #L35 was not covered by tests
"""Test creation of RAC Provider"""
License.objects.create(key=generate_id())
self.client.force_login(self.user)
response = self.client.post(

Check warning on line 39 in authentik/enterprise/providers/rac/tests/test_api.py

View check run for this annotation

Codecov / codecov/patch

authentik/enterprise/providers/rac/tests/test_api.py#L37-L39

Added lines #L37 - L39 were not covered by tests
reverse("authentik_api:racprovider-list"),
data={
"name": generate_id(),
"authorization_flow": create_test_flow().pk,
},
)
self.assertEqual(response.status_code, 201)

Check warning on line 46 in authentik/enterprise/providers/rac/tests/test_api.py

View check run for this annotation

Codecov / codecov/patch

authentik/enterprise/providers/rac/tests/test_api.py#L46

Added line #L46 was not covered by tests
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def test_list(self):
"name": self.provider.name,
"authentication_flow": None,
"authorization_flow": None,
"invalidation_flow": None,
"property_mappings": [],
"connection_expiry": "hours=8",
"delete_token_on_disconnect": False,
Expand Down Expand Up @@ -121,7 +120,6 @@ def test_list_superuser_full_list(self):
"name": self.provider.name,
"authentication_flow": None,
"authorization_flow": None,
"invalidation_flow": None,
"property_mappings": [],
"component": "ak-provider-rac-form",
"assigned_application_slug": self.app.slug,
Expand Down Expand Up @@ -151,7 +149,6 @@ def test_list_superuser_full_list(self):
"name": self.provider.name,
"authentication_flow": None,
"authorization_flow": None,
"invalidation_flow": None,
"property_mappings": [],
"component": "ak-provider-rac-form",
"assigned_application_slug": self.app.slug,
Expand Down
8 changes: 1 addition & 7 deletions blueprints/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -6974,7 +6974,7 @@
"spnego_server_name": {
"type": "string",
"title": "Spnego server name",
"description": "Force the use of a specific server name for SPNEGO"
"description": "Force the use of a specific server name for SPNEGO. Must be in the form HTTP@hostname"
},
"spnego_keytab": {
"type": "string",
Expand Down Expand Up @@ -13383,12 +13383,6 @@
"title": "Authorization flow",
"description": "Flow used when authorizing this provider."
},
"invalidation_flow": {
"type": "string",
"format": "uuid",
"title": "Invalidation flow",
"description": "Flow used ending the session from a provider."
},
"property_mappings": {
"type": "array",
"items": {
Expand Down
23 changes: 6 additions & 17 deletions schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42975,7 +42975,8 @@ components:
readOnly: true
spnego_server_name:
type: string
description: Force the use of a specific server name for SPNEGO
description: Force the use of a specific server name for SPNEGO. Must be
in the form HTTP@hostname
spnego_ccache:
type: string
description: Credential cache to use for SPNEGO in form type:residual
Expand Down Expand Up @@ -43144,7 +43145,8 @@ components:
be in the form TYPE:residual
spnego_server_name:
type: string
description: Force the use of a specific server name for SPNEGO
description: Force the use of a specific server name for SPNEGO. Must be
in the form HTTP@hostname
spnego_keytab:
type: string
writeOnly: true
Expand Down Expand Up @@ -48448,7 +48450,8 @@ components:
be in the form TYPE:residual
spnego_server_name:
type: string
description: Force the use of a specific server name for SPNEGO
description: Force the use of a specific server name for SPNEGO. Must be
in the form HTTP@hostname
spnego_keytab:
type: string
writeOnly: true
Expand Down Expand Up @@ -49461,10 +49464,6 @@ components:
type: string
format: uuid
description: Flow used when authorizing this provider.
invalidation_flow:
type: string
format: uuid
description: Flow used ending the session from a provider.
property_mappings:
type: array
items:
Expand Down Expand Up @@ -51696,10 +51695,6 @@ components:
type: string
format: uuid
description: Flow used when authorizing this provider.
invalidation_flow:
type: string
format: uuid
description: Flow used ending the session from a provider.
property_mappings:
type: array
items:
Expand Down Expand Up @@ -51757,7 +51752,6 @@ components:
- assigned_backchannel_application_slug
- authorization_flow
- component
- invalidation_flow
- meta_model_name
- name
- outpost_set
Expand All @@ -51781,10 +51775,6 @@ components:
type: string
format: uuid
description: Flow used when authorizing this provider.
invalidation_flow:
type: string
format: uuid
description: Flow used ending the session from a provider.
property_mappings:
type: array
items:
Expand All @@ -51801,7 +51791,6 @@ components:
description: When set to true, connection tokens will be deleted upon disconnect.
required:
- authorization_flow
- invalidation_flow
- name
RadiusCheckAccess:
type: object
Expand Down
Loading