mirror of
https://github.com/goauthentik/authentik.git
synced 2026-06-17 19:09:11 +03:00
remove some more usage
Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
@@ -4,6 +4,7 @@ from unittest.mock import MagicMock, patch
|
|||||||
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
|
from authentik.admin.utils import get_system_settings
|
||||||
from authentik.blueprints.tests import apply_blueprint
|
from authentik.blueprints.tests import apply_blueprint
|
||||||
from authentik.core.models import Application, Group, User
|
from authentik.core.models import Application, Group, User
|
||||||
from authentik.core.tests.utils import create_test_user
|
from authentik.core.tests.utils import create_test_user
|
||||||
@@ -18,7 +19,6 @@ from authentik.events.models import Event, EventAction
|
|||||||
from authentik.lib.generators import generate_id
|
from authentik.lib.generators import generate_id
|
||||||
from authentik.lib.sync.outgoing.models import OutgoingSyncDeleteAction
|
from authentik.lib.sync.outgoing.models import OutgoingSyncDeleteAction
|
||||||
from authentik.lib.tests.utils import load_fixture
|
from authentik.lib.tests.utils import load_fixture
|
||||||
from authentik.tenants.models import Tenant
|
|
||||||
|
|
||||||
domains_list_v1_mock = load_fixture("fixtures/domains_list_v1.json")
|
domains_list_v1_mock = load_fixture("fixtures/domains_list_v1.json")
|
||||||
|
|
||||||
@@ -30,7 +30,9 @@ class GoogleWorkspaceGroupTests(TestCase):
|
|||||||
def setUp(self) -> None:
|
def setUp(self) -> None:
|
||||||
# Delete all groups and groups as the mocked HTTP responses only return one ID
|
# Delete all groups and groups as the mocked HTTP responses only return one ID
|
||||||
# which will cause errors with multiple groups
|
# which will cause errors with multiple groups
|
||||||
Tenant.objects.update(avatars="none")
|
settings = get_system_settings()
|
||||||
|
settings.avatars = "none"
|
||||||
|
settings.save()
|
||||||
User.objects.all().exclude_anonymous().delete()
|
User.objects.all().exclude_anonymous().delete()
|
||||||
Group.objects.all().delete()
|
Group.objects.all().delete()
|
||||||
self.provider: GoogleWorkspaceProvider = GoogleWorkspaceProvider.objects.create(
|
self.provider: GoogleWorkspaceProvider = GoogleWorkspaceProvider.objects.create(
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ from unittest.mock import MagicMock, patch
|
|||||||
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
|
from authentik.admin.utils import get_system_settings
|
||||||
from authentik.blueprints.tests import apply_blueprint
|
from authentik.blueprints.tests import apply_blueprint
|
||||||
from authentik.core.models import Application, Group, User
|
from authentik.core.models import Application, Group, User
|
||||||
from authentik.enterprise.providers.google_workspace.clients.test_http import MockHTTP
|
from authentik.enterprise.providers.google_workspace.clients.test_http import MockHTTP
|
||||||
@@ -18,7 +19,6 @@ from authentik.events.models import Event, EventAction
|
|||||||
from authentik.lib.generators import generate_id
|
from authentik.lib.generators import generate_id
|
||||||
from authentik.lib.sync.outgoing.models import OutgoingSyncDeleteAction
|
from authentik.lib.sync.outgoing.models import OutgoingSyncDeleteAction
|
||||||
from authentik.lib.tests.utils import load_fixture
|
from authentik.lib.tests.utils import load_fixture
|
||||||
from authentik.tenants.models import Tenant
|
|
||||||
|
|
||||||
domains_list_v1_mock = load_fixture("fixtures/domains_list_v1.json")
|
domains_list_v1_mock = load_fixture("fixtures/domains_list_v1.json")
|
||||||
|
|
||||||
@@ -30,7 +30,9 @@ class GoogleWorkspaceUserTests(TestCase):
|
|||||||
def setUp(self) -> None:
|
def setUp(self) -> None:
|
||||||
# Delete all users and groups as the mocked HTTP responses only return one ID
|
# Delete all users and groups as the mocked HTTP responses only return one ID
|
||||||
# which will cause errors with multiple users
|
# which will cause errors with multiple users
|
||||||
Tenant.objects.update(avatars="none")
|
settings = get_system_settings()
|
||||||
|
settings.avatars = "none"
|
||||||
|
settings.save()
|
||||||
User.objects.all().exclude_anonymous().delete()
|
User.objects.all().exclude_anonymous().delete()
|
||||||
Group.objects.all().delete()
|
Group.objects.all().delete()
|
||||||
self.provider: GoogleWorkspaceProvider = GoogleWorkspaceProvider.objects.create(
|
self.provider: GoogleWorkspaceProvider = GoogleWorkspaceProvider.objects.create(
|
||||||
|
|||||||
@@ -3,12 +3,12 @@
|
|||||||
from requests_mock import Mocker
|
from requests_mock import Mocker
|
||||||
from rest_framework.test import APITestCase
|
from rest_framework.test import APITestCase
|
||||||
|
|
||||||
|
from authentik.admin.utils import get_system_settings
|
||||||
from authentik.blueprints.tests import apply_blueprint
|
from authentik.blueprints.tests import apply_blueprint
|
||||||
from authentik.core.models import Application, Group, User
|
from authentik.core.models import Application, Group, User
|
||||||
from authentik.lib.generators import generate_id
|
from authentik.lib.generators import generate_id
|
||||||
from authentik.providers.scim.models import SCIMAuthenticationMode, SCIMMapping, SCIMProvider
|
from authentik.providers.scim.models import SCIMAuthenticationMode, SCIMMapping, SCIMProvider
|
||||||
from authentik.sources.oauth.models import OAuthSource
|
from authentik.sources.oauth.models import OAuthSource
|
||||||
from authentik.tenants.models import Tenant
|
|
||||||
|
|
||||||
|
|
||||||
class TestSCIMOAuthAuth(APITestCase):
|
class TestSCIMOAuthAuth(APITestCase):
|
||||||
@@ -18,7 +18,9 @@ class TestSCIMOAuthAuth(APITestCase):
|
|||||||
def setUp(self) -> None:
|
def setUp(self) -> None:
|
||||||
# Delete all users and groups as the mocked HTTP responses only return one ID
|
# Delete all users and groups as the mocked HTTP responses only return one ID
|
||||||
# which will cause errors with multiple users
|
# which will cause errors with multiple users
|
||||||
Tenant.objects.update(avatars="none")
|
settings = get_system_settings()
|
||||||
|
settings.avatars = "none"
|
||||||
|
settings.save()
|
||||||
User.objects.all().exclude_anonymous().delete()
|
User.objects.all().exclude_anonymous().delete()
|
||||||
Group.objects.all().delete()
|
Group.objects.all().delete()
|
||||||
self.source = OAuthSource.objects.create(
|
self.source = OAuthSource.objects.create(
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ from django.utils.timezone import now
|
|||||||
from requests_mock import Mocker
|
from requests_mock import Mocker
|
||||||
from rest_framework.test import APITestCase
|
from rest_framework.test import APITestCase
|
||||||
|
|
||||||
|
from authentik.admin.utils import get_system_settings
|
||||||
from authentik.blueprints.tests import apply_blueprint
|
from authentik.blueprints.tests import apply_blueprint
|
||||||
from authentik.core.models import Application, Group, User
|
from authentik.core.models import Application, Group, User
|
||||||
from authentik.lib.generators import generate_id
|
from authentik.lib.generators import generate_id
|
||||||
from authentik.providers.scim.models import SCIMAuthenticationMode, SCIMMapping, SCIMProvider
|
from authentik.providers.scim.models import SCIMAuthenticationMode, SCIMMapping, SCIMProvider
|
||||||
from authentik.sources.oauth.models import OAuthSource, UserOAuthSourceConnection
|
from authentik.sources.oauth.models import OAuthSource, UserOAuthSourceConnection
|
||||||
from authentik.tenants.models import Tenant
|
|
||||||
from tests.live import create_test_admin_user
|
from tests.live import create_test_admin_user
|
||||||
|
|
||||||
|
|
||||||
@@ -25,7 +25,9 @@ class TestSCIMOAuthToken(APITestCase):
|
|||||||
def setUp(self) -> None:
|
def setUp(self) -> None:
|
||||||
# Delete all users and groups as the mocked HTTP responses only return one ID
|
# Delete all users and groups as the mocked HTTP responses only return one ID
|
||||||
# which will cause errors with multiple users
|
# which will cause errors with multiple users
|
||||||
Tenant.objects.update(avatars="none")
|
settings = get_system_settings()
|
||||||
|
settings.avatars = "none"
|
||||||
|
settings.save()
|
||||||
User.objects.all().exclude_anonymous().delete()
|
User.objects.all().exclude_anonymous().delete()
|
||||||
Group.objects.all().delete()
|
Group.objects.all().delete()
|
||||||
self.source = OAuthSource.objects.create(
|
self.source = OAuthSource.objects.create(
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ from channels.testing import WebsocketCommunicator
|
|||||||
from django.http import HttpRequest
|
from django.http import HttpRequest
|
||||||
from django.test import TransactionTestCase
|
from django.test import TransactionTestCase
|
||||||
|
|
||||||
|
from authentik.admin.utils import get_system_settings
|
||||||
from authentik.core.tests.utils import create_test_user
|
from authentik.core.tests.utils import create_test_user
|
||||||
from authentik.events.models import (
|
from authentik.events.models import (
|
||||||
Event,
|
Event,
|
||||||
@@ -19,15 +20,13 @@ from authentik.lib.generators import generate_id
|
|||||||
from authentik.root import websocket
|
from authentik.root import websocket
|
||||||
from authentik.stages.password import BACKEND_INBUILT
|
from authentik.stages.password import BACKEND_INBUILT
|
||||||
from authentik.stages.user_login.stage import COOKIE_NAME_KNOWN_DEVICE
|
from authentik.stages.user_login.stage import COOKIE_NAME_KNOWN_DEVICE
|
||||||
from authentik.tenants.utils import get_current_tenant
|
|
||||||
|
|
||||||
|
|
||||||
class TestClientWS(TransactionTestCase):
|
class TestClientWS(TransactionTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
tenant = get_current_tenant()
|
settings = get_system_settings()
|
||||||
tenant.flags[RefreshOtherFlowsAfterAuthentication().key] = True
|
settings.flags[RefreshOtherFlowsAfterAuthentication().key] = True
|
||||||
tenant.save()
|
settings.save()
|
||||||
self.user = create_test_user()
|
self.user = create_test_user()
|
||||||
|
|
||||||
async def _alogin_cookie(self, user, **kwargs):
|
async def _alogin_cookie(self, user, **kwargs):
|
||||||
|
|||||||
Reference in New Issue
Block a user