Update get execution's tasks functionality
After this patch, it will validate execution-id exists in the DB while fetching tasks for the execution-id So, GET /v2/executions/execution_id/tasks API will return 404 for absent execution id. Closes-Bug: #1998210 Change-Id: I6ac05f4b87c470a68cd67f19d1bd95a4d6cebe59
This commit is contained in:
parent
c820d6f365
commit
87c08ff421
@ -28,6 +28,7 @@ from mistral.api.controllers.v2 import sub_execution
|
||||
from mistral.api.controllers.v2 import types
|
||||
from mistral import context
|
||||
from mistral.db.v2 import api as db_api
|
||||
from mistral.db.v2.sqlalchemy import models as db_models
|
||||
from mistral import exceptions as exc
|
||||
from mistral import expressions as expr
|
||||
from mistral.lang import parser as spec_parser
|
||||
@ -440,6 +441,12 @@ class ExecutionTasksController(rest.RestController):
|
||||
"""
|
||||
acl.enforce('tasks:list', context.ctx())
|
||||
|
||||
with db_api.transaction():
|
||||
db_api.get_workflow_execution(
|
||||
workflow_execution_id,
|
||||
fields=(db_models.WorkflowExecution.id,)
|
||||
)
|
||||
|
||||
filters = filter_utils.create_filters_from_request_params(
|
||||
workflow_execution_id=workflow_execution_id,
|
||||
created_at=created_at,
|
||||
|
@ -994,3 +994,17 @@ class TestExecutionsController(base.APITest):
|
||||
"The field 'id' can't hold None value.",
|
||||
resp.body.decode()
|
||||
)
|
||||
|
||||
@mock.patch.object(db_api, 'get_workflow_execution', MOCK_NOT_FOUND)
|
||||
def test_get_all_tasks_within_execution(self):
|
||||
fake_execution_id = "00000000-0000-0000-0000-000000000000"
|
||||
resp = self.app.get(
|
||||
'/v2/executions/%s/tasks' % fake_execution_id,
|
||||
expect_errors=True
|
||||
)
|
||||
|
||||
self.assertEqual(404, resp.status_int)
|
||||
self.assertIn(
|
||||
"Object not found",
|
||||
resp.body.decode()
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user