root: reformat with latest black version and fix tests (#8376)

* format files

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

* fix pyright

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

* revert #8367

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

* sigh

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

---------

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens L
2024-01-31 15:24:45 +01:00
committed by GitHub
parent 0b83d1008e
commit 8949464294
687 changed files with 744 additions and 55 deletions

View File

@ -1,4 +1,5 @@
"""authentik root module"""
from os import environ
from typing import Optional

View File

@ -1,4 +1,5 @@
"""Meta API"""
from drf_spectacular.utils import extend_schema
from rest_framework.fields import CharField
from rest_framework.permissions import IsAuthenticated

View File

@ -1,4 +1,5 @@
"""authentik administration metrics"""
from datetime import timedelta
from django.db.models.functions import ExtractHour

View File

@ -1,4 +1,5 @@
"""authentik administration overview"""
import platform
from datetime import datetime
from sys import version as python_version

View File

@ -1,4 +1,5 @@
"""authentik administration overview"""
from django.core.cache import cache
from drf_spectacular.utils import extend_schema
from packaging.version import parse

View File

@ -1,4 +1,5 @@
"""authentik administration overview"""
from django.conf import settings
from drf_spectacular.utils import extend_schema, inline_serializer
from rest_framework.fields import IntegerField

View File

@ -1,4 +1,5 @@
"""authentik admin app config"""
from prometheus_client import Gauge, Info
from authentik.blueprints.apps import ManagedAppConfig

View File

@ -1,4 +1,5 @@
"""authentik admin settings"""
from celery.schedules import crontab
from authentik.lib.utils.time import fqdn_rand

View File

@ -1,4 +1,5 @@
"""admin signals"""
from django.dispatch import receiver
from authentik.admin.apps import GAUGE_WORKERS

View File

@ -1,4 +1,5 @@
"""authentik admin tasks"""
import re
from django.core.cache import cache

View File

@ -1,4 +1,5 @@
"""test admin api"""
from json import loads
from django.test import TestCase

View File

@ -1,4 +1,5 @@
"""test admin tasks"""
from django.core.cache import cache
from django.test import TestCase
from requests_mock import Mocker

View File

@ -1,4 +1,5 @@
"""API URLs"""
from django.urls import path
from authentik.admin.api.meta import AppsViewSet, ModelViewSet

View File

@ -1,4 +1,5 @@
"""API Authentication"""
from hmac import compare_digest
from typing import Any, Optional

View File

@ -1,4 +1,5 @@
"""API Authorization"""
from django.conf import settings
from django.db.models import Model
from django.db.models.query import QuerySet

View File

@ -1,4 +1,5 @@
"""API Decorators"""
from functools import wraps
from typing import Callable, Optional

View File

@ -1,4 +1,5 @@
"""Pagination which includes total pages and current page"""
from rest_framework import pagination
from rest_framework.response import Response

View File

@ -1,4 +1,5 @@
"""Error Response schema, from https://github.com/axnsan12/drf-yasg/issues/224"""
from django.utils.translation import gettext_lazy as _
from drf_spectacular.generators import SchemaGenerator
from drf_spectacular.plumbing import (

View File

@ -1,4 +1,5 @@
"""Test API Authentication"""
import json
from base64 import b64encode

View File

@ -1,4 +1,5 @@
"""Test config API"""
from json import loads
from django.urls import reverse

View File

@ -1,4 +1,5 @@
"""test decorators api"""
from django.urls import reverse
from guardian.shortcuts import assign_perm
from rest_framework.test import APITestCase

View File

@ -1,4 +1,5 @@
"""Schema generation tests"""
from django.urls import reverse
from rest_framework.test import APITestCase
from yaml import safe_load

View File

@ -1,4 +1,5 @@
"""authentik API Modelviewset tests"""
from typing import Callable
from django.test import TestCase

View File

@ -1,4 +1,5 @@
"""authentik api urls"""
from django.urls import include, path
from authentik.api.v3.urls import urlpatterns as v3_urls

View File

@ -1,4 +1,5 @@
"""core Configs API"""
from pathlib import Path
from django.conf import settings

View File

@ -1,4 +1,5 @@
"""api v3 urls"""
from importlib import import_module
from django.urls import path

View File

@ -1,4 +1,5 @@
"""General API Views"""
from typing import Any
from django.urls import reverse

View File

@ -1,4 +1,5 @@
"""Serializer mixin for managed models"""
from django.utils.translation import gettext_lazy as _
from drf_spectacular.utils import extend_schema, inline_serializer
from rest_framework.decorators import action

View File

@ -1,4 +1,5 @@
"""Apply blueprint from commandline"""
from sys import exit as sys_exit
from django.core.management.base import BaseCommand, no_translations

View File

@ -1,4 +1,5 @@
"""Export blueprint of current authentik install"""
from django.core.management.base import no_translations
from structlog.stdlib import get_logger

View File

@ -1,4 +1,5 @@
"""Generate JSON Schema for blueprints"""
from json import dumps
from typing import Any

View File

@ -1,4 +1,5 @@
"""blueprint models"""
from pathlib import Path
from uuid import uuid4

View File

@ -1,4 +1,5 @@
"""blueprint Settings"""
from celery.schedules import crontab
from authentik.lib.utils.time import fqdn_rand

View File

@ -1,4 +1,5 @@
"""Blueprint helpers"""
from functools import wraps
from typing import Callable

View File

@ -1,4 +1,5 @@
"""authentik managed models tests"""
from django.test import TestCase
from authentik.blueprints.models import BlueprintInstance, BlueprintRetrievalFailed

View File

@ -1,4 +1,5 @@
"""Test blueprints OCI"""
from django.test import TransactionTestCase
from requests_mock import Mocker

View File

@ -1,4 +1,5 @@
"""test packaged blueprints"""
from pathlib import Path
from typing import Callable

View File

@ -1,4 +1,5 @@
"""authentik managed models tests"""
from typing import Callable, Type
from django.apps import apps

View File

@ -1,4 +1,5 @@
"""Test blueprints v1"""
from os import environ
from django.test import TransactionTestCase

View File

@ -1,4 +1,5 @@
"""Test blueprints v1 api"""
from json import loads
from tempfile import NamedTemporaryFile, mkdtemp

View File

@ -1,4 +1,5 @@
"""Test blueprints v1"""
from django.test import TransactionTestCase
from authentik.blueprints.v1.importer import Importer

View File

@ -1,4 +1,5 @@
"""Test blueprints v1"""
from django.test import TransactionTestCase
from authentik.blueprints.v1.importer import Importer

View File

@ -1,4 +1,5 @@
"""Test blueprints v1"""
from django.test import TransactionTestCase
from authentik.blueprints.v1.importer import Importer

View File

@ -1,4 +1,5 @@
"""Test blueprints v1 tasks"""
from hashlib import sha512
from tempfile import NamedTemporaryFile, mkdtemp

View File

@ -1,4 +1,5 @@
"""API URLs"""
from authentik.blueprints.api import BlueprintInstanceViewSet
api_urlpatterns = [

View File

@ -1,4 +1,5 @@
"""transfer common classes"""
from collections import OrderedDict
from copy import copy
from dataclasses import asdict, dataclass, field, is_dataclass

View File

@ -1,4 +1,5 @@
"""Blueprint exporter"""
from typing import Iterable
from uuid import UUID

View File

@ -1,4 +1,5 @@
"""Blueprint importer"""
from contextlib import contextmanager
from copy import deepcopy
from typing import Any, Optional

View File

@ -1,4 +1,5 @@
"""Apply Blueprint meta model"""
from typing import TYPE_CHECKING
from rest_framework.exceptions import ValidationError

View File

@ -1,4 +1,5 @@
"""Base models"""
from django.apps import apps
from django.db.models import Model
from rest_framework.serializers import Serializer

View File

@ -1,4 +1,5 @@
"""OCI Client"""
from typing import Any
from urllib.parse import ParseResult, urlparse

View File

@ -1,4 +1,5 @@
"""v1 blueprints tasks"""
from dataclasses import asdict, dataclass, field
from hashlib import sha512
from pathlib import Path

View File

@ -1,4 +1,5 @@
"""Serializer for brands models"""
from typing import Any
from django.db import models

View File

@ -1,4 +1,5 @@
"""authentik brands app"""
from django.apps import AppConfig

View File

@ -1,4 +1,5 @@
"""Inject brand into current request"""
from typing import Callable
from django.http.request import HttpRequest

View File

@ -1,4 +1,5 @@
"""brand models"""
from uuid import uuid4
from django.db import models

View File

@ -1,4 +1,5 @@
"""Test brands"""
from django.urls import reverse
from rest_framework.test import APITestCase

View File

@ -1,4 +1,5 @@
"""API URLs"""
from authentik.brands.api import BrandViewSet
api_urlpatterns = [

View File

@ -1,4 +1,5 @@
"""Brand utilities"""
from typing import Any
from django.db.models import F, Q

View File

@ -1,4 +1,5 @@
"""Application API Views"""
from copy import copy
from datetime import timedelta
from typing import Optional

View File

@ -1,4 +1,5 @@
"""AuthenticatedSessions API Viewset"""
from typing import Optional, TypedDict
from django_filters.rest_framework import DjangoFilterBackend

View File

@ -1,4 +1,5 @@
"""Authenticator Devices API Views"""
from drf_spectacular.types import OpenApiTypes
from drf_spectacular.utils import OpenApiParameter, extend_schema
from rest_framework.fields import BooleanField, CharField, IntegerField, SerializerMethodField

View File

@ -1,4 +1,5 @@
"""Groups API Viewset"""
from json import loads
from typing import Optional

View File

@ -1,4 +1,5 @@
"""PropertyMapping API Views"""
from json import dumps
from drf_spectacular.types import OpenApiTypes

View File

@ -1,4 +1,5 @@
"""Provider API Views"""
from django.db.models import QuerySet
from django.db.models.query import Q
from django.utils.translation import gettext_lazy as _

View File

@ -1,4 +1,5 @@
"""Source API Views"""
from typing import Iterable
from django_filters.rest_framework import DjangoFilterBackend

View File

@ -1,4 +1,5 @@
"""Tokens API Viewset"""
from typing import Any
from django_filters.rest_framework import DjangoFilterBackend

View File

@ -1,4 +1,5 @@
"""transactional application and provider creation"""
from django.apps import apps
from drf_spectacular.utils import PolymorphicProxySerializer, extend_schema, extend_schema_field
from rest_framework.exceptions import ValidationError

View File

@ -1,4 +1,5 @@
"""used_by mixin"""
from enum import Enum
from inspect import getmembers

View File

@ -1,4 +1,5 @@
"""User API Views"""
from datetime import timedelta
from json import loads
from typing import Any, Optional

View File

@ -1,4 +1,5 @@
"""API Utilities"""
from typing import Any
from django.db.models import Model

View File

@ -1,4 +1,5 @@
"""authentik core app config"""
from django.conf import settings
from authentik.blueprints.apps import ManagedAppConfig

View File

@ -1,4 +1,5 @@
"""Channels base classes"""
from channels.db import database_sync_to_async
from channels.exceptions import DenyConnection
from rest_framework.exceptions import AuthenticationFailed

View File

@ -1,4 +1,5 @@
"""authentik core exceptions"""
from authentik.lib.sentry import SentryIgnoredException

View File

@ -1,4 +1,5 @@
"""Property Mapping Evaluator"""
from typing import Any, Optional
from django.db.models import Model

View File

@ -1,4 +1,5 @@
"""Run bootstrap tasks"""
from django.core.management.base import BaseCommand
from django_tenants.utils import get_public_schema_name

View File

@ -1,4 +1,5 @@
"""Build source docs"""
from pathlib import Path
from django.core.management.base import BaseCommand

View File

@ -1,4 +1,5 @@
"""custom runserver command"""
from daphne.management.commands.runserver import Command as RunServer

View File

@ -1,4 +1,5 @@
"""Repair missing permissions"""
from django.apps import apps
from django.contrib.auth.management import create_permissions
from django.core.management.base import BaseCommand, no_translations

View File

@ -1,4 +1,5 @@
"""authentik shell command"""
import code
import platform
import sys

View File

@ -1,4 +1,5 @@
"""Run worker"""
from sys import exit as sysexit
from tempfile import tempdir

View File

@ -1,4 +1,5 @@
"""authentik admin Middleware to impersonate users"""
from contextvars import ContextVar
from typing import Callable, Optional
from uuid import uuid4

View File

@ -1,4 +1,5 @@
"""authentik core models"""
from datetime import timedelta
from hashlib import sha256
from typing import Any, Optional, Self

View File

@ -1,4 +1,5 @@
"""authentik core signals"""
from django.contrib.auth.signals import user_logged_in, user_logged_out
from django.contrib.sessions.backends.cache import KEY_PREFIX
from django.core.cache import cache

View File

@ -1,4 +1,5 @@
"""Source decision helper"""
from enum import Enum
from typing import Any, Optional

View File

@ -1,4 +1,5 @@
"""Source flow manager stages"""
from django.http import HttpRequest, HttpResponse
from authentik.core.models import User, UserSourceConnection

View File

@ -1,4 +1,5 @@
"""authentik core tasks"""
from datetime import datetime, timedelta
from django.contrib.sessions.backends.cache import KEY_PREFIX

View File

@ -1,4 +1,5 @@
"""Test API Utils"""
from rest_framework.exceptions import ValidationError
from rest_framework.test import APITestCase

View File

@ -1,4 +1,5 @@
"""Test Applications API"""
from json import loads
from django.core.files.base import ContentFile

View File

@ -1,4 +1,5 @@
"""Test Applications API"""
from unittest.mock import MagicMock, patch
from django.urls import reverse

View File

@ -1,4 +1,5 @@
"""Test AuthenticatedSessions API"""
from json import loads
from django.urls.base import reverse

View File

@ -1,4 +1,5 @@
"""group tests"""
from django.test.testcases import TestCase
from authentik.core.models import Group, User

View File

@ -1,4 +1,5 @@
"""Test Groups API"""
from django.urls.base import reverse
from rest_framework.test import APITestCase

View File

@ -1,4 +1,5 @@
"""impersonation tests"""
from json import loads
from django.urls import reverse

View File

@ -1,4 +1,5 @@
"""authentik core models tests"""
from time import sleep
from typing import Callable

View File

@ -1,4 +1,5 @@
"""authentik core property mapping tests"""
from django.test import RequestFactory, TestCase
from guardian.shortcuts import get_anonymous_user

View File

@ -1,4 +1,5 @@
"""Test property mappings API"""
from json import dumps
from django.urls import reverse

View File

@ -1,4 +1,5 @@
"""Test providers API"""
from django.urls import reverse
from rest_framework.test import APITestCase

View File

@ -1,4 +1,5 @@
"""Test Source flow_manager"""
from django.contrib.auth.models import AnonymousUser
from django.test import TestCase
from guardian.utils import get_anonymous_user

View File

@ -1,4 +1,5 @@
"""Test tasks"""
from time import mktime
from django.utils.timezone import now

Some files were not shown because too many files have changed in this diff Show More