Skip to content

chore(ers): expand multi-strategy ERS BDD coverage - #3791

Merged
elizabethhealy merged 3 commits into
opentdf:mainfrom
khvirtru:test/multi-strategy-ers-coverage
Aug 7, 2026
Merged

chore(ers): expand multi-strategy ERS BDD coverage#3791
elizabethhealy merged 3 commits into
opentdf:mainfrom
khvirtru:test/multi-strategy-ers-coverage

Conversation

@khvirtru

@khvirtru khvirtru commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Blocked by #3794@claims-only-ers scenarios will fail until the #3790 fix lands. The other two features (@multi-strategy-ers-failfast, @claims-ldap-fallback-ers) pass independently.

Expands multi-strategy ERS BDD test coverage (DSPX-4100) with three new feature files:

  • @multi-strategy-ers-failfast — Demonstrates that failure_strategy: "fail-fast" stops entity resolution at the first strategy error, preventing LDAP fallback. Alice gets DENY (vs PERMIT under continue in the existing feature).

  • @claims-ldap-fallback-ers — Validates condition-based strategy routing: a claims strategy with condition department exists is skipped when the entity lacks department, and the LDAP strategy with condition userName exists provides it via fallback. Covers both PERMIT (engineering user via LDAP) and DENY (operations user via LDAP).

  • @claims-only-ers — Validates that Entity_Claims entities carrying inline claims can be resolved by a claims-only multi-strategy ERS without LDAP. Currently fails due to fix(ers): ResolveEntities does not populate JWTClaimsContextKey for claims provider #3790; will pass once fix(ers): pass inline claims through multi-strategy context #3794 merges.

Also adds a DocString-based step definition for creating claims entities with embedded JSON.

Test results

Tag Scenarios Result
@multi-strategy-ers-failfast 1 ✅ Pass
@claims-ldap-fallback-ers 2 ✅ All pass
@claims-only-ers 2 ⏳ Blocked by #3794
@multi-strategy-ers (existing) 3 ✅ All pass (no regression)

Related

Test plan

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Added end-to-end coverage for claims-based access decisions.
    • Added stateless claims-only access scenarios.
    • Added coverage for fallback from claims to LDAP when claims are unavailable.
    • Added validation that fail-fast behavior prevents fallback after a claims resolution error.
    • Verified expected permit and deny outcomes for engineering and non-engineering access scenarios across supported resolution paths.

@khvirtru
khvirtru requested a review from a team as a code owner July 27, 2026 17:34
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@khvirtru, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 55 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 534dacb7-0626-4bc3-8b39-48bce3840b5a

📥 Commits

Reviewing files that changed from the base of the PR and between 39aa223 and bb18bd4.

📒 Files selected for processing (2)
  • tests-bdd/features/claims-ldap-fallback-ers.feature
  • tests-bdd/features/multi-strategy-ers-failfast.feature
📝 Walkthrough

Walkthrough

The PR adds BDD coverage for claims-only ERS, claims-to-LDAP fallback, and fail-fast routing. The scenarios verify permit and deny authorization decisions.

Changes

Claims ERS routing

Layer / File(s) Summary
Claims-only ERS scenarios
tests-bdd/features/claims-only-ers.feature
The feature configures claims-only ERS and verifies permit for engineering claims and deny for marketing claims.
Claims-to-LDAP fallback scenarios
tests-bdd/features/claims-ldap-fallback-ers.feature
The feature configures conditional claims and LDAP routing and verifies LDAP fallback for engineering and non-engineering users.
Fail-fast strategy scenario
tests-bdd/features/multi-strategy-ers-failfast.feature
The feature configures fail-fast routing and verifies deny when claims resolution fails before LDAP fallback.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: elizabethhealy, jakedoublev

Poem

A rabbit checks each claims route,
Engineering permits come out.
LDAP acts when claims are absent,
Fail-fast stops the next request.
BDD records each result. 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: expanded BDD coverage for multi-strategy ERS.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests-bdd/features/claims-only-ers.feature`:
- Around line 52-73: Strengthen the “Claims entity with marketing department
gets DENY” scenario so it verifies Bob’s marketing claim is resolved rather than
relying only on the DENY result. Add a corresponding marketing resource/action
that must return PERMIT, or assert the resolved department claim before the
existing engineering DENY request, while preserving the current negative case.
- Around line 6-9: Mark the claims-only ERS feature with the repository’s
executable pending/skip control so its scenarios are excluded from normal Godog
runs. Update the feature metadata near the existing NOTE in
claims-only-ers.feature, preserving the `@claims-only-ers` tag and ensuring the
quarantine can be removed once ResolveEntities fixes issue `#3790`.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: e6f2988a-abd4-41ac-be12-c11291c97f1d

📥 Commits

Reviewing files that changed from the base of the PR and between f203f14 and df002c9.

📒 Files selected for processing (4)
  • tests-bdd/cukes/steps_authorization.go
  • tests-bdd/features/claims-ldap-fallback-ers.feature
  • tests-bdd/features/claims-only-ers.feature
  • tests-bdd/features/multi-strategy-ers-failfast.feature

Comment thread tests-bdd/features/claims-only-ers.feature Outdated
Comment thread tests-bdd/features/claims-only-ers.feature
khvirtru added a commit to khvirtru/platform that referenced this pull request Aug 3, 2026
…s, regex (opentdf#3797)

## Summary

Adds BDD test coverage for the three untested condition operators in
multi-strategy ERS strategy matching:

- **`@ers-condition-equals`** — 3 scenarios: exact match (alice PERMIT),
negative match (bob DENY), case-insensitive matching (`values:
["ALICE"]` matches userName `alice`)
- **`@ers-condition-contains`** — 3 scenarios: substring match (`"ali"`
in `"alice"` PERMIT), negative match (bob DENY), AND logic (two
`contains` conditions — only `"diana"` matches both)
- **`@ers-condition-regex`** — 3 scenarios: pattern match (`^[a-d].*`
matches alice PERMIT), negative match (henry DENY), AND logic (regex +
exists conditions)

All 9 scenarios use LDAP strategies with `user_name` entities, avoiding
the claims provider bug (opentdf#3790). Each feature file is `@stateless` and
runs independently.

### Coverage before/after

| Operator | Unit tests | BDD tests (before) | BDD tests (after) |
|----------|-----------|--------------------|--------------------|
| `exists` | Many | Many | Many |
| `equals` | 1 (negative only) | 0 | 3 |
| `contains` | 0 | 0 | 3 |
| `regex` | 0 | 0 | 3 |
| AND logic (multiple conditions) | 0 | 0 | 2 |

### Related

- opentdf#3790 — claims provider context bug (why these tests use LDAP, not
claims)
- opentdf#3791 — fail-fast, fallback, and claims-only BDD tests
- DSPX-4100 — multi-strategy ERS BDD coverage

## Test plan

- [ ] CI: all 9 scenarios should pass (equals, contains, regex)
- [ ] Run locally with `--godog.tags=@ers-condition-equals` /
`@ers-condition-contains` / `@ers-condition-regex`

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Tests**
* Added BDD coverage for ERS condition operators: `contains`, `equals`
(including case-insensitive and multi-value), `regex`, and
mixed-operator AND logic.
* Validated substring and pattern matching semantics, non-matching
behavior, and scenario routing outcomes.
* Added end-to-end decision requests asserting expected **`PERMIT`** and
**`DENY`** results across the new scenarios.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@khvirtru
khvirtru force-pushed the test/multi-strategy-ers-coverage branch from df002c9 to af75b19 Compare August 3, 2026 14:36

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests-bdd/features/multi-strategy-ers-failfast.feature`:
- Around line 70-73: Extend the scenario around the decision request for
“alice_ff” to explicitly verify that the first ERS strategy errors under
fail-fast and that LDAP resolution is not attempted for this user, rather than
relying only on the DENY response. Use the existing BDD steps or add focused
assertions for the ERS error and absence of LDAP resolution while preserving the
successful response and DENY outcome.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c25923f9-f9a4-45e6-a14a-26f87c6240cb

📥 Commits

Reviewing files that changed from the base of the PR and between df002c9 and af75b19.

📒 Files selected for processing (2)
  • tests-bdd/features/claims-ldap-fallback-ers.feature
  • tests-bdd/features/multi-strategy-ers-failfast.feature

Comment thread tests-bdd/features/multi-strategy-ers-failfast.feature
…scenarios

Three new multi-strategy ERS feature files:
- claims-only-ers.feature: Entity_Claims with inline claims resolved by
  claims-only strategy (PERMIT/DENY based on department)
- claims-ldap-fallback-ers.feature: claims→LDAP fallback where LDAP
  enriches user_name entities with department claim
- multi-strategy-ers-failfast.feature: fail-fast strategy aborts at
  first error, preventing LDAP fallback

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Ken Ho <kho@virtru.com>
@khvirtru
khvirtru force-pushed the test/multi-strategy-ers-coverage branch from f12b378 to 211ce37 Compare August 5, 2026 15:57
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

Comment thread tests-bdd/features/claims-only-ers.feature Outdated
Comment thread tests-bdd/features/claims-ldap-fallback-ers.feature
Comment thread tests-bdd/features/claims-ldap-fallback-ers.feature
Comment thread tests-bdd/features/claims-only-ers.feature
Comment thread tests-bdd/features/claims-ldap-fallback-ers.feature
elizabethhealy
elizabethhealy previously approved these changes Aug 5, 2026

@elizabethhealy elizabethhealy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

mostly comments on how we can expand coverage, they can be tackled in follow ups if desired

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Ken Ho <kho@virtru.com>
…perly

claims-ldap-fallback-ers.feature:
- Change claims condition from "department exists" to "userName exists" so
  the claims strategy is actually selected for user_name entities, fails,
  and continue mode allows LDAP fallback (previously claims was just skipped)
- Add Entity_Claims fast-path scenario showing claims resolves directly
  without needing LDAP when inline claims carry the needed attributes

multi-strategy-ers-failfast.feature:
- Add department to claims_passthrough output_mapping
- Add Entity_Claims PERMIT scenario proving fail-fast only triggers on
  actual strategy errors, not universally

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Ken Ho <kho@virtru.com>
@elizabethhealy
elizabethhealy added this pull request to the merge queue Aug 6, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 6, 2026
@elizabethhealy
elizabethhealy added this pull request to the merge queue Aug 7, 2026
Merged via the queue into opentdf:main with commit 6c0baa0 Aug 7, 2026
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants