mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-02-06 12:13:01 +00:00
Test custom CAS user authentication
This commit is contained in:
parent
6afa1ea40b
commit
aed9f457c3
@ -1,6 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from corres2math.tokens import email_validation_token
|
from corres2math.tokens import email_validation_token
|
||||||
|
from django.conf import settings
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.contrib.sites.models import Site
|
from django.contrib.sites.models import Site
|
||||||
@ -10,6 +11,7 @@ from django.urls import reverse
|
|||||||
from django.utils.encoding import force_bytes
|
from django.utils.encoding import force_bytes
|
||||||
from django.utils.http import urlsafe_base64_encode
|
from django.utils.http import urlsafe_base64_encode
|
||||||
|
|
||||||
|
from .auth import CustomAuthUser
|
||||||
from .models import AdminRegistration, CoachRegistration, Registration, StudentRegistration
|
from .models import AdminRegistration, CoachRegistration, Registration, StudentRegistration
|
||||||
|
|
||||||
|
|
||||||
@ -325,6 +327,15 @@ class TestRegistration(TestCase):
|
|||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertTrue(response.context["object_list"])
|
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))
|
||||||
|
|
||||||
def test_not_implemented_error(self):
|
def test_not_implemented_error(self):
|
||||||
# Only for coverage
|
# Only for coverage
|
||||||
self.assertRaises(NotImplementedError, lambda: Registration().type)
|
self.assertRaises(NotImplementedError, lambda: Registration().type)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user