Skip to content

Commit

Permalink
chore: change in credential function name
Browse files Browse the repository at this point in the history
  • Loading branch information
kanishkkatara committed Jun 27, 2024
1 parent dc83798 commit 04a3821
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
10 changes: 5 additions & 5 deletions src/util/ivmFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ async function createIvm(
}),
);

await jail.set('_credential', function (key) {
await jail.set('_getCredential', function (key) {
if (isNil(credentials) || !isObject(credentials)) {
logger.error(
`Error fetching credentials map for transformationID: ${transformationId} and workspaceId: ${workspaceId}`,
Expand Down Expand Up @@ -344,11 +344,11 @@ async function createIvm(
]);
};
let credential = _credential;
delete _credential;
global.credential = function(...args) {
let getCredential = _getCredential;
delete _getCredential;
global.getCredential = function(...args) {
const key = args[0];
return credential(new ivm.ExternalCopy(key).copyInto());
return getCredential(new ivm.ExternalCopy(key).copyInto());
};
return new ivm.Reference(function forwardMainPromise(
Expand Down
28 changes: 14 additions & 14 deletions test/__tests__/user_transformation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ describe("User transformation", () => {
name,
code: `
export function transformEvent(event, metadata) {
event.credentialValue = credential('key1');
event.credentialValue = getCredential('key1');
return event;
}
`
Expand Down Expand Up @@ -1154,7 +1154,7 @@ describe("User transformation", () => {
name,
code: `
export function transformEvent(event, metadata) {
event.credentialValue = credential();
event.credentialValue = getCredential();
return event;
}
`
Expand Down Expand Up @@ -1183,7 +1183,7 @@ describe("User transformation", () => {
name,
code: `
export function transformEvent(event, metadata) {
event.credentialValue = credential('key1', 'key2');
event.credentialValue = getCredential('key1', 'key2');
return event;
}
`
Expand Down Expand Up @@ -1212,10 +1212,10 @@ describe("User transformation", () => {
name,
code: `
export function transformEvent(event, metadata) {
event.credentialValueForNumkey = credential(1);
event.credentialValueForBoolkey = credential(true);
event.credentialValueForArraykey = credential([]);
event.credentialValueForObjkey = credential({});
event.credentialValueForNumkey = getCredential(1);
event.credentialValueForBoolkey = getCredential(true);
event.credentialValueForArraykey = getCredential([]);
event.credentialValueForObjkey = getCredential({});
return event;
}
`
Expand Down Expand Up @@ -1247,7 +1247,7 @@ describe("User transformation", () => {
name,
code: `
export function transformEvent(event, metadata) {
event.credentialValue = credential('key3');
event.credentialValue = getCredential('key3');
return event;
}
`
Expand Down Expand Up @@ -1276,7 +1276,7 @@ describe("User transformation", () => {
name,
code: `
export function transformEvent(event, metadata) {
event.credentialValue = credential('key1');
event.credentialValue = getCredential('key1');
return event;
}
`
Expand Down Expand Up @@ -1307,8 +1307,8 @@ describe("User transformation", () => {
code: `
export function transformBatch(events, metadata) {
events.forEach((event) => {
event.credentialValue1 = credential("key1");
event.credentialValue2 = credential("key3");
event.credentialValue1 = getCredential("key1");
event.credentialValue2 = getCredential("key3");
});
return events;
}
Expand Down Expand Up @@ -1339,7 +1339,7 @@ describe("User transformation", () => {
code: `
export function transformBatch(events, metadata) {
events.forEach((event) => {
event.credentialValue = credential();
event.credentialValue = getCredential();
});
return events;
}
Expand Down Expand Up @@ -1371,7 +1371,7 @@ describe("User transformation", () => {
code: `
function transform(events) {
events.forEach((event) => {
event.credentialValue = credential('key1');
event.credentialValue = getCredential('key1');
});
return events;
}
Expand All @@ -1384,7 +1384,7 @@ describe("User transformation", () => {
try {
await userTransformHandler(inputData, versionId, []);
} catch (e) {
expect(e).toEqual('credential is not defined');
expect(e).toEqual('getCredential is not defined');
}
});
});
Expand Down

0 comments on commit 04a3821

Please sign in to comment.