Skip to content

Commit

Permalink
Add more tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
teleyinex committed Aug 22, 2018
1 parent 7c4f58e commit 0deeede
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions test/test_api/test_taskrun_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1295,3 +1295,50 @@ def test_taskrun_post_file_anon(self):
data['info']['file_name'])
assert os.path.isfile(fname) is True, fname
assert data['info']['container'] == 'anonymous', data

# wrong project_id
img = (io.BytesIO(b'test'), 'test_file.jpg')

payload = dict(project_id=-1,
task_id=task.id,
info=json.dumps(dict(foo="bar")),
file=img)

url = '/api/taskrun'
res = self.app.post(url, data=payload,
content_type="multipart/form-data")
data = json.loads(res.data)
assert res.status_code == 403, data

# Wrong attribute
img = (io.BytesIO(b'test'), 'test_file.jpg')

payload = dict(project_id=project.id,
task_id=task.id,
info=json.dumps(dict(foo="bar")),
wrong=img)

url = '/api/taskrun'
res = self.app.post(url, data=payload,
content_type="multipart/form-data")
data = json.loads(res.data)
assert res.status_code == 415, data

# reserved key
img = (io.BytesIO(b'test'), 'test_file.jpg')

payload = dict(project_id=project.id,
file=img)

payload = dict(project_id=project.id,
task_id=task.id,
info=json.dumps(dict(foo="bar")),
file=img,
id=3)

url = '/api/taskrun'
res = self.app.post(url, data=payload,
content_type="multipart/form-data")
data = json.loads(res.data)
assert res.status_code == 400, data
assert data['exception_msg'] == 'Reserved keys in payload', data

0 comments on commit 0deeede

Please sign in to comment.