providers/scim: fix scim_sync_all error (#5539)

* providers/scim: fix scim_sync_all error

closes #5538

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

* don't use static names in tests

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

---------

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens L 2023-05-08 22:39:48 +02:00 committed by GitHub
parent ad2d38fa4a
commit 9c25d72d61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 8 deletions

View file

@ -35,7 +35,7 @@ def client_for_model(provider: SCIMProvider, model: Model) -> SCIMClient:
@CELERY_APP.task()
def scim_sync_all():
"""Run sync for all providers"""
for provider in SCIMProvider.objects.all(backchannel_application__isnull=False):
for provider in SCIMProvider.objects.filter(backchannel_application__isnull=False):
scim_sync.delay(provider.pk)

View file

@ -7,6 +7,7 @@ from authentik.core.models import Application
from authentik.lib.generators import generate_id
from authentik.providers.scim.clients.base import SCIMClient
from authentik.providers.scim.models import SCIMMapping, SCIMProvider
from authentik.providers.scim.tasks import scim_sync_all
class SCIMClientTests(TestCase):
@ -82,3 +83,7 @@ class SCIMClientTests(TestCase):
SCIMClient(self.provider)
self.assertEqual(mock.call_count, 1)
self.assertEqual(mock.request_history[0].method, "GET")
def test_scim_sync_all(self):
"""test scim_sync_all task"""
scim_sync_all()

View file

@ -74,7 +74,7 @@ class TestProviderProxy(SeleniumTestCase):
self.user.save()
proxy: ProxyProvider = ProxyProvider.objects.create(
name="proxy_provider",
name=generate_id(),
authorization_flow=Flow.objects.get(
slug="default-provider-authorization-implicit-consent"
),
@ -85,9 +85,9 @@ class TestProviderProxy(SeleniumTestCase):
proxy.set_oauth_defaults()
proxy.save()
# we need to create an application to actually access the proxy
Application.objects.create(name="proxy", slug="proxy", provider=proxy)
Application.objects.create(name=generate_id(), slug=generate_id(), provider=proxy)
outpost: Outpost = Outpost.objects.create(
name="proxy_outpost",
name=generate_id(),
type=OutpostType.PROXY,
)
outpost.providers.add(proxy)
@ -141,7 +141,7 @@ class TestProviderProxy(SeleniumTestCase):
self.user.save()
proxy: ProxyProvider = ProxyProvider.objects.create(
name="proxy_provider",
name=generate_id(),
authorization_flow=Flow.objects.get(
slug="default-provider-authorization-implicit-consent"
),
@ -155,9 +155,9 @@ class TestProviderProxy(SeleniumTestCase):
proxy.set_oauth_defaults()
proxy.save()
# we need to create an application to actually access the proxy
Application.objects.create(name="proxy", slug="proxy", provider=proxy)
Application.objects.create(name=generate_id(), slug=generate_id(), provider=proxy)
outpost: Outpost = Outpost.objects.create(
name="proxy_outpost",
name=generate_id(),
type=OutpostType.PROXY,
)
outpost.providers.add(proxy)
@ -219,7 +219,7 @@ class TestProviderProxyConnect(ChannelsLiveServerTestCase):
proxy.set_oauth_defaults()
proxy.save()
# we need to create an application to actually access the proxy
Application.objects.create(name="proxy", slug="proxy", provider=proxy)
Application.objects.create(name=generate_id(), slug=generate_id(), provider=proxy)
service_connection = DockerServiceConnection.objects.get(local=True)
outpost: Outpost = Outpost.objects.create(
name=generate_id(),