Skip to content
Snippets Groups Projects
Commit 2b315d21 authored by Jameson Rollins's avatar Jameson Rollins
Browse files

web: fix handling empty query keys

Also add some additional tests.
parent a23b2179
No related branches found
No related tags found
No related merge requests found
......@@ -39,13 +39,14 @@ def query_parse(query):
out_query = {}
for key, val in query.items():
try:
conv = val_conv[key]
except KeyError:
# if the query key is not know just skip
# if the query key is not know ignore
if key not in val_conv:
continue
# if the value is empty skip
if not val:
continue
try:
out_query[key] = conv(val)
out_query[key] = val_conv[key](val)
except ValueError:
# FIXME: raise better error here?
raise
......
#!/bin/bash -ex
set -o pipefail
PYTHON=python3
export IFO
......@@ -57,7 +59,10 @@ REQUEST_METHOD=GET $PYTHON -m locklost.web >/dev/null
REQUEST_METHOD=GET QUERY_STRING=event=$EVENT $PYTHON -m locklost.web >/dev/null
REQUEST_METHOD=GET QUERY_STRING=format=json $PYTHON -m locklost.web | tail -n +5 | json_verify
REQUEST_METHOD=GET QUERY_STRING='format=json' $PYTHON -m locklost.web | tail -n +5 | json_verify
REQUEST_METHOD=GET QUERY_STRING='format=json&limit=' $PYTHON -m locklost.web | tail -n +5 | json_verify
REQUEST_METHOD=GET QUERY_STRING='format=json&limit=2' $PYTHON -m locklost.web | tail -n +5 | json_verify
REQUEST_METHOD=GET QUERY_STRING='format=json&tag=REFINED' $PYTHON -m locklost.web | tail -n +5 | json_verify
trap - EXIT
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment