Skip to content
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
10 changes: 10 additions & 0 deletions authentik/outposts/tests/test_ws.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
"""Websocket tests"""

from dataclasses import asdict
from unittest.mock import patch

from channels.routing import URLRouter
from channels.testing import WebsocketCommunicator
from django.contrib.contenttypes.models import ContentType
from django.test import TransactionTestCase

from authentik import __version__
Expand All @@ -14,6 +16,12 @@
from authentik.root import websocket


def patched__get_ct_cached(app_label, codename):
"""Caches `ContentType` instances like its `QuerySet` does."""
return ContentType.objects.get(app_label=app_label, permission__codename=codename)


@patch("guardian.shortcuts._get_ct_cached", patched__get_ct_cached)
class TestOutpostWS(TransactionTestCase):
"""Websocket tests"""

Expand All @@ -38,6 +46,7 @@
)
connected, _ = await communicator.connect()
self.assertFalse(connected)
await communicator.disconnect()

Check warning on line 49 in authentik/outposts/tests/test_ws.py

View check run for this annotation

Codecov / codecov/patch

authentik/outposts/tests/test_ws.py#L49

Added line #L49 was not covered by tests

async def test_auth_valid(self):
"""Test auth with token"""
Expand All @@ -48,6 +57,7 @@
)
connected, _ = await communicator.connect()
self.assertTrue(connected)
await communicator.disconnect()

Check warning on line 60 in authentik/outposts/tests/test_ws.py

View check run for this annotation

Codecov / codecov/patch

authentik/outposts/tests/test_ws.py#L60

Added line #L60 was not covered by tests

async def test_send(self):
"""Test sending of Hello"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@


def migrate_search_group(apps: Apps, schema_editor: BaseDatabaseSchemaEditor):
from authentik.core.models import User
from django.apps import apps as real_apps
from django.contrib.auth.management import create_permissions
from guardian.shortcuts import UserObjectPermission

db_alias = schema_editor.connection.alias

Expand Down
2 changes: 1 addition & 1 deletion authentik/root/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
TENANT_BASE_SCHEMA = "template"
PUBLIC_SCHEMA_NAME = CONFIG.get("postgresql.default_schema")

GUARDIAN_MONKEY_PATCH = False
GUARDIAN_MONKEY_PATCH_USER = False

SPECTACULAR_SETTINGS = {
"TITLE": "authentik",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependencies = [
"django-countries==7.6.1",
"django-cte==1.3.3",
"django-filter==25.1",
"django-guardian<3.0.0",
"django-guardian==3.0.0",
"django-model-utils==5.0.0",
"django-pglock==1.7.2",
"django-prometheus==2.3.1",
Expand Down
3 changes: 3 additions & 0 deletions tests/e2e/test_provider_ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from dataclasses import asdict
from time import sleep
from unittest.mock import patch

from guardian.shortcuts import assign_perm
from ldap3 import ALL, ALL_ATTRIBUTES, ALL_OPERATIONAL_ATTRIBUTES, SUBTREE, Connection, Server
Expand All @@ -15,10 +16,12 @@
from authentik.lib.generators import generate_id
from authentik.outposts.apps import MANAGED_OUTPOST
from authentik.outposts.models import Outpost, OutpostConfig, OutpostType
from authentik.outposts.tests.test_ws import patched__get_ct_cached
from authentik.providers.ldap.models import APIAccessMode, LDAPProvider
from tests.e2e.utils import SeleniumTestCase, retry


@patch("guardian.shortcuts._get_ct_cached", patched__get_ct_cached)
class TestProviderLDAP(SeleniumTestCase):
"""LDAP and Outpost e2e tests"""

Expand Down
3 changes: 3 additions & 0 deletions tests/e2e/test_provider_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from sys import platform
from time import sleep
from unittest.case import skip, skipUnless
from unittest.mock import patch

from channels.testing import ChannelsLiveServerTestCase
from jwt import decode
Expand All @@ -17,10 +18,12 @@
from authentik.lib.generators import generate_id
from authentik.outposts.models import DockerServiceConnection, Outpost, OutpostConfig, OutpostType
from authentik.outposts.tasks import outpost_connection_discovery
from authentik.outposts.tests.test_ws import patched__get_ct_cached
from authentik.providers.proxy.models import ProxyProvider
from tests.e2e.utils import SeleniumTestCase, retry


@patch("guardian.shortcuts._get_ct_cached", patched__get_ct_cached)
class TestProviderProxy(SeleniumTestCase):
"""Proxy and Outpost e2e tests"""

Expand Down
3 changes: 3 additions & 0 deletions tests/e2e/test_provider_proxy_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from pathlib import Path
from time import sleep
from unittest import skip
from unittest.mock import patch

from selenium.webdriver.common.by import By

Expand All @@ -12,10 +13,12 @@
from authentik.flows.models import Flow
from authentik.lib.generators import generate_id
from authentik.outposts.models import Outpost, OutpostType
from authentik.outposts.tests.test_ws import patched__get_ct_cached
from authentik.providers.proxy.models import ProxyMode, ProxyProvider
from tests.e2e.utils import SeleniumTestCase, retry


@patch("guardian.shortcuts._get_ct_cached", patched__get_ct_cached)
class TestProviderProxyForward(SeleniumTestCase):
"""Proxy and Outpost e2e tests"""

Expand Down
3 changes: 3 additions & 0 deletions tests/e2e/test_provider_radius.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from dataclasses import asdict
from time import sleep
from unittest.mock import patch

from pyrad.client import Client
from pyrad.dictionary import Dictionary
Expand All @@ -12,10 +13,12 @@
from authentik.flows.models import Flow
from authentik.lib.generators import generate_id, generate_key
from authentik.outposts.models import Outpost, OutpostConfig, OutpostType
from authentik.outposts.tests.test_ws import patched__get_ct_cached
from authentik.providers.radius.models import RadiusProvider
from tests.e2e.utils import SeleniumTestCase, retry


@patch("guardian.shortcuts._get_ct_cached", patched__get_ct_cached)
class TestProviderRadius(SeleniumTestCase):
"""Radius Outpost e2e tests"""

Expand Down
8 changes: 4 additions & 4 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading