15814: Fix runtime typecheck error 15814-wb2-secrets
authorPeter Amstutz <peter.amstutz@curii.com>
Mon, 1 Jul 2024 14:44:50 +0000 (10:44 -0400)
committerPeter Amstutz <peter.amstutz@curii.com>
Mon, 1 Jul 2024 14:44:50 +0000 (10:44 -0400)
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz@curii.com>

services/workbench2/cypress/e2e/create-workflow.cy.js
services/workbench2/src/models/workflow.ts
services/workbench2/src/views/process-panel/process-io-card.tsx

index 15d40dd37d1b032c97f93e2e224162c5bbf1590e..f4e4a92c8d0d72b1aaba469769ed15c70ac8d5eb 100644 (file)
@@ -320,7 +320,7 @@ describe('Create workflow tests', function () {
             cy.get('[data-cy=new-process-panel]').contains('Run workflow').click();
 
             cy.get('[data-cy=process-io-card]').should('contain', 'exposed_value_xyz');
-            cy.get('[data-cy=process-io-card]').should('contain', 'exposed_value_xyz');
+            cy.get('[data-cy=process-io-card]').should('contain', 'Cannot display secret');
             cy.get('[data-cy=process-io-card]').should('not.contain', 'secret_value_xyz');
 
             cy.url().then((url) => {
index df1935999352085cf4e3fa93430e38f6e393567c..b7a115da6d12f439044b5de9aa745c33a5f7c1ae 100644 (file)
@@ -103,6 +103,10 @@ export interface Directory {
     basename?: string;
 }
 
+export interface SecretInclude {
+    $include: string;
+}
+
 export interface GenericCommandInputParameter<Type, Value> {
     id: string;
     label?: string;
@@ -130,10 +134,8 @@ export type IntArrayCommandInputParameter = GenericArrayCommandInputParameter<CW
 export type FloatArrayCommandInputParameter = GenericArrayCommandInputParameter<CWLType.FLOAT, string>;
 export type FileArrayCommandInputParameter = GenericArrayCommandInputParameter<CWLType.FILE, File>;
 export type DirectoryArrayCommandInputParameter = GenericArrayCommandInputParameter<CWLType.DIRECTORY, Directory>;
+export type SecretCommandInputParameter = GenericArrayCommandInputParameter<CWLType.STRING, SecretInclude>;
 
-type SecretInclude = {
-    $include: string;
-}
 
 export type WorkflowInputsData = {
     [key: string]: boolean | number | string | File | Directory | SecretInclude;
@@ -232,8 +234,11 @@ export const getEnumType = (input: GenericCommandInputParameter<any, any>) => {
     return null;
 };
 
+export const isSecret = (input: GenericCommandInputParameter<any, any>) =>
+    (typeof input.value === 'object') && input.value.$include?.startsWith("/secrets/");
+
 export const stringifyInputType = ({ type }: CommandInputParameter) => {
-    if (typeof type === 'string') {
+       if (typeof type === 'string') {
         return type;
     } else if (type instanceof Array) {
         return type.join(' | ');
index a551a0d8ec30ba6ddf02f2e5531fe5642d942586..42a9616049d593d96dfc84bd9a92d691aa970c55 100644 (file)
@@ -43,6 +43,7 @@ import {
     IntCommandInputParameter,
     isArrayOfType,
     isPrimitiveOfType,
+    isSecret,
     StringArrayCommandInputParameter,
     StringCommandInputParameter,
     getEnumType,
@@ -689,7 +690,7 @@ type FileWithSecondaryFiles = {
 
 export const getIOParamDisplayValue = (auth: AuthState, input: CommandInputParameter | CommandOutputParameter, pdh?: string): ProcessIOValue[] => {
     switch (true) {
-        case (typeof input.value === 'object') && input.value.$include?.startsWith("/secrets/"):
+        case isSecret(input):
             return [{ display: <SecretValue /> }];
 
         case isPrimitiveOfType(input, CWLType.BOOLEAN):