From e05b0a396ef246f7f736bc86e7b82a6d9cf65b4a Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Thu, 2 Jun 2016 18:38:47 +0200 Subject: [PATCH] Disallow / in compute_id because it was a stupid idea --- gns3server/controller/compute.py | 2 +- .../handlers/api/controller/compute_handler.py | 6 +++--- tests/handlers/api/controller/test_compute.py | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/gns3server/controller/compute.py b/gns3server/controller/compute.py index 83b0cb6a..74487606 100644 --- a/gns3server/controller/compute.py +++ b/gns3server/controller/compute.py @@ -329,4 +329,4 @@ class Compute: Forward a call to the emulator on compute """ res = yield from self.get("/{}/{}".format(type, path)) - return res + return res.json diff --git a/gns3server/handlers/api/controller/compute_handler.py b/gns3server/handlers/api/controller/compute_handler.py index f1d36dd2..8960375e 100644 --- a/gns3server/handlers/api/controller/compute_handler.py +++ b/gns3server/handlers/api/controller/compute_handler.py @@ -78,7 +78,7 @@ class ComputeHandler: response.json(compute) @Route.get( - r"/computes/{compute_id:.+}/{emulator}/images", + r"/computes/{compute_id}/{emulator}/images", parameters={ "compute_id": "Compute UUID" }, @@ -94,7 +94,7 @@ class ComputeHandler: response.json(images) @Route.get( - r"/computes/{compute_id:.+}/{emulator}/vms", + r"/computes/{compute_id}/{emulator}/vms", parameters={ "compute_id": "Compute UUID" }, @@ -110,7 +110,7 @@ class ComputeHandler: response.json(images) @Route.get( - r"/computes/{compute_id:.+}", + r"/computes/{compute_id}", description="Get a compute server information", status_codes={ 200: "Compute server information returned" diff --git a/tests/handlers/api/controller/test_compute.py b/tests/handlers/api/controller/test_compute.py index b52b7160..88205123 100644 --- a/tests/handlers/api/controller/test_compute.py +++ b/tests/handlers/api/controller/test_compute.py @@ -61,7 +61,7 @@ def test_compute_create_with_id(http_controller, controller): def test_compute_get(http_controller, controller): params = { - "compute_id": "my_compute/id", + "compute_id": "my_compute_id", "protocol": "http", "host": "example.com", "port": 84, @@ -71,7 +71,7 @@ def test_compute_get(http_controller, controller): response = http_controller.post("/computes", params) assert response.status == 201 - response = http_controller.get("/computes/my_compute/id", example=True) + response = http_controller.get("/computes/my_compute_id", example=True) assert response.status == 200 assert response.json["protocol"] == "http" @@ -79,7 +79,7 @@ def test_compute_get(http_controller, controller): def test_compute_update(http_controller, controller): params = { - "compute_id": "my_compute/id", + "compute_id": "my_compute_id", "protocol": "http", "host": "example.com", "port": 84, @@ -89,12 +89,12 @@ def test_compute_update(http_controller, controller): response = http_controller.post("/computes", params) assert response.status == 201 - response = http_controller.get("/computes/my_compute/id") + response = http_controller.get("/computes/my_compute_id") assert response.status == 200 assert response.json["protocol"] == "http" params["protocol"] = "https" - response = http_controller.put("/computes/my_compute/id", params, example=True) + response = http_controller.put("/computes/my_compute_id", params, example=True) assert response.status == 200 assert response.json["protocol"] == "https" @@ -135,7 +135,7 @@ def test_compute_list(http_controller, controller): def test_compute_delete(http_controller, controller): params = { - "compute_id": "my_compute/id", + "compute_id": "my_compute_id", "protocol": "http", "host": "example.com", "port": 84, @@ -148,7 +148,7 @@ def test_compute_delete(http_controller, controller): response = http_controller.get("/computes") assert len(response.json) == 1 - response = http_controller.delete("/computes/my_compute/id") + response = http_controller.delete("/computes/my_compute_id") assert response.status == 204 response = http_controller.get("/computes")