From 9e6f04896cc4988697fbd6ec8b92955b372a85df Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Thu, 13 Feb 2020 10:04:17 +0200 Subject: [PATCH] Added file upload mock tests --- app/controllers/mock.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/controllers/mock.php b/app/controllers/mock.php index 89d1d448d3..57299aed3d 100644 --- a/app/controllers/mock.php +++ b/app/controllers/mock.php @@ -176,9 +176,23 @@ $utopia->post('/v1/mock/tests/general/upload') function ($x, $y, $z, $file) use ($request) { $file = $request->getFiles('file'); $file['tmp_name'] = (is_array($file['tmp_name'])) ? $file['tmp_name'] : [$file['tmp_name']]; + $file['name'] = (is_array($file['name'])) ? $file['name'] : [$file['name']]; + $file['size'] = (is_array($file['size'])) ? $file['size'] : [$file['size']]; + + foreach ($file['name'] as $i => $name) { + if($name !== 'file.png') { + throw new Exception('Wrong file name', 400); + } + } + + foreach ($file['size'] as $i => $size) { + if($size !== 38756) { + throw new Exception('Wrong file size', 400); + } + } foreach ($file['tmp_name'] as $i => $tmpName) { - if(md5(file_get_contents($tmpName)) !== 'asdasdasd') { + if(md5(file_get_contents($tmpName)) !== 'd80e7e6999a3eb2ae0d631a96fe135a4') { throw new Exception('Wrong file uploaded', 400); } }