Skip to content
Snippets Groups Projects
Commit dae3ae3f authored by Ben Adida's avatar Ben Adida
Browse files

check for 404 in security checks

parent a427cdef
No related branches found
No related tags found
No related merge requests found
...@@ -9,6 +9,7 @@ from functools import update_wrapper ...@@ -9,6 +9,7 @@ from functools import update_wrapper
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.core.exceptions import * from django.core.exceptions import *
from django.http import *
from django.conf import settings from django.conf import settings
from models import * from models import *
...@@ -92,6 +93,9 @@ def election_view(**checks): ...@@ -92,6 +93,9 @@ def election_view(**checks):
def election_view_wrapper(request, election_uuid=None, *args, **kw): def election_view_wrapper(request, election_uuid=None, *args, **kw):
election = get_election_by_uuid(election_uuid) election = get_election_by_uuid(election_uuid)
if not election:
raise Http404
# do checks # do checks
do_election_checks(election, checks) do_election_checks(election, checks)
......
...@@ -390,6 +390,10 @@ class ElectionBlackboxTests(WebTest): ...@@ -390,6 +390,10 @@ class ElectionBlackboxTests(WebTest):
response = self.client.get("/helios/elections/params") response = self.client.get("/helios/elections/params")
self.assertEquals(response.content, views.ELGAMAL_PARAMS_LD_OBJECT.serialize()) self.assertEquals(response.content, views.ELGAMAL_PARAMS_LD_OBJECT.serialize())
def test_election_404(self):
response = self.client.get("/helios/elections/foobar")
self.assertEquals(response.status_code, 404)
def test_election_bad_trustee(self): def test_election_bad_trustee(self):
response = self.client.get("/helios/t/%s/foobar@bar.com/badsecret" % self.election.short_name) response = self.client.get("/helios/t/%s/foobar@bar.com/badsecret" % self.election.short_name)
self.assertEquals(response.status_code, 404) self.assertEquals(response.status_code, 404)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment