mirror of
https://github.com/n8n-io/n8n.git
synced 2026-10-16 21:19:43 +02:00
chore: Move the shared runtime-credential getter into BaseExecuteContext (#39470)
Co-authored-by: n8n-cat-bot[bot] <n8n-cat-bot[bot]@users.noreply.github.com>
This commit is contained in:
parent
8b68b0fcdd
commit
05a992d4f2
|
|
@ -398,29 +398,6 @@ describe('ExecuteContext', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('getRuntimeCredential', () => {
|
||||
beforeEach(() => {
|
||||
additionalData.getRuntimeCredential.mockReset();
|
||||
});
|
||||
|
||||
it('forwards the alias to the additionalData callback and returns its value', async () => {
|
||||
additionalData.getRuntimeCredential.mockResolvedValue('Bearer xyz');
|
||||
|
||||
const result = await executeContext.getRuntimeCredential('api_key');
|
||||
|
||||
expect(result).toBe('Bearer xyz');
|
||||
expect(additionalData.getRuntimeCredential).toHaveBeenCalledWith(runExecutionData, 'api_key');
|
||||
});
|
||||
|
||||
it('returns undefined when the underlying callback yields undefined', async () => {
|
||||
additionalData.getRuntimeCredential.mockResolvedValue(undefined);
|
||||
|
||||
const result = await executeContext.getRuntimeCredential('missing');
|
||||
|
||||
expect(result).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('executeAgent', () => {
|
||||
const webhookNode: INode = {
|
||||
id: 'webhook-node-id',
|
||||
|
|
|
|||
|
|
@ -199,27 +199,4 @@ describe('ExecuteSingleContext', () => {
|
|||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getRuntimeCredential', () => {
|
||||
beforeEach(() => {
|
||||
additionalData.getRuntimeCredential.mockReset();
|
||||
});
|
||||
|
||||
it('forwards the alias to the additionalData callback and returns its value', async () => {
|
||||
additionalData.getRuntimeCredential.mockResolvedValue('Bearer xyz');
|
||||
|
||||
const result = await executeSingleContext.getRuntimeCredential('api_key');
|
||||
|
||||
expect(result).toBe('Bearer xyz');
|
||||
expect(additionalData.getRuntimeCredential).toHaveBeenCalledWith(runExecutionData, 'api_key');
|
||||
});
|
||||
|
||||
it('returns undefined when the underlying callback yields undefined', async () => {
|
||||
additionalData.getRuntimeCredential.mockResolvedValue(undefined);
|
||||
|
||||
const result = await executeSingleContext.getRuntimeCredential('missing');
|
||||
|
||||
expect(result).toBeUndefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -46,6 +46,29 @@ export const describeCommonTests = (
|
|||
) => {
|
||||
const additionalData = context.additionalData as MockProxy<IWorkflowExecuteAdditionalData>;
|
||||
|
||||
describe('getRuntimeCredential', () => {
|
||||
beforeEach(() => {
|
||||
additionalData.getRuntimeCredential.mockReset();
|
||||
});
|
||||
|
||||
it('forwards the alias to the additionalData callback and returns its value', async () => {
|
||||
additionalData.getRuntimeCredential.mockResolvedValue('Bearer xyz');
|
||||
|
||||
const result = await context.getRuntimeCredential('api_key');
|
||||
|
||||
expect(result).toBe('Bearer xyz');
|
||||
expect(additionalData.getRuntimeCredential).toHaveBeenCalledWith(runExecutionData, 'api_key');
|
||||
});
|
||||
|
||||
it('returns undefined when the underlying callback yields undefined', async () => {
|
||||
additionalData.getRuntimeCredential.mockResolvedValue(undefined);
|
||||
|
||||
const result = await context.getRuntimeCredential('missing');
|
||||
|
||||
expect(result).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('getExecutionCancelSignal', () => {
|
||||
it('should return the abort signal', () => {
|
||||
expect(context.getExecutionCancelSignal()).toBe(abortSignal);
|
||||
|
|
|
|||
|
|
@ -132,6 +132,10 @@ export class BaseExecuteContext extends NodeExecutionContext {
|
|||
);
|
||||
}
|
||||
|
||||
async getRuntimeCredential(alias: string): Promise<IDataObject[string] | undefined> {
|
||||
return await this.additionalData.getRuntimeCredential(this.runExecutionData, alias);
|
||||
}
|
||||
|
||||
async putExecutionToWait(
|
||||
waitTill: Date,
|
||||
options?: { acceptsResumeRequest?: boolean },
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import type {
|
|||
AINodeConnectionType,
|
||||
CallbackManager,
|
||||
CloseFunction,
|
||||
IDataObject,
|
||||
IExecuteData,
|
||||
IExecuteFunctions,
|
||||
IExecuteResponsePromiseData,
|
||||
|
|
@ -126,10 +125,6 @@ export class ExecuteContext extends BaseExecuteContext implements IExecuteFuncti
|
|||
)) as IExecuteFunctions['getNodeParameter'];
|
||||
}
|
||||
|
||||
async getRuntimeCredential(alias: string): Promise<IDataObject[string] | undefined> {
|
||||
return await this.additionalData.getRuntimeCredential(this.runExecutionData, alias);
|
||||
}
|
||||
|
||||
async getInputConnectionData(
|
||||
connectionType: AINodeConnectionType,
|
||||
itemIndex: number,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import type {
|
|||
WorkflowExecuteMode,
|
||||
ITaskDataConnections,
|
||||
IExecuteData,
|
||||
IDataObject,
|
||||
} from 'n8n-workflow';
|
||||
import { UnexpectedError, NodeConnectionTypes } from 'n8n-workflow';
|
||||
|
||||
|
|
@ -87,10 +86,6 @@ export class ExecuteSingleContext extends BaseExecuteContext implements IExecute
|
|||
};
|
||||
}
|
||||
|
||||
async getRuntimeCredential(alias: string): Promise<IDataObject[string] | undefined> {
|
||||
return await this.additionalData.getRuntimeCredential(this.runExecutionData, alias);
|
||||
}
|
||||
|
||||
evaluateExpression(expression: string, itemIndex: number = this.itemIndex) {
|
||||
return super.evaluateExpression(expression, itemIndex);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user