Skip to content

Commit

Permalink
fix(editor): Allow $secrets to resolve on credentials (#10093)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivov authored Jul 19, 2024
1 parent dd54390 commit bf57f38
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/editor-ui/src/components/ParameterInputHint.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[$style.highlight]: highlight,
}"
>
<span v-html="simplyText"></span>
<span data-test-id="parameter-input-hint" v-html="simplyText"></span>
</div>
<div
v-else
Expand Down
39 changes: 39 additions & 0 deletions packages/editor-ui/src/components/ParameterInputWrapper.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { renderComponent } from '@/__tests__/render';
import { createTestingPinia } from '@pinia/testing';
import ParameterInputWrapper from './ParameterInputWrapper.vue';

describe('ParameterInputWrapper.vue', () => {
test('should resolve expression', async () => {
const { getByTestId } = renderComponent(ParameterInputWrapper, {
pinia: createTestingPinia({
initialState: {
ndv: {
activeNodeName: 'testNode',
input: { nodeName: 'inputNode' },
},
},
}),
props: {
parameter: {
name: 'test',
type: 'string',
},
path: 'params.test',
modelValue: '={{ $secrets.infisical.password }}',
isForCredential: true,
},
global: {
mocks: {
$workflowHelpers: {
resolveExpression: vi.fn(() => 'topSecret'),
},
$ndvStore: {
activeNode: vi.fn(() => ({ test: 'test' })),
},
},
},
});

expect(getByTestId('parameter-input-hint')).toHaveTextContent('[ERROR: ]');
});
});
2 changes: 2 additions & 0 deletions packages/editor-ui/src/components/ParameterInputWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ const evaluatedExpression = computed<Result<unknown, Error>>(() => {
};
}
if (props.isForCredential) opts.additionalKeys = resolvedAdditionalExpressionData.value;
return { ok: true, result: workflowHelpers.resolveExpression(value, undefined, opts) };
} catch (error) {
return { ok: false, error };
Expand Down
3 changes: 1 addition & 2 deletions packages/editor-ui/src/composables/useExpressionEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,13 @@ export const useExpressionEditor = ({
// e.g. credential modal
result.resolved = Expression.resolveWithoutWorkflow(resolvable, toValue(additionalData));
} else {
let opts;
let opts: Record<string, unknown> = { additionalKeys: toValue(additionalData) };
if (ndvStore.isInputParentOfActiveNode) {
opts = {
targetItem: target ?? undefined,
inputNodeName: ndvStore.ndvInputNodeName,
inputRunIndex: ndvStore.ndvInputRunIndex,
inputBranchIndex: ndvStore.ndvInputBranchIndex,
additionalKeys: toValue(additionalData),
};
}
result.resolved = workflowHelpers.resolveExpression('=' + resolvable, undefined, opts);
Expand Down

0 comments on commit bf57f38

Please sign in to comment.