convert list of auth_codes to single value

The auth tests use parse_qs() which always returns a list for a
name. The MySQL driver apparently converts the list to a single
string, but the sqlite3 driver does not so do it ourselves in
authorization_code_get() before accessing the database.

Change-Id: Ib68a7b2c8c51b8762b595e31c4d6d2878d116b91
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann 2018-01-30 20:34:14 +00:00
parent ccce5ef454
commit 9249e0a095
1 changed files with 4 additions and 0 deletions

View File

@ -20,6 +20,10 @@ from storyboard.db import models
def authorization_code_get(code):
query = api_base.model_query(models.AuthorizationCode,
api_base.get_session())
# The query string parser always gives a list, but the database
# wants a single value.
if isinstance(code, list):
code = code[0]
return query.filter_by(code=code).first()