Skip to content

Commit a3ed6ea

Browse files
authored
fix: ensure public is in sync with isVisible when using DAP (#8980)
1 parent 028bc95 commit a3ed6ea

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

packages/cubejs-server-core/src/core/CompilerApi.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,8 @@ export class CompilerApi {
473473
}
474474
return (item) => ({
475475
...item,
476-
isVisible: item.isVisible && isMemberVisibleInContext[item.name]
476+
isVisible: item.isVisible && isMemberVisibleInContext[item.name],
477+
public: item.public && isMemberVisibleInContext[item.name]
477478
});
478479
};
479480

packages/cubejs-testing/test/smoke-rbac.test.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,3 +264,66 @@ describe('Cube RBAC Engine', () => {
264264
});
265265
});
266266
});
267+
268+
describe('Cube RBAC Engine [dev mode]', () => {
269+
jest.setTimeout(60 * 5 * 1000);
270+
let db: StartedTestContainer;
271+
let birdbox: BirdBox;
272+
let client: CubeApi;
273+
274+
const DEFAULT_API_TOKEN = sign({
275+
auth: {
276+
username: 'nobody',
277+
userAttributes: {},
278+
roles: [],
279+
},
280+
}, DEFAULT_CONFIG.CUBEJS_API_SECRET, {
281+
expiresIn: '2 days'
282+
});
283+
284+
const pgPort = 5656;
285+
286+
beforeAll(async () => {
287+
db = await PostgresDBRunner.startContainer({});
288+
await PostgresDBRunner.loadEcom(db);
289+
birdbox = await getBirdbox(
290+
'postgres',
291+
{
292+
...DEFAULT_CONFIG,
293+
CUBEJS_DEV_MODE: 'true',
294+
NODE_ENV: 'dev',
295+
//
296+
CUBEJS_DB_TYPE: 'postgres',
297+
CUBEJS_DB_HOST: db.getHost(),
298+
CUBEJS_DB_PORT: `${db.getMappedPort(5432)}`,
299+
CUBEJS_DB_NAME: 'test',
300+
CUBEJS_DB_USER: 'test',
301+
CUBEJS_DB_PASS: 'test',
302+
//
303+
CUBEJS_PG_SQL_PORT: `${pgPort}`,
304+
},
305+
{
306+
schemaDir: 'rbac/model',
307+
cubejsConfig: 'rbac/cube.js',
308+
}
309+
);
310+
client = cubejs(async () => DEFAULT_API_TOKEN, {
311+
apiUrl: birdbox.configuration.apiUrl,
312+
});
313+
}, JEST_BEFORE_ALL_DEFAULT_TIMEOUT);
314+
315+
afterAll(async () => {
316+
await birdbox.stop();
317+
await db.stop();
318+
}, JEST_AFTER_ALL_DEFAULT_TIMEOUT);
319+
320+
test('line_items hidden created_at', async () => {
321+
const meta = await client.meta();
322+
const dimensions = meta.meta.cubes.find(c => c.name === 'orders')?.dimensions;
323+
expect(dimensions?.length).toBe(2);
324+
for (const dim of dimensions || []) {
325+
expect(dim.isVisible).toBe(false);
326+
expect(dim.public).toBe(false);
327+
}
328+
});
329+
});

0 commit comments

Comments
 (0)