Skip to content

Commit

Permalink
fix: ensure public is in sync with isVisible when using DAP
Browse files Browse the repository at this point in the history
  • Loading branch information
bsod90 committed Nov 22, 2024
1 parent 47e7897 commit c5fa78b
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/cubejs-server-core/src/core/CompilerApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,8 @@ export class CompilerApi {
}
return (item) => ({
...item,
isVisible: item.isVisible && isMemberVisibleInContext[item.name]
isVisible: item.isVisible && isMemberVisibleInContext[item.name],
public: item.public && isMemberVisibleInContext[item.name]
});
};

Expand Down
63 changes: 63 additions & 0 deletions packages/cubejs-testing/test/smoke-rbac.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,3 +264,66 @@ describe('Cube RBAC Engine', () => {
});
});
});

describe('Cube RBAC Engine [dev mode]', () => {
jest.setTimeout(60 * 5 * 1000);
let db: StartedTestContainer;
let birdbox: BirdBox;
let client: CubeApi;

const DEFAULT_API_TOKEN = sign({
auth: {
username: 'nobody',
userAttributes: {},
roles: [],
},
}, DEFAULT_CONFIG.CUBEJS_API_SECRET, {
expiresIn: '2 days'
});

const pgPort = 5656;

beforeAll(async () => {
db = await PostgresDBRunner.startContainer({});
await PostgresDBRunner.loadEcom(db);
birdbox = await getBirdbox(
'postgres',
{
...DEFAULT_CONFIG,
CUBEJS_DEV_MODE: 'true',
NODE_ENV: 'dev',
//
CUBEJS_DB_TYPE: 'postgres',
CUBEJS_DB_HOST: db.getHost(),
CUBEJS_DB_PORT: `${db.getMappedPort(5432)}`,
CUBEJS_DB_NAME: 'test',
CUBEJS_DB_USER: 'test',
CUBEJS_DB_PASS: 'test',
//
CUBEJS_PG_SQL_PORT: `${pgPort}`,
},
{
schemaDir: 'rbac/model',
cubejsConfig: 'rbac/cube.js',
}
);
client = cubejs(async () => DEFAULT_API_TOKEN, {
apiUrl: birdbox.configuration.apiUrl,
});
}, JEST_BEFORE_ALL_DEFAULT_TIMEOUT);

afterAll(async () => {
await birdbox.stop();
await db.stop();
}, JEST_AFTER_ALL_DEFAULT_TIMEOUT);

test('line_items hidden created_at', async () => {
const meta = await client.meta();
const dimensions = meta.meta.cubes.find(c => c.name === 'orders')?.dimensions;
expect(dimensions?.length).toBe(2);
for (const dim of dimensions || []) {
expect(dim.isVisible).toBe(false);
expect(dim.public).toBe(false);
}
});
});

0 comments on commit c5fa78b

Please sign in to comment.