Skip to content
This repository was archived by the owner on May 6, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion rootfs/api/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,13 @@ def test_run(self, mock_requests):
response = self.client.post(url, body)
self.assertEqual(response.status_code, 201, response.data)

# run command
# cannot run command without body
url = '/v2/apps/{}/run'.format(app_id)
response = self.client.post(url, {})
self.assertEqual(response.status_code, 400, response.data)
self.assertEqual(response.data, {'detail': 'command is a required field'})

# run command
body = {'command': 'ls -al'}
response = self.client.post(url, body)
self.assertEqual(response.status_code, 200, response.data)
Expand Down
2 changes: 2 additions & 0 deletions rootfs/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ def logs(self, request, **kwargs):

def run(self, request, **kwargs):
app = self.get_object()
if not request.data.get('command'):
raise DeisException("command is a required field")
rc, output = app.run(self.request.user, request.data['command'])
return Response({'exit_code': rc, 'output': str(output)})

Expand Down