fix tests and lint

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens Langhammer 2023-12-17 19:39:18 +01:00
parent 8797b6309f
commit 63fea84405
No known key found for this signature in database
6 changed files with 12 additions and 12 deletions

View file

@ -169,6 +169,7 @@ class License(SerializerModel):
@classmethod @classmethod
def non_expired(cls) -> QuerySet["License"]: def non_expired(cls) -> QuerySet["License"]:
"""Filter all non expired licenses"""
return License.objects.filter(expiry__gte=now()) return License.objects.filter(expiry__gte=now())
@property @property

View file

@ -8,8 +8,8 @@ from grpc import (
UnaryUnaryClientInterceptor, UnaryUnaryClientInterceptor,
insecure_channel, insecure_channel,
intercept_channel, intercept_channel,
ssl_channel_credentials,
secure_channel, secure_channel,
ssl_channel_credentials,
) )
from grpc._interceptor import _ClientCallDetails from grpc._interceptor import _ClientCallDetails
@ -58,10 +58,10 @@ def get_enterprise_token() -> str:
try: try:
from authentik.enterprise.models import License from authentik.enterprise.models import License
license = License.non_expired().order_by("-expiry").first() valid_license = License.non_expired().order_by("-expiry").first()
if not license: if not valid_license:
return get_install_id() return get_install_id()
return license.key return valid_license.key
except ImportError: except ImportError:
return get_install_id() return get_install_id()

View file

@ -15,7 +15,6 @@ from django.http import HttpRequest
from django.utils.translation import gettext as __ from django.utils.translation import gettext as __
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from django.views import View from django.views import View
from grpc import RpcError
from rest_framework.serializers import BaseSerializer, Serializer from rest_framework.serializers import BaseSerializer, Serializer
from structlog.stdlib import get_logger from structlog.stdlib import get_logger
@ -201,8 +200,6 @@ class MobileTransaction(ExpiringModel):
) )
) )
LOGGER.debug("Sent notification", id=response, tx_id=self.tx_id) LOGGER.debug("Sent notification", id=response, tx_id=self.tx_id)
except RpcError as exc:
LOGGER.warning("failed to push", exc=exc, code=exc.code(), tx_id=self.tx_id)
except ValueError as exc: except ValueError as exc:
LOGGER.warning("failed to push", exc=exc, tx_id=self.tx_id) LOGGER.warning("failed to push", exc=exc, tx_id=self.tx_id)
return True return True

View file

@ -1,7 +1,8 @@
"""Mobile stage""" """Mobile stage"""
from django.conf import settings
from django.http import HttpResponse from django.http import HttpResponse
from rest_framework.fields import CharField from rest_framework.fields import CharField
from django.conf import settings
from authentik.core.api.utils import PassiveSerializer from authentik.core.api.utils import PassiveSerializer
from authentik.flows.challenge import ( from authentik.flows.challenge import (
Challenge, Challenge,

View file

@ -130,9 +130,8 @@ class AuthenticatorValidationChallengeResponse(ChallengeResponse):
device = MobileDevice.objects.filter(pk=challenge.get("device_uid")).first() device = MobileDevice.objects.filter(pk=challenge.get("device_uid")).first()
case "sms": case "sms":
device = SMSDevice.objects.filter(pk=int(challenge.get("device_uid"))).first() device = SMSDevice.objects.filter(pk=int(challenge.get("device_uid"))).first()
if not device: if device:
raise ValidationError("invalid challenge selected") select_challenge(self.stage.request, self.stage, device)
select_challenge(self.stage.request, self.stage, device)
return challenge return challenge
def validate_selected_stage(self, stage_pk: str) -> str: def validate_selected_stage(self, stage_pk: str) -> str:

View file

@ -95,7 +95,9 @@ extension-pkg-whitelist = ["lxml", "xmlsec"]
# Allow constants to be shorter than normal (and lowercase, for settings.py) # Allow constants to be shorter than normal (and lowercase, for settings.py)
const-rgx = "[a-zA-Z0-9_]{1,40}$" const-rgx = "[a-zA-Z0-9_]{1,40}$"
ignored-modules = ["binascii", "socket", "zlib"] ignored-modules = [
"authentik_cloud_gateway_client"
]
generated-members = ["xmlsec.constants.*", "xmlsec.tree.*", "xmlsec.template.*"] generated-members = ["xmlsec.constants.*", "xmlsec.tree.*", "xmlsec.template.*"]
ignore = ["migrations", "tests"] ignore = ["migrations", "tests"]
max-attributes = 12 max-attributes = 12