diff --git a/picasso/api/controllers/runnable.py b/picasso/api/controllers/runnable.py index 6ab9610..338ac21 100644 --- a/picasso/api/controllers/runnable.py +++ b/picasso/api/controllers/runnable.py @@ -139,9 +139,19 @@ class RunnableV1Controller(controller.ServiceController, "200": description: successful operation. Return "runnable" JSON "404": - description: App does not exist + description: App not found "404": - description: App route does not exist + description: App route not found """ + app = request.match_info.get('app') + project_id = request.match_info.get('project_id') + + if not (await app_model.Apps.exists(app, project_id)): + return web.json_response(data={ + "error": { + "message": "App {0} not found".format(app), + } + }, status=404) + return await super(RunnableV1Controller, self).run(request, **kwargs) diff --git a/picasso/tests/common/routes.py b/picasso/tests/common/routes.py index d70077b..ab76c59 100644 --- a/picasso/tests/common/routes.py +++ b/picasso/tests/common/routes.py @@ -223,3 +223,13 @@ class AppRoutesTestSuite(object): ) ) self.assertEqual(403, status) + + def fail_to_run_app_from_other_project(self): + with setup_execute(self, "fail_to_run_app_" + "from_other_project") as app_name: + _, status = self.testloop.run_until_complete( + self.other_test_client.routes.execute_public( + app_name, self.route_data["path"] + ) + ) + self.assertEqual(404, status) diff --git a/picasso/tests/functional/base.py b/picasso/tests/functional/base.py index cf88952..4e3db03 100644 --- a/picasso/tests/functional/base.py +++ b/picasso/tests/functional/base.py @@ -74,12 +74,17 @@ class FunctionalTestsBase(base.PicassoTestsBase, testtools.TestCase): ) self.project_id = str(uuid.uuid4()).replace("-", "") + self.other_project_id = str(uuid.uuid4()).replace("-", "") + self.test_client = client.ProjectBoundTestClient( self.testapp, self.project_id) + self.other_test_client = client.ProjectBoundTestClient( + self.testapp, self.other_project_id) self.testloop.run_until_complete(self.test_client.start_server()) super(FunctionalTestsBase, self).setUp() def tearDown(self): self.testloop.run_until_complete(self.test_client.close()) + self.testloop.run_until_complete(self.other_test_client.close()) super(FunctionalTestsBase, self).tearDown() diff --git a/picasso/tests/functional/test_routes.py b/picasso/tests/functional/test_routes.py index 0869c54..ee48539 100644 --- a/picasso/tests/functional/test_routes.py +++ b/picasso/tests/functional/test_routes.py @@ -52,3 +52,7 @@ class TestAppRoutes(base.FunctionalTestsBase, def test_fail_to_execute_private_route(self): super(TestAppRoutes, self).fail_to_execute_private_as_public() + + def test_fail_to_run_app_from_other_project(self): + super(TestAppRoutes, + self).fail_to_run_app_from_other_project()