@@ -797,7 +797,36 @@ mod tests {
797797 status_completed: {
798798 sql: `${CUBE}.status = 'completed'`
799799 }
800- }
800+ },
801+ accessPolicy: [
802+ {
803+ role: "*",
804+ rowLevel: {
805+ allowAll: true,
806+ },
807+ },
808+ {
809+ role: 'admin',
810+ conditions: [
811+ {
812+ if: `true`,
813+ },
814+ ],
815+ rowLevel: {
816+ filters: [
817+ {
818+ member: `${CUBE}.id`,
819+ operator: 'equals',
820+ values: [`1`, `2`, `3`],
821+ },
822+ ],
823+ },
824+ memberLevel: {
825+ includes: `*`,
826+ excludes: [`localTime`, `completedAt`],
827+ },
828+ },
829+ ]
801830 });
802831 "# ;
803832 // Should generate
@@ -897,6 +926,29 @@ mod tests {
897926 // sql: CUBE => `${CUBE}.status = 'completed'`,
898927 // },
899928 // },
929+ // accessPolicy: [{
930+ // role: "*",
931+ // rowLevel: {
932+ // allowAll: true
933+ // }
934+ // },
935+ // {
936+ // role: 'admin',
937+ // conditions: [{
938+ // if: () => `true`
939+ // }],
940+ // rowLevel: {
941+ // filters: [{
942+ // member: CUBE => `${CUBE}.id`,
943+ // operator: 'equals',
944+ // values: () => [`1`, `2`, `3`]
945+ // }]
946+ // },
947+ // memberLevel: {
948+ // includes: `*`,
949+ // excludes: [`localTime`, `completedAt`]
950+ // }
951+ // }]
900952 // });
901953
902954 let mut transformed_program: Option < Program > = None ;
@@ -971,6 +1023,21 @@ mod tests {
9711023 "Output code should contain arrow function with SQL_UTILS as parameter for *.sql, got:\n {}" ,
9721024 output_code
9731025 ) ;
1026+ assert ! (
1027+ output_code. contains( "if: ()=>`true`" ) ,
1028+ "Output code should contain arrow function for acl if condition, got:\n {}" ,
1029+ output_code
1030+ ) ;
1031+ assert ! (
1032+ output_code. contains( "member: (CUBE)=>`${CUBE}.id`" ) ,
1033+ "Output code should contain arrow function for acl rowlevel filters member, got:\n {}" ,
1034+ output_code
1035+ ) ;
1036+ assert ! (
1037+ output_code. contains( "values: ()=>[" ) ,
1038+ "Output code should contain arrow function for acl rowlevel filters values, got:\n {}" ,
1039+ output_code
1040+ ) ;
9741041 let diags = diagnostics. lock ( ) . unwrap ( ) ;
9751042 assert ! (
9761043 diags. is_empty( ) ,
@@ -1091,7 +1158,30 @@ mod tests {
10911158 status_completed: {
10921159 sql: CUBE => `${CUBE}.status = 'completed'`
10931160 }
1094- }
1161+ },
1162+ accessPolicy: [{
1163+ role: "*",
1164+ rowLevel: {
1165+ allowAll: true
1166+ }
1167+ },
1168+ {
1169+ role: 'admin',
1170+ conditions: [{
1171+ if: () => `true`
1172+ }],
1173+ rowLevel: {
1174+ filters: [{
1175+ member: CUBE => `${CUBE}.id`,
1176+ operator: 'equals',
1177+ values: () => [`1`, `2`, `3`]
1178+ }]
1179+ },
1180+ memberLevel: {
1181+ includes: `*`,
1182+ excludes: [`localTime`, `completedAt`]
1183+ }
1184+ }]
10951185 });
10961186 "# ;
10971187 // Should generate
@@ -1190,7 +1280,30 @@ mod tests {
11901280 // status_completed: {
11911281 // sql: CUBE => `${CUBE}.status = 'completed'`
11921282 // }
1193- // }
1283+ // },
1284+ // accessPolicy: [{
1285+ // role: "*",
1286+ // rowLevel: {
1287+ // allowAll: true
1288+ // }
1289+ // },
1290+ // {
1291+ // role: 'admin',
1292+ // conditions: [{
1293+ // if: () => `true`
1294+ // }],
1295+ // rowLevel: {
1296+ // filters: [{
1297+ // member: CUBE => `${CUBE}.id`,
1298+ // operator: 'equals',
1299+ // values: () => [`1`, `2`, `3`]
1300+ // }]
1301+ // },
1302+ // memberLevel: {
1303+ // includes: `*`,
1304+ // excludes: [`localTime`, `completedAt`]
1305+ // }
1306+ // }]
11941307 // });
11951308
11961309 let mut transformed_program: Option < Program > = None ;
@@ -1289,6 +1402,21 @@ mod tests {
12891402 "Output code should contain arrow function with SQL_UTILS as parameter for *.sql, got:\n {}" ,
12901403 output_code
12911404 ) ;
1405+ assert ! (
1406+ output_code. contains( "if: ()=>`true`" ) ,
1407+ "Output code should contain arrow function for acl if condition, got:\n {}" ,
1408+ output_code
1409+ ) ;
1410+ assert ! (
1411+ output_code. contains( "member: (CUBE)=>`${CUBE}.id`" ) ,
1412+ "Output code should contain arrow function for acl rowlevel filters member, got:\n {}" ,
1413+ output_code
1414+ ) ;
1415+ assert ! (
1416+ output_code. contains( "values: ()=>[" ) ,
1417+ "Output code should contain arrow function for acl rowlevel filters values, got:\n {}" ,
1418+ output_code
1419+ ) ;
12921420 let diags = diagnostics. lock ( ) . unwrap ( ) ;
12931421 assert ! (
12941422 diags. is_empty( ) ,
0 commit comments