Commit f9889268 authored by Łukasz Nowak's avatar Łukasz Nowak

app: Avoid needless exception to pop

It's better to reply 400 Bad Request on malformed requests and do not pollute
log with exceptions.
parent dcd506f3
......@@ -370,10 +370,12 @@ class Kedifa(object):
if not index:
index = None
else:
raise ValueError
start_response('400 Bad Request', headers_text_plain)
return ('Wrong path')
if not reference:
raise ValueError
start_response('400 Bad Request', headers_text_plain)
return ('Wrong path')
if environ['REQUEST_METHOD'] == 'PUT':
# key auth
......
......@@ -348,16 +348,10 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
# KeDiFa does not support nothing on / so for now it just raises
# possibly in the future it will become self-describing interface
self.assertEqual(
httplib.INTERNAL_SERVER_ERROR,
httplib.BAD_REQUEST,
result.status_code
)
self.assertEqual(
'A server error occurred. Please contact the administrator.',
result.text
)
self.assertLastLogEntry('"GET / HTTP/1.1" 500')
self.assertAnyLogEntry('Exception while handling the request:')
self.assertAnyLogEntry('ValueError')
self.assertLastLogEntry('"GET / HTTP/1.1" 400')
def assertAnyLogEntry(self, entry):
with open(self.logfile) as fh:
......
Markdown is supported
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