From e98614cd606a863030fb98b23eff099b19ec868d Mon Sep 17 00:00:00 2001 From: Bob Haddleton Date: Thu, 11 Oct 2018 14:31:11 -0500 Subject: [PATCH] Update OnClauseSPec task name criteria The OnClauseSpec required Task names to be \w+ or [a-zA-Z0-9_] which is not enforced by the DSL, so it was possible to have valid task names that could not be referenced in an on-clause. YAML enforces some restrictions on characters in task names (#, !, |) but other than that any JSON-schema valid string should be a valid Task name Change-Id: I3f1056cad7c67e160a082c2a0de2e3bfd476bc63 Closes-Bug: 1797439 --- mistral/lang/v2/on_clause.py | 2 +- mistral/tests/unit/lang/v2/test_workflows.py | 26 ++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/mistral/lang/v2/on_clause.py b/mistral/lang/v2/on_clause.py index e5c1bb7e5..56498d96f 100644 --- a/mistral/lang/v2/on_clause.py +++ b/mistral/lang/v2/on_clause.py @@ -23,7 +23,7 @@ NEXT_TASK = { "oneOf": [ { "type": "string", - "pattern": "^\w+$", + "pattern": "^\S+$", "description": "Task name (e.g.: `task1`)" }, { diff --git a/mistral/tests/unit/lang/v2/test_workflows.py b/mistral/tests/unit/lang/v2/test_workflows.py index 48019f5e4..fcabc08b9 100644 --- a/mistral/tests/unit/lang/v2/test_workflows.py +++ b/mistral/tests/unit/lang/v2/test_workflows.py @@ -432,6 +432,32 @@ class WorkflowSpecValidation(base.WorkflowSpecValidationTestCase): str(exception) ) + def test_task_name(self): + wf = { + 'version': '2.0', + 'workflowname': { + 'type': 'direct', + 'tasks': {'task1': {'action': 'std.noop', + 'on-success': ['t2-task']}, + 't2-task': {'action': 'std.noop', + 'on-success': ['t3.task']}, + 't3.task': {'action': 'std.noop', + 'on-success': ['t4,task']}, + 't4,task': {'action': 'std.noop', + 'on-success': ['t5+task']}, + 't5+task': {'action': 'std.noop', + 'on-success': ['t6$task']}, + 't6$task': {'action': 'std.noop', + 'on-success': ['t7%task']}, + 't7%task': {'action': 'std.noop', + 'on-success': ['t8^task']}, + 't8^task': {'action': 'std.noop', + }}}} + + dsl_yaml = yaml.safe_dump(wf, default_flow_style=False) + + self._spec_parser(dsl_yaml) + def test_tags(self): tests = [ ({'tags': ''}, True),