diff --git a/authentik/enterprise/providers/ssf/models.py b/authentik/enterprise/providers/ssf/models.py index 281691cc4cdc..179c895d9bb2 100644 --- a/authentik/enterprise/providers/ssf/models.py +++ b/authentik/enterprise/providers/ssf/models.py @@ -157,9 +157,3 @@ class StreamEvent(models.Model): def __str__(self): return f"Stream event {self.type}" - - def queue(self): - """Queue event to be sent""" - from authentik.enterprise.providers.ssf.tasks import send_single_ssf_event - - return send_single_ssf_event.delay(str(self.stream.uuid), str(self.uuid)) diff --git a/authentik/enterprise/providers/ssf/signals.py b/authentik/enterprise/providers/ssf/signals.py index 84763130f9c5..907deea20683 100644 --- a/authentik/enterprise/providers/ssf/signals.py +++ b/authentik/enterprise/providers/ssf/signals.py @@ -130,7 +130,7 @@ def ssf_device_post_save(sender: type[Model], instance: Device, created: bool, * @receiver(post_delete) -def ssf_device_post_delete(sender: type[Model], instance: Device, created: bool, **_): +def ssf_device_post_delete(sender: type[Model], instance: Device, **_): if not isinstance(instance, Device): return if not instance.confirmed: diff --git a/authentik/enterprise/providers/ssf/tests/test_stream.py b/authentik/enterprise/providers/ssf/tests/test_stream.py index b605f49fe9c6..1c4e5aad5b77 100644 --- a/authentik/enterprise/providers/ssf/tests/test_stream.py +++ b/authentik/enterprise/providers/ssf/tests/test_stream.py @@ -3,7 +3,7 @@ from authentik.core.models import Application from authentik.core.tests.utils import create_test_cert -from authentik.enterprise.providers.ssf.models import SSFProvider +from authentik.enterprise.providers.ssf.models import SSFProvider, Stream from authentik.lib.generators import generate_id @@ -41,6 +41,17 @@ def test_stream_add(self): }, HTTP_AUTHORIZATION=f"Bearer {self.provider.token.key}", ) - print(res) - print(res.content) self.assertEqual(res.status_code, 201) + + def test_stream_delete(self): + """delete stream""" + stream = Stream.objects.create(provider=self.provider) + res = self.client.delete( + reverse( + "authentik_providers_ssf:stream", + kwargs={"application_slug": self.application.slug, "provider": self.provider.pk}, + ), + HTTP_AUTHORIZATION=f"Bearer {self.provider.token.key}", + ) + self.assertEqual(res.status_code, 204) + self.assertFalse(Stream.objects.filter(pk=stream.pk).exists()) diff --git a/authentik/enterprise/providers/ssf/views/stream.py b/authentik/enterprise/providers/ssf/views/stream.py index 274c4cf94966..960a5474de2a 100644 --- a/authentik/enterprise/providers/ssf/views/stream.py +++ b/authentik/enterprise/providers/ssf/views/stream.py @@ -27,12 +27,12 @@ class StreamSerializer(ModelSerializer): aud = ListField(child=CharField()) def create(self, validated_data): - iss = self._context["request"].build_absolute_uri( + iss = self.context["request"].build_absolute_uri( reverse( "authentik_providers_ssf:configuration", kwargs={ - "application_slug": self.provider.application.slug, - "provider": self.provider.pk, + "application_slug": validated_data["provider"].application.slug, + "provider": validated_data["provider"].pk, }, ) ) @@ -81,7 +81,7 @@ def get_events_supported(self, instance: Stream) -> list[str]: class StreamView(SSFView): def post(self, request: Request, *args, **kwargs) -> Response: - stream = StreamSerializer(data=request.data) + stream = StreamSerializer(data=request.data, context={"request": request}) stream.is_valid(raise_exception=True) instance: Stream = stream.save(provider=self.provider) send_ssf_event( diff --git a/authentik/lib/config.py b/authentik/lib/config.py index d7e78ea2dc28..430bd41f01f8 100644 --- a/authentik/lib/config.py +++ b/authentik/lib/config.py @@ -288,7 +288,9 @@ def get_optional_int(self, path: str, default=None) -> int | None: return int(value) except (ValueError, TypeError) as exc: if value is None or (isinstance(value, str) and value.lower() == "null"): - return None + return default + if value is UNSET: + return default self.log("warning", "Failed to parse config as int", path=path, exc=str(exc)) return default