mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-12 14:52:17 -06:00
Compare commits
1 Commits
21117-API_
...
21097-grap
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a54ad24b47 |
@@ -3,7 +3,7 @@ from typing import TYPE_CHECKING
|
||||
|
||||
import strawberry_django
|
||||
from strawberry import ID
|
||||
from strawberry_django import FilterLookup
|
||||
from strawberry_django import ComparisonFilterLookup, FilterLookup
|
||||
|
||||
from core.graphql.filter_mixins import ChangeLoggingMixin
|
||||
from extras.graphql.filter_mixins import CustomFieldsFilterMixin, JournalEntriesFilterMixin, TagsFilterMixin
|
||||
@@ -23,7 +23,7 @@ __all__ = (
|
||||
|
||||
@dataclass
|
||||
class BaseModelFilter:
|
||||
id: FilterLookup[ID] | None = strawberry_django.filter_field()
|
||||
id: ComparisonFilterLookup[ID] | None = strawberry_django.filter_field()
|
||||
|
||||
|
||||
class ChangeLoggedModelFilter(ChangeLoggingMixin, BaseModelFilter):
|
||||
|
||||
@@ -213,9 +213,6 @@ class Token(models.Model):
|
||||
def clean(self):
|
||||
super().clean()
|
||||
|
||||
if self.version == TokenVersionChoices.V2 and not settings.API_TOKEN_PEPPERS:
|
||||
raise ValidationError(_("Unable to save v2 tokens: API_TOKEN_PEPPERS is not defined."))
|
||||
|
||||
if self._state.adding:
|
||||
if self.pepper_id is not None and self.pepper_id not in settings.API_TOKEN_PEPPERS:
|
||||
raise ValidationError(_(
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
from datetime import timedelta
|
||||
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.test import TestCase, override_settings
|
||||
from django.test import TestCase
|
||||
from django.utils import timezone
|
||||
|
||||
from users.choices import TokenVersionChoices
|
||||
from users.models import User, Token
|
||||
from utilities.testing import create_test_user
|
||||
|
||||
@@ -95,15 +94,6 @@ class TokenTest(TestCase):
|
||||
token.refresh_from_db()
|
||||
self.assertEqual(token.description, 'New Description')
|
||||
|
||||
@override_settings(API_TOKEN_PEPPERS={})
|
||||
def test_v2_without_peppers_configured(self):
|
||||
"""
|
||||
Attempting to save a v2 token without API_TOKEN_PEPPERS defined should raise a ValidationError.
|
||||
"""
|
||||
token = Token(version=TokenVersionChoices.V2)
|
||||
with self.assertRaises(ValidationError):
|
||||
token.clean()
|
||||
|
||||
|
||||
class UserConfigTest(TestCase):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user