diff --git a/guidelines/mwm-workflow-spec.md b/guidelines/mwm-workflow-spec.md index 8a451059f..656d369bf 100644 --- a/guidelines/mwm-workflow-spec.md +++ b/guidelines/mwm-workflow-spec.md @@ -79,7 +79,7 @@ This section contains the IG configuration. Specifically, it contains the follow | Property | Type | Description | |------|------|------| |ae_title|str|The AE title for this workflow. Only data sent to this AE title will be processed by this workflow.| -|data_origins|list[str]|List of possible origin systems. These should be registered with the informatics gateway.| +|data_origins|Optional[list[str]]|List of possible origin systems. These should be registered with the informatics gateway.| |export_destinations|list[str]|List of possible destinations for the output of tasks in this workflow. Informatics gateways can subscribe to notifications of output to these destinations.| ```json @@ -171,7 +171,7 @@ The task also requires these extra attributes:- | Property | Type | Description | |------|------|------| -|args|object|An object that will be available to the task plugin when executing this task. This schema of this object is defined by the plugin itself.| +|args|optional[object]|An object that will be available to the task plugin when executing this task. This schema of this object is defined by the plugin itself.| |artifacts|[ArtifactMap](#artifacts)|Input & output artifacts of this task. @@ -187,7 +187,7 @@ The root level Task object contains an optional ArtifactMap object: | Property | Type | Description | |------|------|------| |input|list[Artifact]|List of artifacts that are needed by this task. -|output|list[Artifact]|List of artifacts that are generated by this task. +|output|optional[list[Artifact]]|List of artifacts that are generated by this task. #### Artifact diff --git a/src/WorkflowManager/PayloadListener/Extensions/WorkflowExtensions.cs b/src/WorkflowManager/PayloadListener/Extensions/WorkflowExtensions.cs index 4ff988441..983cc3f62 100644 --- a/src/WorkflowManager/PayloadListener/Extensions/WorkflowExtensions.cs +++ b/src/WorkflowManager/PayloadListener/Extensions/WorkflowExtensions.cs @@ -87,23 +87,11 @@ public static bool IsInformaticsGatewayValid(string source, InformaticsGateway i var valid = true; valid &= ValidationExtensions.IsAeTitleValid(informaticsGateway.GetType().Name, informaticsGateway.AeTitle, validationErrors); - valid &= IsDataOriginsValid(informaticsGateway.GetType().Name, informaticsGateway.DataOrigins, validationErrors); valid &= IsExportDestinationsValid(informaticsGateway.GetType().Name, informaticsGateway.ExportDestinations, validationErrors); return valid; } - public static bool IsDataOriginsValid(string source, string[] dataOrigins, IList validationErrors = null) - { - Guard.Against.NullOrWhiteSpace(source, nameof(source)); - - if (dataOrigins?.Length > 0) return true; - - validationErrors?.Add($"'{dataOrigins}' is not a valid Informatics Gateway - {nameof(dataOrigins)} (source: {source})."); - - return false; - } - public static bool IsExportDestinationsValid(string source, string[] exportDestinations, IList validationErrors = null) { Guard.Against.NullOrWhiteSpace(source, nameof(source)); @@ -128,7 +116,6 @@ public static bool IsTaskObjectValid(string source, TaskObject taskObject, IList valid &= IsTaskIdValid(taskObject.Id, taskObject.Id, validationErrors); valid &= IsTaskDescriptionValid(taskObject.Id, taskObject.Description, validationErrors); valid &= IsTaskTypeValid(taskObject.Id, taskObject.Type, validationErrors); - valid &= IsArgsValid(taskObject.Id, taskObject.Args, validationErrors); return valid; } @@ -166,18 +153,6 @@ public static bool IsTaskTypeValid(string source, string taskType, IList return false; } - public static bool IsArgsValid(string source, Dictionary args, IList validationErrors = null) - { - Guard.Against.NullOrWhiteSpace(source, nameof(source)); - - if (!args.IsNullOrEmpty()) return true; - - var jsontext = JsonConvert.SerializeObject(args); - validationErrors?.Add($"'{jsontext}' is not a valid {nameof(args)} (source: {source})."); - - return false; - } - #endregion } } diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/WorkflowApi.feature b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/WorkflowApi.feature index d7c1eb075..ec96f9470 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/WorkflowApi.feature +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/WorkflowApi.feature @@ -104,7 +104,6 @@ Scenario Outline: Update workflow with invalid details | /workflows/c86a437d-d026-4bdf-b1df-c7a6372b89e3 | Invalid_Workflow_Name_Length | is not a valid Workflow Name | | /workflows/c86a437d-d026-4bdf-b1df-c7a6372b89e3 | Invalid_Workflow_Desc_Length | is not a valid Workflow Description | | /workflows/c86a437d-d026-4bdf-b1df-c7a6372b89e3 | Invalid_Workflow_AETitle_Length | is not a valid AE Title | - | /workflows/c86a437d-d026-4bdf-b1df-c7a6372b89e3 | Invalid_Workflow_DataOrg | is not a valid Informatics Gateway - dataOrigins | | /workflows/c86a437d-d026-4bdf-b1df-c7a6372b89e3 | Invalid_Workflow_ExportDest | is not a valid Informatics Gateway - exportDestinations | | /workflows/c86a437d-d026-4bdf-b1df-c7a6372b89e3 | Invalid_Workflow_TaskDesc_Length | is not a valid taskDescription | | /workflows/c86a437d-d026-4bdf-b1df-c7a6372b89e3 | Invalid_Workflow_TaskType_Length | is not a valid taskType | @@ -133,6 +132,13 @@ Scenario: Add workflow with valid details When I send a POST request Then I will get a 201 response +@AddWorkflows +Scenario: Add workflow with valid empty details + Given I have an endpoint /workflows + And I have a body Basic_Workflow_2 + When I send a POST request + Then I will get a 201 response + @AddWorkflows Scenario Outline: Add workflow with invalid details Given I have an endpoint /workflows @@ -145,7 +151,6 @@ Scenario Outline: Add workflow with invalid details | Invalid_Workflow_Name_Length | is not a valid Workflow Name | | Invalid_Workflow_Desc_Length | is not a valid Workflow Description | | Invalid_Workflow_AETitle_Length | is not a valid AE Title | - | Invalid_Workflow_DataOrg | is not a valid Informatics Gateway - dataOrigins | | Invalid_Workflow_ExportDest | is not a valid Informatics Gateway - exportDestinations | | Invalid_Workflow_TaskDesc_Length | is not a valid taskDescription | | Invalid_Workflow_TaskType_Length | is not a valid taskType | diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/WorkflowObjectTestData.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/WorkflowObjectTestData.cs index ac74daba4..dd2834fd3 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/WorkflowObjectTestData.cs +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/WorkflowObjectTestData.cs @@ -62,6 +62,34 @@ public static class WorkflowObjectsTestData } }, new WorkflowObjectTestData() + { + Name = "Basic_Workflow_2", + Workflow = new Workflow() + { + Name = "Basic update", + Description = "Basic workflow update", + Version = "1", + Tasks = new TaskObject[] + { + new TaskObject + { + Id = "basic_id_with-legal-chars", + Type = "Basic_task", + Description = "Basic Workflow update Task update", + Artifacts = new ArtifactMap() + { + Input = new Artifact[] {} + } + } + }, + InformaticsGateway = new InformaticsGateway() + { + AeTitle = "Update", + ExportDestinations = new string[]{"test"} + } + } + }, + new WorkflowObjectTestData() { Name = "Invalid_Workflow_Name_Length", Workflow = new Workflow() diff --git a/tests/UnitTests/WorkflowManager.Tests/Controllers/WorkflowsControllerTests.cs b/tests/UnitTests/WorkflowManager.Tests/Controllers/WorkflowsControllerTests.cs index a0c4d73cf..e5a96c706 100644 --- a/tests/UnitTests/WorkflowManager.Tests/Controllers/WorkflowsControllerTests.cs +++ b/tests/UnitTests/WorkflowManager.Tests/Controllers/WorkflowsControllerTests.cs @@ -640,7 +640,7 @@ public void ValidateWorkflow_ValidatesAWorkflow_ReturnsTrueAndHasCorrectValidati Assert.True(workflowHasErrors); - Assert.Equal(26, results.Errors.Count); + Assert.Equal(14, results.Errors.Count); var successPath = "rootTask => taskSucessdesc1 => taskSucessdesc2"; Assert.Contains(successPath, results.SuccessfulPaths);