Skip to content

test(tenancy): integration test for per-repository gitRepositoryFilter scoping#1180

Merged
krusche merged 1 commit into
stagingfrom
test/repo-tenant-filter-integration-test
Jul 3, 2026
Merged

test(tenancy): integration test for per-repository gitRepositoryFilter scoping#1180
krusche merged 1 commit into
stagingfrom
test/repo-tenant-filter-integration-test

Conversation

@krusche

@krusche krusche commented Jul 3, 2026

Copy link
Copy Markdown
Member

Adds the coverage that was missing (and let the 1.7.0 cross-repo leak ship unnoticed).

Drives the real RepositoryInterceptor + real Hibernate @Filter + real Flyway schema on embedded Postgres (existing @DataJpaTest pattern). Seeds two repositories (repo A: 2 enabled envs, repo B: 1) and asserts:

  • scoped to A → only A's 2 envs;
  • scoped to B → only B's env;
  • no repo context → filter off, all repos returned (proves the filter is what scopes).

Fails exactly the way v1.7.0 would. Scope note in the class Javadoc: servlet-level OSIV ordering is verified in staging/prod, not reproduced here.

Lands before the 1.7.2 release per request.

…r scoping

Guards the 1.7.0 regression fixed in 1.7.2: verifies that RepositoryInterceptor enables the
Hibernate gitRepositoryFilter for web requests and that a tenant query is scoped to the current
repository, with no cross-repo leak. Runs against a real embedded Postgres + the Flyway schema
(the existing @DataJpaTest pattern), seeds two repositories with enabled environments, and asserts
that findByEnabledTrue is scoped per X-REPOSITORY-ID (and unscoped when no repo context is set).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 3, 2026 15:53
@krusche krusche requested a review from a team as a code owner July 3, 2026 15:53
@codacy-production

codacy-production Bot commented Jul 3, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 9 complexity

Metric Results
Complexity 9 (≤ 20 complexity)

View in Codacy

🟢 Coverage ∅ diff coverage · +0.11% coverage variation

Metric Results
Coverage variation +0.11% coverage variation (-1.00%)
Diff coverage diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (911e04f) 15441 7600 49.22%
Head commit (57048e2) 15441 (+0) 7617 (+17) 49.33% (+0.11%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#1180) 0 0 ∅ (not applicable)

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an integration test to prevent regressions in Helios’s per-repository tenant isolation by verifying that Hibernate’s gitRepositoryFilter is correctly enabled via the real RepositoryInterceptor path (the production mechanism that avoids the OSIV/transaction-initializer gap).

Changes:

  • Introduces an embedded-Postgres (zonky) @DataJpaTest that runs against the real Flyway schema.
  • Seeds two repositories with enabled environments and asserts correct scoping for repo A, repo B, and “no repository context” (filter off).
  • Drives the actual RepositoryInterceptor behavior to ensure web-request reads remain tenant-scoped.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@krusche krusche merged commit f0fa77b into staging Jul 3, 2026
24 checks passed
@krusche krusche deleted the test/repo-tenant-filter-integration-test branch July 3, 2026 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants