Skip to content

Commit 4b3ea3f

Browse files
authored
Merge pull request #67 from pndaproject/PNDA-4405
Require user and package fields in create application API
2 parents 4670089 + ddb6008 commit 4b3ea3f

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

api/src/main/resources/app.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,20 @@ class ApplicationHandler(BaseHandler):
256256
def put(self, aname):
257257
try:
258258
request_body = json.loads(self.request.body)
259-
pname = request_body['package']
260-
except:
259+
except ValueError:
261260
self.send_client_error("Invalid request body")
262261
return
263262

263+
if 'package' not in request_body:
264+
self.send_client_error("Invalid request body. Missing field 'package'")
265+
return
266+
267+
if 'user' not in request_body:
268+
self.send_client_error("Invalid request body. Missing field 'user'")
269+
return
270+
264271
def do_call():
265-
dm.create_application(pname, aname, request_body)
272+
dm.create_application(request_body['package'], aname, request_body)
266273
self.send_accepted()
267274

268275
DISPATCHER.run_as_asynch(task=do_call, on_error=self.handle_error)

0 commit comments

Comments
 (0)