stages/invitation: fix mis-matched serializer class for invitation (#7018)

* stages/invitation: fix mis-matched serializer class for invitation

Signed-off-by: Jens Langhammer <jens@goauthentik.io>

* fix returning an instance

Signed-off-by: Jens Langhammer <jens@goauthentik.io>

---------

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens L 2023-10-02 12:26:14 +02:00 committed by GitHub
parent 8efdbd54e8
commit 8c891b04f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -6,6 +6,7 @@ from django.test import TestCase
from authentik.blueprints.v1.importer import is_model_allowed
from authentik.lib.models import SerializerModel
from authentik.providers.oauth2.models import RefreshToken
class TestModels(TestCase):
@ -21,6 +22,9 @@ def serializer_tester_factory(test_model: Type[SerializerModel]) -> Callable:
model_class = test_model()
self.assertTrue(isinstance(model_class, SerializerModel))
self.assertIsNotNone(model_class.serializer)
if model_class.serializer.Meta().model == RefreshToken:
return
self.assertEqual(model_class.serializer.Meta().model, test_model)
return tester

View File

@ -73,12 +73,12 @@ class Invitation(SerializerModel, ExpiringModel):
@property
def serializer(self) -> Serializer:
from authentik.stages.consent.api import UserConsentSerializer
from authentik.stages.invitation.api import InvitationSerializer
return UserConsentSerializer
return InvitationSerializer
def __str__(self):
return f"Invitation {self.invite_uuid.hex} created by {self.created_by}"
return f"Invitation {str(self.invite_uuid)} created by {self.created_by}"
class Meta:
verbose_name = _("Invitation")