Skip to content

Commit

Permalink
add more unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
5d committed Dec 11, 2024
1 parent 5d9c19d commit ff4700b
Showing 1 changed file with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -293,4 +293,50 @@ describe('update', () => {
Sql: expect.stringMatching(new RegExp(`.+ ON ${tableName} FROM ${username}`)),
}));
});

test('serializes properties in grant statement when tableName in physical resource ID', async () => {
const properties = {
...resourceProperties,
tablePrivileges: [{
tableId,
tableName: `${makePhysicalId(tableName, resourceProperties, requestId)}`,
actions,
}],
};

const newEvent = {
...event,
ResourceProperties: properties,
StackId: 'xxxxx:' + requestId,
};

await managePrivileges(properties, newEvent);

expect(mockExecuteStatement).toHaveBeenCalledWith(expect.objectContaining({
Sql: `GRANT INSERT, SELECT ON ${tableName} TO ${username}`,
}));
});

test('serializes properties in drop statement when tableName in physical resource ID', async () => {
const properties = {
...resourceProperties,
tablePrivileges: [{
tableId,
tableName: `${makePhysicalId(tableName, resourceProperties, requestId)}`,
actions: ['DROP'],
}],
};

const newEvent = {
...event,
ResourceProperties: properties,
StackId: 'xxxxx:' + requestId,
};

await managePrivileges(properties, newEvent);

expect(mockExecuteStatement).toHaveBeenCalledWith(expect.objectContaining({
Sql: `REVOKE INSERT, SELECT ON ${tableName} FROM ${username}`,
}));
});
});

0 comments on commit ff4700b

Please sign in to comment.