The GitHub Actions job "Required Checks" on 
texera.git/gh-readonly-queue/main/pr-7479-bbd5c976d7512f796251e5d5a8ca1495e5b3756f
 has succeeded.
Run started by GitHub user mengw15 (triggered by mengw15).

Head commit for run:
ca41bdd0cd1c99a164868afe6b0dce2d4c502105 / Xinyuan Lin <[email protected]>
test(amber): pin the dataset search's access-control branches (#7479)

### What changes were proposed in this PR?

Every member of `DatasetSearchQueryBuilder` is `override protected`, so
nothing is directly callable. The one public route in is the trait's
`final constructQuery`, and what it returns can be rendered to SQL and
inspected without ever executing it.

That reaches the part of the file with real consequences: **which
datasets a caller is allowed to see.**

Adds 9 tests. The one that matters most is the grant join's scoping
predicate — without `.eq(uid)` the `UID.isNotNull` check below is
satisfied by any user's grant row, which hands the caller every shared
dataset in the system. An anonymous caller must see public datasets only
and match no grant row at all; a private-only search must not leak
public datasets in.

Also covers the keyword split, `selectDistinct` being the sole dedup
(this builder alone has no `GROUP BY`, so the DISTINCT is all that
collapses the rows the access join multiplies out), and the `'dataset'`
literal that `DashboardResource` dispatches on with no default branch.

**Verified by mutation**, all reverted (production diff empty):

| Mutation | Result |
|---|---|
| grant join not scoped to the caller | red |
| anonymous caller matches any grant row | red |
| anonymous arm drops the public restriction | red |
| private-only search leaks public datasets | red |
| `includePublic` arm narrowed to public only | red |
| keyword splitting removed | red |
| a `GROUP BY` is introduced | red |
| resource type mis-tagged | red |

`toEntryImpl` is deliberately left uncovered — it is ~80% of this file's
uncovered lines and sits behind a live LakeFS call with no mockable
seam, so reaching it would need a source change rather than a test. That
is stated in the spec's header so the next reader does not re-derive it.

`MockTexeraDB` is initialized only because `SearchQueryBuilder.context`
reads `SqlServer.getInstance()`; no query is run against the database.

No production file is touched.

### Any related issues, documentation, discussions?

Closes #7476

### How was this PR tested?

```
sbt "WorkflowExecutionService/testOnly 
org.apache.texera.web.resource.dashboard.DatasetSearchQueryBuilderSpec"
```

```
[info] Tests: succeeded 9, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
```

`Test/scalafmtCheck` and `Test/scalafix --check` both pass.

### Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Opus 5)

Co-authored-by: Meng Wang <[email protected]>

Report URL: https://github.com/apache/texera/actions/runs/31346675968

With regards,
GitHub Actions via GitBox

Reply via email to