diff --git a/apps/registration/auth.py b/apps/registration/auth.py index d2febf4..f84b1f0 100644 --- a/apps/registration/auth.py +++ b/apps/registration/auth.py @@ -1,7 +1,7 @@ -from cas_server.auth import DjangoAuthUser +from cas_server.auth import DjangoAuthUser # pragma: no cover -class CustomAuthUser(DjangoAuthUser): +class CustomAuthUser(DjangoAuthUser): # pragma: no cover """ Override Django Auth User model to define a custom Matrix username. """ diff --git a/apps/registration/tests.py b/apps/registration/tests.py index 2db3763..4c464c9 100644 --- a/apps/registration/tests.py +++ b/apps/registration/tests.py @@ -1,7 +1,6 @@ import os from corres2math.tokens import email_validation_token -from django.conf import settings from django.contrib.auth.models import User from django.contrib.contenttypes.models import ContentType from django.contrib.sites.models import Site @@ -11,7 +10,6 @@ from django.urls import reverse from django.utils.encoding import force_bytes from django.utils.http import urlsafe_base64_encode -from .auth import CustomAuthUser from .models import AdminRegistration, CoachRegistration, StudentRegistration @@ -326,12 +324,3 @@ class TestRegistration(TestCase): self.student.registration.get_student_class_display()) self.assertEqual(response.status_code, 200) self.assertTrue(response.context["object_list"]) - - def test_init_cas(self): - """ - Load custom CAS authentication - """ - self.assertEqual(settings.CAS_AUTH_CLASS, "registration.auth.CustomAuthUser") - attr = CustomAuthUser(self.user.username).attributs() - self.assertEqual(attr["matrix_username"], self.user.registration.matrix_username) - self.assertEqual(attr["display_name"], str(self.user.registration)) diff --git a/corres2math/settings.py b/corres2math/settings.py index 25d1362..7f1e52b 100644 --- a/corres2math/settings.py +++ b/corres2math/settings.py @@ -51,7 +51,6 @@ INSTALLED_APPS = [ 'django.forms', 'bootstrap_datepicker_plus', - 'cas_server', 'crispy_forms', 'django_tables2', 'haystack', @@ -68,6 +67,7 @@ INSTALLED_APPS = [ if "test" not in sys.argv: # pragma: no cover INSTALLED_APPS += [ + 'cas_server', 'django_extensions', 'mailer', ] diff --git a/corres2math/urls.py b/corres2math/urls.py index 380cd71..1947023 100644 --- a/corres2math/urls.py +++ b/corres2math/urls.py @@ -13,6 +13,7 @@ Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ +from django.conf import settings from django.contrib import admin from django.urls import include, path from django.views.defaults import bad_request, page_not_found, permission_denied, server_error @@ -35,11 +36,14 @@ urlpatterns = [ path('media/authorization/photo//', PhotoAuthorizationView.as_view(), name='photo_authorization'), - path('cas/', include('cas_server.urls', namespace="cas_server")), - path('', include('eastereggs.urls')), ] +if 'cas_server' in settings.INSTALLED_APPS: # pragma: no cover + urlpatterns += [ + path('cas/', include('cas_server.urls', namespace="cas_server")), + ] + handler400 = bad_request handler403 = permission_denied handler404 = page_not_found diff --git a/tox.ini b/tox.ini index 9a86cd3..37ce64c 100644 --- a/tox.ini +++ b/tox.ini @@ -12,7 +12,6 @@ deps = coverage Django~=3.1 django-bootstrap-datepicker-plus~=3.0 - django-cas-server~=1.2 django-crispy-forms~=1.9 django-filter~=2.3 django-haystack~=3.0