Commit da796c6e authored by Valentin Samir's avatar Valentin Samir
Browse files

Corrects various errors spoted by travis and codacy

parent ed5e3d52
......@@ -372,7 +372,8 @@ class DjangoAuthUser(AuthUser): # pragma: no cover
# _meta.get_fields() is from the new documented _meta interface in django 1.8
field_names = [
field.attname for field in self.user._meta.get_fields() if hasattr(field, "attname")
field.attname for field in self.user._meta.get_fields()
if hasattr(field, "attname")
# backward compatibility with django 1.7
except AttributeError: # pragma: no cover (only used by django 1.7)
......@@ -115,8 +115,8 @@ def get_validated_ticket(service):
client = Client()
response = client.get('/validate', {'ticket': ticket.value, 'service': service})
assert (response.status_code == 200)
assert (response.content == b'yes\ntest\n')
assert response.status_code == 200
assert response.content == b'yes\ntest\n'
ticket = models.ServiceTicket.objects.get(value=ticket.value)
return (auth_client, ticket)
......@@ -222,6 +222,10 @@ class Http404Handler(HttpParamsHandler):
class DummyCAS(BaseHTTPServer.BaseHTTPRequestHandler):
"""A dummy CAS that validate for only one (service, ticket) used in federated mode tests"""
#: dict of the last receive GET parameters
params = None
def test_params(self):
"""check that internal and provided (service, ticket) matches"""
if (
......@@ -79,7 +79,13 @@ class LogoutMixin(object):
# If all_session is set, search all of the user sessions
if all_session:
# Iterate over all user sessions that have to be logged out
for user in users:
......@@ -228,6 +234,9 @@ class FederateAuth(CsrfExemptView):
csrf is disabled for allowing SLO requests reception.
#: current URL used as service URL by the CAS client
service_url = None
def get_cas_client(self, request, provider, renew=False):
return a CAS client object matching provider
......@@ -291,7 +300,7 @@ class FederateAuth(CsrfExemptView):
method called on GET request
:param django.http.HttpRequest request: The current request object
:param django.http.HttpRequestself. request: The current request object
:param unicode provider: Optional parameter. The user provider suffix.
# if settings.CAS_FEDERATE is not True redirect to the login page
......@@ -1053,7 +1062,7 @@ class ValidationBaseError(Exception):
def __init__(self, code, msg=""):
self.code = code
self.msg = msg
super(ValidateError, self).__init__(code)
super(ValidationBaseError, self).__init__(code)
def __str__(self):
return u"%s" % self.msg
......@@ -1066,7 +1075,11 @@ class ValidationBaseError(Exception):
:return: the rendered ``cas_server/serviceValidateError.xml`` template
:rtype: django.http.HttpResponse
return render(request, self.template, self.contex(), content_type="text/xml; charset=utf-8")
return render(
self.context(), content_type="text/xml; charset=utf-8"
class ValidateError(ValidationBaseError):
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment