summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2018-07-17 13:27:10 +0300
committerLars Wirzenius <liw@liw.fi>2018-07-17 15:32:45 +0300
commita1bc79d1ad8e4995a7d3ecec9c959d58770a7951 (patch)
tree92f5412cb24987fea6fc4e7af60dd4c2cdf6cb59
parent2ccc0561bf0099f0eeb5c095a56b839b096f8301 (diff)
downloadqvisqve-a1bc79d1ad8e4995a7d3ecec9c959d58770a7951.tar.gz
Change: implement IMPLEMENTS for end-user-auth scenario
-rw-r--r--yarns/900-implements.yarn56
1 files changed, 30 insertions, 26 deletions
diff --git a/yarns/900-implements.yarn b/yarns/900-implements.yarn
index e21d8d5..7eea6d8 100644
--- a/yarns/900-implements.yarn
+++ b/yarns/900-implements.yarn
@@ -83,22 +83,23 @@ This chapter shows the scenario step implementations.
V['API_URL'] + path, headers=headers)
IMPLEMENTS WHEN browser requests GET (\S+)
- # FIXME: This is a dummy implemantation, does not do anything real.
path = get_next_match()
V['status_code'], V['headers'], V['body'] = get(V['API_URL'] + path, {})
- IMPLEMENTS WHEN browser requests POST (\S+)$
- # FIXME: This is a dummy implemantation, does not do anything real.
- pass
-
- IMPLEMENTS WHEN browser requests POST (\S+), with form values (\S+)=(\S+) and (\S+)=(\S+)
- # FIXME: This is a dummy implemantation, does not do anything real.
- V['status_code'] = 302
-
- IMPLEMENTS WHEN facade requests POST (\S+), with form values (\S+)=(\S+) and (\S+)=(\S+)
- # FIXME: This is a dummy implemantation, does not do anything real.
- V['status_code'] = 200
- V['headers'] = {'Content-Type': 'application/json'}
+ IMPLEMENTS WHEN (browser|facade) requests POST (\S+), with form values (\S+)=(\S+) and (\S+)=(\S+)
+ who = get_next_match()
+ path = get_next_match()
+ field1 = get_next_match()
+ value1 = get_next_match()
+ field2 = get_next_match()
+ value2 = get_next_match()
+ headers = {}
+ body = {
+ field1: value1,
+ field2: value2,
+ }
+ V['status_code'], V['headers'], V['body'] = post(
+ V['API_URL'] + path, headers=headers, body=body)
## API access token creation
@@ -172,23 +173,21 @@ This chapter shows the scenario step implementations.
assertTrue(values_match(wanted, body))
IMPLEMENTS THEN body has an HTML form with field (.+)
- # FIXME: This is a dummy implemantation, does not do anything real.
- pass
+ field = get_next_match()
+ body = V['body']
+ pattern = '<input name="{}"'.format(field)
+ assertTrue(pattern in body)
IMPLEMENTS THEN Content-Type is (\S+)
wanted = get_next_match()
headers = V['headers']
assertEqual(headers['Content-Type'][:len(wanted)], wanted)
- IMPLEMENTS THEN Location header is (\S+)
- # FIXME: This is a dummy implemantation, does not do anything real.
- pass
-
IMPLEMENTS THEN body is a correctly signed JWT token
resp = json.loads(V['body'])
assertIn('access_token', resp)
assertIn('token_type', resp)
- assertEqual(resp['token_type'], 'bearer')
+ assertEqual(resp['token_type'], 'Bearer')
token = resp['access_token']
claims = token_decode(token, V['pubkey'])
assertNotEqual(claims, None)
@@ -206,10 +205,15 @@ This chapter shows the scenario step implementations.
remains = expires - time.time()
assertTrue(3400 < remains < 3700)
- IMPLEMENTS THEN body has field (\S+)$
- # FIXME: This is a dummy implemantation, does not do anything real.
- pass
+ IMPLEMENTS THEN JSON body has field (\S+)$
+ field = get_next_match()
+ body = V['body']
+ body = json.loads(body)
+ assertTrue(field in body)
- IMPLEMENTS THEN body has field (\S+), with value (\S+)
- # FIXME: This is a dummy implemantation, does not do anything real.
- pass
+ IMPLEMENTS THEN JSON body has field (\S+), with value (\S+)
+ field = get_next_match()
+ value = get_next_match()
+ body = V['body']
+ body = json.loads(body)
+ assertEqual(body.get(field), value)