diff --git a/src/backend/InvenTree/InvenTree/test_middleware.py b/src/backend/InvenTree/InvenTree/test_middleware.py index e00ea8a00ff..4e810594cf6 100644 --- a/src/backend/InvenTree/InvenTree/test_middleware.py +++ b/src/backend/InvenTree/InvenTree/test_middleware.py @@ -2,7 +2,6 @@ from django.conf import settings from django.http import Http404 -from django.test import tag from django.urls import reverse from error_report.models import Error @@ -11,8 +10,6 @@ from InvenTree.unit_test import InvenTreeTestCase -# TODO change test to not rely on CUI -@tag('cui') class MiddlewareTests(InvenTreeTestCase): """Test for middleware functions.""" @@ -32,22 +29,15 @@ def test_AuthRequiredMiddleware(self): # logout self.client.logout() - # check that static files go through - # TODO @matmair re-enable this check - # self.check_path('/static/css/inventree.css', 302) - # check that account things go through self.check_path(reverse('account_login')) - # logout goes directly to login - self.check_path(reverse('account_logout')) + # check that account things are rereouted + self.check_path(reverse('account_login'), 302) # check that frontend code is redirected to login - response = self.check_path(reverse('stats'), 302) - self.assertEqual(response.url, '/accounts/login/?next=/stats/') - - # check that a 401 is raised - self.check_path(reverse('settings.js'), 401) + response = self.check_path(reverse('index'), 302) + self.assertEqual(response.url, '/accounts/login/?next=/') def test_token_auth(self): """Test auth with token auth.""" @@ -58,16 +48,16 @@ def test_token_auth(self): # logout self.client.logout() # this should raise a 401 - self.check_path(reverse('settings.js'), 401) - - # request with token - self.check_path(reverse('settings.js'), HTTP_Authorization=f'Token {token}') + self.check_path(reverse('api-license'), 401) # Request with broken token - self.check_path(reverse('settings.js'), 401, HTTP_Authorization='Token abcd123') + self.check_path(reverse('api-license'), 401, HTTP_Authorization='Token abcd123') # should still fail without token - self.check_path(reverse('settings.js'), 401) + self.check_path(reverse('api-license'), 401) + + # request with token + self.check_path(reverse('api-license'), HTTP_Authorization=f'Token {token}') def test_error_exceptions(self): """Test that ignored errors are not logged.""" @@ -80,7 +70,7 @@ def check(excpected_nbr=0): # Test normal setup check() - response = self.client.get(reverse('part-detail', kwargs={'pk': 9999})) + response = self.client.get(reverse('api-part-detail', kwargs={'pk': 9999})) self.assertEqual(response.status_code, 404) check() @@ -92,13 +82,8 @@ def check(excpected_nbr=0): # Test setup without ignored errors settings.IGNORED_ERRORS = [] - response = self.client.get(reverse('part-detail', kwargs={'pk': 9999})) - self.assertEqual(response.status_code, 404) - check(1) - - # Test manual logging try: raise Http404 except Http404: log_error('testpath') - check(2) + check(1) diff --git a/src/backend/InvenTree/InvenTree/tests.py b/src/backend/InvenTree/InvenTree/tests.py index 0672e4699df..0f17f9a3d44 100644 --- a/src/backend/InvenTree/InvenTree/tests.py +++ b/src/backend/InvenTree/InvenTree/tests.py @@ -11,7 +11,7 @@ from django.contrib.auth import get_user_model from django.core import mail from django.core.exceptions import ValidationError -from django.test import TestCase, override_settings, tag +from django.test import TestCase, override_settings from django.urls import reverse from django.utils import timezone @@ -1493,8 +1493,6 @@ def test_generation(self): self.assertEqual(resp.wsgi_request.user, self.user) -# TODO - refactor to not use CUI -@tag('cui') class MaintenanceModeTest(InvenTreeTestCase): """Unit tests for maintenance mode.""" diff --git a/src/backend/InvenTree/InvenTree/urls.py b/src/backend/InvenTree/InvenTree/urls.py index 7f6d6c6b37c..601c8457314 100644 --- a/src/backend/InvenTree/InvenTree/urls.py +++ b/src/backend/InvenTree/InvenTree/urls.py @@ -477,7 +477,9 @@ frontendpatterns += [ path( 'accounts/login/', - RedirectView.as_view(url=settings.FRONTEND_URL_BASE, permanent=False), + RedirectView.as_view( + url=f'/{settings.FRONTEND_URL_BASE}', permanent=False + ), name='account_login', ) ] diff --git a/src/backend/InvenTree/build/tests.py b/src/backend/InvenTree/build/tests.py index 22d38cbeb83..01065d90aa4 100644 --- a/src/backend/InvenTree/build/tests.py +++ b/src/backend/InvenTree/build/tests.py @@ -47,6 +47,8 @@ def test_url(self): b1 = Build.objects.get(pk=1) if settings.ENABLE_CLASSIC_FRONTEND: self.assertEqual(b1.get_absolute_url(), '/build/1/') + else: + self.assertEqual(b1.get_absolute_url(), '/platform/manufacturing/build-order/1') def test_is_complete(self): """Test build completion status""" diff --git a/src/backend/InvenTree/users/tests.py b/src/backend/InvenTree/users/tests.py index 9e123bb1818..262e8dcd99b 100644 --- a/src/backend/InvenTree/users/tests.py +++ b/src/backend/InvenTree/users/tests.py @@ -2,7 +2,7 @@ from django.apps import apps from django.contrib.auth.models import Group -from django.test import TestCase, tag +from django.test import TestCase from django.urls import reverse from common.settings import set_global_setting @@ -166,8 +166,6 @@ def do_request(self, endpoint, filters, status_code=200): self.assertEqual(response.status_code, status_code) return response.data - # TODO: Find out why this depends on CUI - @tag('cui') def test_owner(self): """Tests for the 'owner' model.""" # Check that owner was created for user