From 4e9b1ddfae711ce38d743a3faccf49447ab10f75 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 3 Dec 2017 19:07:24 +0200 Subject: Add: blob service --- yarns/900-implements.yarn | 8 ++++---- yarns/lib.py | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'yarns') diff --git a/yarns/900-implements.yarn b/yarns/900-implements.yarn index 6f9d423..afddb3b 100644 --- a/yarns/900-implements.yarn +++ b/yarns/900-implements.yarn @@ -45,11 +45,11 @@ along with this program. If not, see . path = get_next_match() token = get_token(user) url = vars['bsurl'] - status, content_type, headers, body = get(url + path, token) + status, content_type, headers, body = get_blob(url + path, token) vars['status_code'] = status vars['content_type'] = content_type vars['headers'] = headers - vars['body'] = body + vars['body'] = body.encode('hex') IMPLEMENTS WHEN (\S+) makes request GET (\S+) with an invalid token user = get_next_match() @@ -88,7 +88,7 @@ along with this program. If not, see . vars['status_code'] = status vars['content_type'] = content_type vars['headers'] = headers - vars['body'] = body + vars['body'] = body.encode('hex') IMPLEMENTS WHEN (\S+) makes request PUT (\S+) with a valid token and body (.+) user = get_next_match() @@ -162,7 +162,7 @@ along with this program. If not, see . IMPLEMENTS THEN body is the same as the blob (\S+) filename = get_next_match() blob = cat(filename) - body = vars['body'] + body = vars['body'].decode('hex') assertEqual(body, blob) IMPLEMENTS THEN version in body matches version from setup.py diff --git a/yarns/lib.py b/yarns/lib.py index 00db015..6575e6d 100644 --- a/yarns/lib.py +++ b/yarns/lib.py @@ -104,6 +104,14 @@ def get(url, token): return r.status_code, r.headers['Content-Type'], dict(r.headers), r.text +def get_blob(url, token): + headers = { + 'Authorization': 'Bearer {}'.format(token), + } + r = requests.get(url, headers=headers, verify=False) + return r.status_code, r.headers['Content-Type'], dict(r.headers), r.content + + def post(url, body_text, token): headers = { 'Authorization': 'Bearer {}'.format(token), -- cgit v1.2.1