test: add userAttributes shorthand in mask.sql test cases#10668
test: add userAttributes shorthand in mask.sql test cases#10668paveltiunov wants to merge 4 commits intomasterfrom
Conversation
Add unit test in transpilers.test.ts verifying that userAttributes shorthand in mask.sql is transpiled to SECURITY_CONTEXT.cubeCloud.userAttributes. Add sc_ua_mask_test cube definition using userAttributes shorthand in mask.sql with access policy masking. Add smoke tests (SQL API and REST API) to verify the mask SQL with userAttributes shorthand works end-to-end. Co-authored-by: Pavel Tiunov <pavel.tiunov@gmail.com>
|
Claude finished @paveltiunov's task in 1m 32s —— View job Code Review:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #10668 +/- ##
===========================================
+ Coverage 57.92% 78.80% +20.88%
===========================================
Files 215 465 +250
Lines 16642 91903 +75261
Branches 3346 3346
===========================================
+ Hits 9640 72427 +62787
- Misses 6513 18987 +12474
Partials 489 489
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…UBE context - Tesseract: Include mask_sql dependencies and cube refs in DimensionSymbol.get_dependencies() and get_cube_refs(), and MeasureSymbol.get_dependencies() and get_cube_refs(). This ensures join hints are collected from mask SQL references. - Transpiler: Ensure mask.sql always has CUBE as a default parameter in the arrow function, even when not explicitly referenced. This provides consistent CUBE context for mask SQL expressions. - YamlCompiler: Pass ensureCubeParam flag for mask.sql fields so YAML-defined masks also get default CUBE context. - Tests: Add unit tests for CUBE default parameter in mask.sql and CUBE reference resolution in masked queries. Add smoke RBAC tests for CUBE context in mask SQL via SQL API and REST API. Co-authored-by: Pavel Tiunov <pavel.tiunov@gmail.com>
…and CUBE context in mask SQL Add a new 'Cube RBAC Engine [Tesseract]' describe block that runs with CUBESQL_SQL_PUSH_DOWN=true to exercise the Tesseract/native SQL planner path for mask SQL features. Co-authored-by: Pavel Tiunov <pavel.tiunov@gmail.com>
…level fixes Transpilation already correctly handles CUBE context for mask.sql - when mask.sql references cube members or CUBE explicitly, the transpiler adds CUBE as a parameter. The default CUBE context issue is in the evaluation path, not transpilation. Reverted: - CubePropContextTranspiler: removed maskSqlPattern, ensureCubeParam - YamlCompiler: removed ensureCubeParam plumbing - Removed 'mask.sql should always have CUBE as default parameter' test Kept: - Tesseract mask_sql dependency collection fixes (dimension + measure) - mask.sql with CUBE reference resolution test - All smoke tests (non-Tesseract and Tesseract) Co-authored-by: Pavel Tiunov <pavel.tiunov@gmail.com>
|
Claude finished @paveltiunov's task in 2m 38s —— View job Code Review:
|
| Area | Verdict |
|---|---|
| Rust fix correctness | ✅ Correct |
iter_sql_calls / apply_to_deps completeness |
|
| Unit tests | ✅ Clean, follows patterns |
| Smoke fixtures | ✅ Well-constructed |
| Smoke tests | ✅ Correct assertions |
| Test coverage | ✅ 3-level coverage (unit + SQL API + REST API) for both Tesseract and non-Tesseract |
Check List
Description of Changes Made
This PR adds test coverage for the
userAttributesshorthand inmask.sql, fixes mask SQL join dependency collection in Tesseract, and adds tests for CUBE context in mask SQL.Fixes
Tesseract: Include mask SQL in join dependency collection
DimensionSymbol.get_dependencies()andget_cube_refs()now include dependencies and cube references frommask_sql, not just the mainmember_sql. Same forMeasureSymbol. This ensures that when a mask SQL expression references members from another cube, those references are included in join hint collection, preventing missing joins.Files changed:
rust/cubesqlplanner/cubesqlplanner/src/planner/sql_evaluator/symbols/dimension_symbol.rsrust/cubesqlplanner/cubesqlplanner/src/planner/sql_evaluator/symbols/measure_symbol.rsTests
Unit tests (
packages/cubejs-schema-compiler/test/unit/transpilers.test.ts):userAttributes shorthand in mask.sql should transpile to SECURITY_CONTEXTmask.sql with CUBE reference should resolve correctly— Verifies${CUBE}.columnresolves to proper table-qualified SQL in masked queriesSmoke RBAC fixtures (
packages/cubejs-testing/birdbox-fixtures/rbac/model/cubes/security_context_test.js):sc_ua_mask_test— Cube usinguserAttributes.tenantIdshorthand in mask SQLsc_cube_mask_test— Cube using${CUBE}.product_id * -1as mask SQLSmoke RBAC tests (
packages/cubejs-testing/test/smoke-rbac.test.ts):Non-Tesseract (12 tests):
userAttributes shorthand in mask sql(SQL + REST)CUBE context in mask sql(SQL + REST)Tesseract-enabled with
CUBESQL_SQL_PUSH_DOWN=true(4 tests):userAttributes shorthand in mask sql(SQL + REST)CUBE context in mask sql(SQL + REST)Test Results