Skip to content

Commit

Permalink
[#486] Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmursa-dev committed Dec 17, 2024
1 parent a1989ec commit a43f973
Show file tree
Hide file tree
Showing 2 changed files with 373 additions and 21 deletions.
25 changes: 15 additions & 10 deletions src/objects/setup_configuration/steps/token_auth.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import logging
from typing import Any

from django.core.exceptions import ValidationError
from django.core.exceptions import ObjectDoesNotExist, ValidationError
from django.db import IntegrityError

from django_setup_configuration.configuration import BaseConfigurationStep
from django_setup_configuration.exceptions import ConfigurationRunFailed
from django_setup_configuration.exceptions import (
ConfigurationRunFailed,
PrerequisiteFailed,
)

from objects.core.models import ObjectType
from objects.setup_configuration.models.token_auth import (
Expand Down Expand Up @@ -42,13 +45,16 @@ def _configure_permissions(self, token: TokenAuth, permissions: list) -> None:
logger.warning("No permissions provided for %s", token.identifier)

for permission in permissions:
permission_kwargs = {
"token_auth": token,
"object_type": ObjectType.objects.get(uuid=permission.object_type),
"mode": permission.mode,
"use_fields": permission.use_fields,
"fields": permission.fields,
}
try:
permission_kwargs = {
"token_auth": token,
"object_type": ObjectType.objects.get(uuid=permission.object_type),
"mode": permission.mode,
"use_fields": permission.use_fields,
"fields": permission.fields,
}
except ObjectDoesNotExist as exception:
raise PrerequisiteFailed(step=self, validation_error=exception)

permission_instance = Permission(**permission_kwargs)
self._full_clean(permission_instance)
Expand Down Expand Up @@ -88,7 +94,6 @@ def execute(self, model: TokenAuthGroupConfigurationModel) -> None:

token_instance = TokenAuth(**token_kwargs)
self._full_clean(token_instance)

try:
logger.debug("Saving %s", item.identifier)
token, _ = TokenAuth.objects.update_or_create(
Expand Down
Loading

0 comments on commit a43f973

Please sign in to comment.