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:
parent
ad2d38fa4a
commit
9c25d72d61
|
@ -35,7 +35,7 @@ def client_for_model(provider: SCIMProvider, model: Model) -> SCIMClient:
|
||||||
@CELERY_APP.task()
|
@CELERY_APP.task()
|
||||||
def scim_sync_all():
|
def scim_sync_all():
|
||||||
"""Run sync for all providers"""
|
"""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)
|
scim_sync.delay(provider.pk)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ from authentik.core.models import Application
|
||||||
from authentik.lib.generators import generate_id
|
from authentik.lib.generators import generate_id
|
||||||
from authentik.providers.scim.clients.base import SCIMClient
|
from authentik.providers.scim.clients.base import SCIMClient
|
||||||
from authentik.providers.scim.models import SCIMMapping, SCIMProvider
|
from authentik.providers.scim.models import SCIMMapping, SCIMProvider
|
||||||
|
from authentik.providers.scim.tasks import scim_sync_all
|
||||||
|
|
||||||
|
|
||||||
class SCIMClientTests(TestCase):
|
class SCIMClientTests(TestCase):
|
||||||
|
@ -82,3 +83,7 @@ class SCIMClientTests(TestCase):
|
||||||
SCIMClient(self.provider)
|
SCIMClient(self.provider)
|
||||||
self.assertEqual(mock.call_count, 1)
|
self.assertEqual(mock.call_count, 1)
|
||||||
self.assertEqual(mock.request_history[0].method, "GET")
|
self.assertEqual(mock.request_history[0].method, "GET")
|
||||||
|
|
||||||
|
def test_scim_sync_all(self):
|
||||||
|
"""test scim_sync_all task"""
|
||||||
|
scim_sync_all()
|
||||||
|
|
|
@ -74,7 +74,7 @@ class TestProviderProxy(SeleniumTestCase):
|
||||||
self.user.save()
|
self.user.save()
|
||||||
|
|
||||||
proxy: ProxyProvider = ProxyProvider.objects.create(
|
proxy: ProxyProvider = ProxyProvider.objects.create(
|
||||||
name="proxy_provider",
|
name=generate_id(),
|
||||||
authorization_flow=Flow.objects.get(
|
authorization_flow=Flow.objects.get(
|
||||||
slug="default-provider-authorization-implicit-consent"
|
slug="default-provider-authorization-implicit-consent"
|
||||||
),
|
),
|
||||||
|
@ -85,9 +85,9 @@ class TestProviderProxy(SeleniumTestCase):
|
||||||
proxy.set_oauth_defaults()
|
proxy.set_oauth_defaults()
|
||||||
proxy.save()
|
proxy.save()
|
||||||
# we need to create an application to actually access the proxy
|
# 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(
|
outpost: Outpost = Outpost.objects.create(
|
||||||
name="proxy_outpost",
|
name=generate_id(),
|
||||||
type=OutpostType.PROXY,
|
type=OutpostType.PROXY,
|
||||||
)
|
)
|
||||||
outpost.providers.add(proxy)
|
outpost.providers.add(proxy)
|
||||||
|
@ -141,7 +141,7 @@ class TestProviderProxy(SeleniumTestCase):
|
||||||
self.user.save()
|
self.user.save()
|
||||||
|
|
||||||
proxy: ProxyProvider = ProxyProvider.objects.create(
|
proxy: ProxyProvider = ProxyProvider.objects.create(
|
||||||
name="proxy_provider",
|
name=generate_id(),
|
||||||
authorization_flow=Flow.objects.get(
|
authorization_flow=Flow.objects.get(
|
||||||
slug="default-provider-authorization-implicit-consent"
|
slug="default-provider-authorization-implicit-consent"
|
||||||
),
|
),
|
||||||
|
@ -155,9 +155,9 @@ class TestProviderProxy(SeleniumTestCase):
|
||||||
proxy.set_oauth_defaults()
|
proxy.set_oauth_defaults()
|
||||||
proxy.save()
|
proxy.save()
|
||||||
# we need to create an application to actually access the proxy
|
# 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(
|
outpost: Outpost = Outpost.objects.create(
|
||||||
name="proxy_outpost",
|
name=generate_id(),
|
||||||
type=OutpostType.PROXY,
|
type=OutpostType.PROXY,
|
||||||
)
|
)
|
||||||
outpost.providers.add(proxy)
|
outpost.providers.add(proxy)
|
||||||
|
@ -219,7 +219,7 @@ class TestProviderProxyConnect(ChannelsLiveServerTestCase):
|
||||||
proxy.set_oauth_defaults()
|
proxy.set_oauth_defaults()
|
||||||
proxy.save()
|
proxy.save()
|
||||||
# we need to create an application to actually access the proxy
|
# 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)
|
service_connection = DockerServiceConnection.objects.get(local=True)
|
||||||
outpost: Outpost = Outpost.objects.create(
|
outpost: Outpost = Outpost.objects.create(
|
||||||
name=generate_id(),
|
name=generate_id(),
|
||||||
|
|
Reference in a new issue