summaryrefslogtreecommitdiff
path: root/yarns
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2017-10-05 13:41:21 +0300
committerLars Wirzenius <liw@liw.fi>2017-10-05 18:01:46 +0300
commitdb3e5ccf02679ccb50feb45f31d4b3a8d6f4b739 (patch)
treeada7cb7406d6ce067ecedf64f5854e94023b2bc9 /yarns
parent6d27baeabb9074abaea61fb1dde8f36a4d66f5f5 (diff)
downloadqvisqve-db3e5ccf02679ccb50feb45f31d4b3a8d6f4b739.tar.gz
Add: implement test for header values
Diffstat (limited to 'yarns')
-rw-r--r--yarns/900-implements.yarn17
1 files changed, 10 insertions, 7 deletions
diff --git a/yarns/900-implements.yarn b/yarns/900-implements.yarn
index f18e999..fdb3a56 100644
--- a/yarns/900-implements.yarn
+++ b/yarns/900-implements.yarn
@@ -23,12 +23,14 @@ Start a Qvarn running in the background.
vars['pid-file'] = 'pid'
vars['port'] = cliapp.runcmd([os.path.join(srcdir, 'randport' )]).strip()
vars['url'] = 'http://127.0.0.1:{}'.format(vars['port'])
+ vars['API_URL'] = vars['url']
config = {
'log': [
{
'filename': vars['api.log'],
},
],
+ 'baseurl': vars['url'],
'token-issuer': vars['iss'],
'token-audience': vars['aud'],
'token-public-key': vars['pubkey'],
@@ -63,7 +65,7 @@ Start a Qvarn running in the background.
IMPLEMENTS WHEN client requests GET (/.+) without token
path = get_next_match()
path = expand_vars(path, vars)
- vars['status_code'], vars['body'] = get(vars['url'] + path)
+ vars['status_code'], vars['headers'], vars['body'] = get(vars['url'] + path)
IMPLEMENTS WHEN client requests GET (/.+) using token
path = get_next_match()
@@ -71,7 +73,8 @@ Start a Qvarn running in the background.
headers = {
'Authorization': 'Bearer {}'.format(vars['token']),
}
- vars['status_code'], vars['body'] = get(vars['url'] + path, headers)
+ vars['status_code'], vars['headers'], vars['body'] = get(
+ vars['url'] + path, headers)
IMPLEMENTS WHEN client requests POST (/.+) with token and body (.+)
path = get_next_match()
@@ -80,7 +83,7 @@ Start a Qvarn running in the background.
'Authorization': 'Bearer {}'.format(vars['token']),
'Content-Type': 'application/json',
}
- vars['status_code'], vars['body'] = post(
+ vars['status_code'], vars['headers'], vars['body'] = post(
vars['url'] + path, headers=headers, body=body)
IMPLEMENTS WHEN client requests PUT (/.+) with token and body (.+)
@@ -92,7 +95,7 @@ Start a Qvarn running in the background.
'Authorization': 'Bearer {}'.format(vars['token']),
'Content-Type': 'application/json',
}
- vars['status_code'], vars['body'] = put(
+ vars['status_code'], vars['headers'], vars['body'] = put(
vars['url'] + path, headers=headers, body=body)
IMPLEMENTS WHEN client requests DELETE (/.+) with token
@@ -101,7 +104,7 @@ Start a Qvarn running in the background.
headers = {
'Authorization': 'Bearer {}'.format(vars['token']),
}
- vars['status_code'], vars['body'] = delete(
+ vars['status_code'], vars['headers'], vars['body'] = delete(
vars['url'] + path, headers=headers)
IMPLEMENTS WHEN client uploads a fake jpg
@@ -130,8 +133,8 @@ Start a Qvarn running in the background.
IMPLEMENTS THEN HTTP (\S+) header is (.+)
header = get_next_match()
- value = get_next_match()
- assert 0
+ value = expand_vars(get_next_match(), vars)
+ assertEqual(vars['headers'].get(header), value)
IMPLEMENTS THEN resource id is (\S+)
import json