From 7f27a6370a0af25e1bf6ff8f46360c6c26c21e0b Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Wed, 1 Jul 2020 15:16:34 +0200 Subject: Restrict PUT --- web-server/README.md | 9 ++++++++- web-server/opendc/api/v2/experiments/experimentId/endpoint.py | 10 ++-------- .../opendc/api/v2/experiments/experimentId/test_endpoint.py | 9 --------- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/web-server/README.md b/web-server/README.md index ff50cb36..e5a46016 100644 --- a/web-server/README.md +++ b/web-server/README.md @@ -70,7 +70,14 @@ In `opendc-web-server/static/index.html`, add your own `OAUTH_CLIENT_ID` in `con #### Set up the database -Run `docker-compose build` and `docker-compose up` in the [`mongodb` directory](../mongodb) of the main OpenDC repository to get a database setup up and running. +You can selectively run only the database services from the standard OpenDC `docker-compose` setup: + +```bash +docker-compose build mongo mongo-express +docker-compose up mongo mongo-express +``` + +This will set you up with a running MongoDB instance and a visual inspection tool running on [localhost:8082](http://localhost:8082), with which you can view and manipulate the database. ### Local Development diff --git a/web-server/opendc/api/v2/experiments/experimentId/endpoint.py b/web-server/opendc/api/v2/experiments/experimentId/endpoint.py index 5120368e..1611f889 100644 --- a/web-server/opendc/api/v2/experiments/experimentId/endpoint.py +++ b/web-server/opendc/api/v2/experiments/experimentId/endpoint.py @@ -17,14 +17,11 @@ def GET(request): def PUT(request): - """Update this Experiment.""" + """Update this Experiments name.""" request.check_required_parameters(path={'experimentId': 'string'}, body={ 'experiment': { - 'topologyId': 'string', - 'traceId': 'string', - 'schedulerName': 'string', 'name': 'string', } }) @@ -34,14 +31,11 @@ def PUT(request): experiment.check_exists() experiment.check_user_access(request.google_id, True) - experiment.set_property('topologyId', request.params_body['experiment']['topologyId']) - experiment.set_property('traceId', request.params_body['experiment']['traceId']) - experiment.set_property('schedulerName', request.params_body['experiment']['schedulerName']) experiment.set_property('name', request.params_body['experiment']['name']) experiment.update() - return Response(200, 'Successfully updated experiment', experiment.obj) + return Response(200, 'Successfully updated experiment.', experiment.obj) def DELETE(request): diff --git a/web-server/opendc/api/v2/experiments/experimentId/test_endpoint.py b/web-server/opendc/api/v2/experiments/experimentId/test_endpoint.py index c460585f..f3aa111c 100644 --- a/web-server/opendc/api/v2/experiments/experimentId/test_endpoint.py +++ b/web-server/opendc/api/v2/experiments/experimentId/test_endpoint.py @@ -51,9 +51,6 @@ def test_update_experiment_non_existing(client, mocker): assert '404' in client.put('/api/v2/experiments/1', json={ 'experiment': { - 'topologyId': '1', - 'traceId': '1', - 'schedulerName': 'default', 'name': 'test', } }).status @@ -74,9 +71,6 @@ def test_update_experiment_not_authorized(client, mocker): assert '403' in client.put('/api/v2/experiments/1', json={ 'experiment': { - 'topologyId': '1', - 'traceId': '1', - 'schedulerName': 'default', 'name': 'test', } }).status @@ -98,9 +92,6 @@ def test_update_experiment(client, mocker): res = client.put( '/api/v2/experiments/1', json={'experiment': { - 'topologyId': '1', - 'traceId': '1', - 'schedulerName': 'default', 'name': 'test', }}) assert '200' in res.status -- cgit v1.2.3