Merge pull request #3 from aureplop/fix/casv2-extra-attributes

Fix usage with CASClient V2
This commit is contained in:
aureplop 2018-10-21 15:26:28 +02:00 committed by GitHub
commit bebbeaf6fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View file

@ -217,7 +217,7 @@ class CASCallbackView(CASView):
# Keep tracks of the last used CAS provider. # Keep tracks of the last used CAS provider.
request.session[CAS_PROVIDER_SESSION_KEY] = self.provider.id request.session[CAS_PROVIDER_SESSION_KEY] = self.provider.id
data = (uid, extra) data = (uid, extra or {})
# Finish the login flow. # Finish the login flow.
login = self.adapter.complete_login(request, data) login = self.adapter.complete_login(request, data)

View file

@ -184,7 +184,7 @@ class CASCallbackViewTests(CASViewTestCase):
self.assertEqual('/accounts/theid/login/callback/', url) self.assertEqual('/accounts/theid/login/callback/', url)
def test_ticket_valid(self): def test_ticket_valid(self):
"""p( """
If ticket is valid, the user is logged in. If ticket is valid, the user is logged in.
""" """
self.patch_cas_response(username='username', valid_ticket='123456') self.patch_cas_response(username='username', valid_ticket='123456')
@ -211,6 +211,18 @@ class CASCallbackViewTests(CASViewTestCase):
r = self.client.get('/accounts/theid/login/callback/') r = self.client.get('/accounts/theid/login/callback/')
self.assertLoginFailure(r) 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): class CASLogoutViewTests(CASViewTestCase):