Skip to content

Commit

Permalink
Merge branch 'issue/django-setup-configuration-tokens' into issue/dja…
Browse files Browse the repository at this point in the history
…ngo-setup-configuration-mozilla-django-oidc-db
  • Loading branch information
danielmursa-dev committed Dec 13, 2024
2 parents 95031cd + d6df41a commit 7ebced9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/objecttypes/setup_configuration/steps/token_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class TokenAuthConfigurationStep(

def execute(self, model: TokenAuthGroupConfigurationModel) -> None:
if len(model.items) == 0:
logger.warning(f"No tokens provided for configuration")
logger.warning("No tokens provided for configuration")

for item in model.items:
logger.info(f"Configuring {item.identifier}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ class Migration(migrations.Migration):
field=models.CharField(
max_length=40,
unique=True,
validators=[objecttypes.token.validators.validate_no_whitespace],
validators=[
objecttypes.token.validators.validate_no_empty,
objecttypes.token.validators.validate_no_whitespace,
],
verbose_name="token",
),
),
Expand Down
2 changes: 1 addition & 1 deletion src/objecttypes/token/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.db import models
from django.utils.translation import gettext_lazy as _

from objecttypes.token.validators import validate_no_whitespace, validate_no_empty
from objecttypes.token.validators import validate_no_empty, validate_no_whitespace


class TokenAuth(models.Model):
Expand Down
15 changes: 14 additions & 1 deletion src/objecttypes/token/tests/test_validators.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
from django.core.exceptions import ValidationError
from django.test import SimpleTestCase

from objecttypes.token.validators import validate_no_whitespace, validate_no_empty
from objecttypes.token.validators import validate_no_empty, validate_no_whitespace


class NoEmptyValidatorTestCase(SimpleTestCase):
def test_valid(self):
self.assertIsNone(validate_no_empty("test123"))

def test_invalid_string(self):
with self.assertRaises(ValidationError):
validate_no_empty("")

def test_invalid_none(self):
with self.assertRaises(ValidationError):
validate_no_empty(None)


class NoEmptyValidatorTestCase(SimpleTestCase):
Expand Down

0 comments on commit 7ebced9

Please sign in to comment.