Skip to content

Commit

Permalink
Merge pull request #36 from openintegrationhub:feature/flo-203-secret…
Browse files Browse the repository at this point in the history
…-parameters-v1

Added support for additionalParameters from cfg
  • Loading branch information
SvenHoeffler authored Aug 28, 2024
2 parents 44bceb8 + ef31f5f commit fdcdfda
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions templates/lib/actions/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ async function processAction(msg, cfg, snapshot, incomingMessageHeaders, tokenDa
if (body[param]) {
parameters[param] = body[param];
delete body[param];
} else if (cfg && cfg.additionalParameters && cfg.additionalParameters[param]) {
parameters[param] = cfg.additionalParameters[param];
}
}
logger.debug("Parameters were populated from configuration: %j", parameters);
Expand Down
4 changes: 4 additions & 0 deletions templates/lib/triggers/trigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ async function processTrigger(msg, cfg, snapshot, incomingMessageHeaders, tokenD
logger.debug("Found params in msg.data", msg.data);
triggerParams = { ...triggerParams, ...msg.data };
}
if (cfg && cfg.additionalParameters) {
logger.debug("Found additional params in credentials", cfg.additionalParameters),
triggerParams = { ...triggerParams, ...cfg.additionalParameters };
}
logger.info("Final trigger params: %j", triggerParams);

let parameters = {};
Expand Down
7 changes: 5 additions & 2 deletions templates/spec-integration/action.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ describe("Action test", () => {
};
const cfg = {
accessToken,
nodeSettings: {}
nodeSettings: {},
additionalParameters: {
teamId: 123,
}
// SET CONFIGURATION HERE
};
const snapshot = {};
const incomingMessageHeaders = {};
const tokenData = {
"function": actionName
};
await action.process.call(context,msg, cfg, snapshot, incomingMessageHeaders, tokenData);
await action.process.call(context, msg, cfg, snapshot, incomingMessageHeaders, tokenData);
expect(context.emit.callCount).to.be.equal(2);
});
});
7 changes: 5 additions & 2 deletions templates/spec-integration/trigger.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ describe("Trigger test", () => {
const triggerName = "SET TRIGGER NAME HERE";
const accessToken = await getAccessToken();
const context = getContext();
const msg = {data:{}};
const msg = { data: {} };
const cfg = {
accessToken,
nodeSettings: {}
nodeSettings: {},
additionalParameters: {
teamId: 123,
}
};
const snapshot = {};
const incomingMessageHeaders = {};
Expand Down

0 comments on commit fdcdfda

Please sign in to comment.