Corrects various errors spoted by travis and codacy
This commit is contained in:
parent
ed5e3d5226
commit
da796c6e01
@ -372,7 +372,8 @@ class DjangoAuthUser(AuthUser): # pragma: no cover
|
|||||||
# _meta.get_fields() is from the new documented _meta interface in django 1.8
|
# _meta.get_fields() is from the new documented _meta interface in django 1.8
|
||||||
try:
|
try:
|
||||||
field_names = [
|
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
|
# backward compatibility with django 1.7
|
||||||
except AttributeError: # pragma: no cover (only used by 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()
|
client = Client()
|
||||||
response = client.get('/validate', {'ticket': ticket.value, 'service': service})
|
response = client.get('/validate', {'ticket': ticket.value, 'service': service})
|
||||||
assert (response.status_code == 200)
|
assert response.status_code == 200
|
||||||
assert (response.content == b'yes\ntest\n')
|
assert response.content == b'yes\ntest\n'
|
||||||
|
|
||||||
ticket = models.ServiceTicket.objects.get(value=ticket.value)
|
ticket = models.ServiceTicket.objects.get(value=ticket.value)
|
||||||
return (auth_client, ticket)
|
return (auth_client, ticket)
|
||||||
@ -222,6 +222,10 @@ class Http404Handler(HttpParamsHandler):
|
|||||||
|
|
||||||
class DummyCAS(BaseHTTPServer.BaseHTTPRequestHandler):
|
class DummyCAS(BaseHTTPServer.BaseHTTPRequestHandler):
|
||||||
"""A dummy CAS that validate for only one (service, ticket) used in federated mode tests"""
|
"""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):
|
def test_params(self):
|
||||||
"""check that internal and provided (service, ticket) matches"""
|
"""check that internal and provided (service, ticket) matches"""
|
||||||
if (
|
if (
|
||||||
|
@ -79,7 +79,13 @@ class LogoutMixin(object):
|
|||||||
|
|
||||||
# If all_session is set, search all of the user sessions
|
# If all_session is set, search all of the user sessions
|
||||||
if all_session:
|
if all_session:
|
||||||
users.extend(models.User.objects.filter(username=username))
|
users.extend(
|
||||||
|
models.User.objects.filter(
|
||||||
|
username=username
|
||||||
|
).exclude(
|
||||||
|
session_key=self.request.session.session_key
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
# Iterate over all user sessions that have to be logged out
|
# Iterate over all user sessions that have to be logged out
|
||||||
for user in users:
|
for user in users:
|
||||||
@ -228,6 +234,9 @@ class FederateAuth(CsrfExemptView):
|
|||||||
csrf is disabled for allowing SLO requests reception.
|
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):
|
def get_cas_client(self, request, provider, renew=False):
|
||||||
"""
|
"""
|
||||||
return a CAS client object matching provider
|
return a CAS client object matching provider
|
||||||
@ -291,7 +300,7 @@ class FederateAuth(CsrfExemptView):
|
|||||||
"""
|
"""
|
||||||
method called on GET request
|
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.
|
:param unicode provider: Optional parameter. The user provider suffix.
|
||||||
"""
|
"""
|
||||||
# if settings.CAS_FEDERATE is not True redirect to the login page
|
# if settings.CAS_FEDERATE is not True redirect to the login page
|
||||||
@ -1053,7 +1062,7 @@ class ValidationBaseError(Exception):
|
|||||||
def __init__(self, code, msg=""):
|
def __init__(self, code, msg=""):
|
||||||
self.code = code
|
self.code = code
|
||||||
self.msg = msg
|
self.msg = msg
|
||||||
super(ValidateError, self).__init__(code)
|
super(ValidationBaseError, self).__init__(code)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return u"%s" % self.msg
|
return u"%s" % self.msg
|
||||||
@ -1066,7 +1075,11 @@ class ValidationBaseError(Exception):
|
|||||||
:return: the rendered ``cas_server/serviceValidateError.xml`` template
|
:return: the rendered ``cas_server/serviceValidateError.xml`` template
|
||||||
:rtype: django.http.HttpResponse
|
:rtype: django.http.HttpResponse
|
||||||
"""
|
"""
|
||||||
return render(request, self.template, self.contex(), content_type="text/xml; charset=utf-8")
|
return render(
|
||||||
|
request,
|
||||||
|
self.template,
|
||||||
|
self.context(), content_type="text/xml; charset=utf-8"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ValidateError(ValidationBaseError):
|
class ValidateError(ValidationBaseError):
|
||||||
|
Loading…
Reference in New Issue
Block a user