@@ -293,4 +293,50 @@ describe('update', () => {
293293 Sql : expect . stringMatching ( new RegExp ( `.+ ON ${ tableName } FROM ${ username } ` ) ) ,
294294 } ) ) ;
295295 } ) ;
296+
297+ test ( 'serializes properties in grant statement when tableName in physical resource ID' , async ( ) => {
298+ const properties = {
299+ ...resourceProperties ,
300+ tablePrivileges : [ {
301+ tableId,
302+ tableName : `${ makePhysicalId ( tableName , resourceProperties , requestId ) } ` ,
303+ actions,
304+ } ] ,
305+ } ;
306+
307+ const newEvent = {
308+ ...event ,
309+ ResourceProperties : properties ,
310+ StackId : 'xxxxx:' + requestId ,
311+ } ;
312+
313+ await managePrivileges ( properties , newEvent ) ;
314+
315+ expect ( mockExecuteStatement ) . toHaveBeenCalledWith ( expect . objectContaining ( {
316+ Sql : `GRANT INSERT, SELECT ON ${ tableName } TO ${ username } ` ,
317+ } ) ) ;
318+ } ) ;
319+
320+ test ( 'serializes properties in drop statement when tableName in physical resource ID' , async ( ) => {
321+ const properties = {
322+ ...resourceProperties ,
323+ tablePrivileges : [ {
324+ tableId,
325+ tableName : `${ makePhysicalId ( tableName , resourceProperties , requestId ) } ` ,
326+ actions : [ 'DROP' ] ,
327+ } ] ,
328+ } ;
329+
330+ const newEvent = {
331+ ...event ,
332+ ResourceProperties : properties ,
333+ StackId : 'xxxxx:' + requestId ,
334+ } ;
335+
336+ await managePrivileges ( properties , newEvent ) ;
337+
338+ expect ( mockExecuteStatement ) . toHaveBeenCalledWith ( expect . objectContaining ( {
339+ Sql : `REVOKE INSERT, SELECT ON ${ tableName } FROM ${ username } ` ,
340+ } ) ) ;
341+ } ) ;
296342} ) ;
0 commit comments