Skip to content

Commit

Permalink
fix(analytics): unregister knox.AuthToken from admin site
Browse files Browse the repository at this point in the history
Refs: LINK-2168
  • Loading branch information
harriris-vincit committed Sep 17, 2024
1 parent bc345aa commit bae087f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions data_analytics/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from django.contrib.auth import get_user_model
from django.utils import timezone
from knox import crypto
from knox.models import AuthToken
from knox.settings import CONSTANTS, knox_settings

from data_analytics.forms import DataAnalyticsApiTokenAdminForm
Expand Down Expand Up @@ -43,4 +44,5 @@ def save_model(self, request, obj, form, change):
obj.save()


admin.site.unregister(AuthToken)
admin.site.register(DataAnalyticsApiToken, DataAnalyticsApiTokenAdmin)
4 changes: 4 additions & 0 deletions data_analytics/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from django.test import TestCase
from django.utils import timezone, translation
from knox import crypto
from knox.models import AuthToken
from knox.settings import CONSTANTS, knox_settings
from rest_framework import status

Expand Down Expand Up @@ -35,6 +36,9 @@ def setUpTestData(cls):
def setUp(self):
self.client.force_login(self.admin)

def test_knox_auth_token_admin_is_not_registered(self):
self.assertFalse(admin.site.is_registered(AuthToken))

def test_local_auth_token_admin_is_registered(self):
self.assertTrue(admin.site.is_registered(DataAnalyticsApiToken))

Expand Down

0 comments on commit bae087f

Please sign in to comment.