diff --git a/allauth_cas/views.py b/allauth_cas/views.py index d2ea9b7..b27b3c7 100644 --- a/allauth_cas/views.py +++ b/allauth_cas/views.py @@ -217,7 +217,7 @@ class CASCallbackView(CASView): # Keep tracks of the last used CAS provider. request.session[CAS_PROVIDER_SESSION_KEY] = self.provider.id - data = (uid, extra) + data = (uid, extra or {}) # Finish the login flow. login = self.adapter.complete_login(request, data) diff --git a/tests/test_views.py b/tests/test_views.py index ebae670..e7b04e1 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -184,7 +184,7 @@ class CASCallbackViewTests(CASViewTestCase): self.assertEqual('/accounts/theid/login/callback/', url) def test_ticket_valid(self): - """p( + """ If ticket is valid, the user is logged in. """ self.patch_cas_response(username='username', valid_ticket='123456') @@ -211,6 +211,18 @@ class CASCallbackViewTests(CASViewTestCase): r = self.client.get('/accounts/theid/login/callback/') self.assertLoginFailure(r) + def test_attributes_is_none(self): + """ + Without extra attributes, CASClientV2 of python-cas returns None. + """ + self.patch_cas_response( + username='username', valid_ticket='123456', attributes=None + ) + r = self.client.get('/accounts/theid/login/callback/', { + 'ticket': '123456', + }) + self.assertLoginSuccess(r) + class CASLogoutViewTests(CASViewTestCase):