Skip to content

chore(ers): add BDD scenarios for condition operators equals, contains, regex - #3797

Merged
elizabethhealy merged 3 commits into
opentdf:mainfrom
khvirtru:test/ers-condition-operators
Jul 30, 2026
Merged

chore(ers): add BDD scenarios for condition operators equals, contains, regex#3797
elizabethhealy merged 3 commits into
opentdf:mainfrom
khvirtru:test/ers-condition-operators

Conversation

@khvirtru

@khvirtru khvirtru commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

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 (#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

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

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.

…s, regex

Cover the three untested condition operators in multi-strategy ERS:
- equals: exact match, negative match, case-insensitive (EqualFold)
- contains: substring match, negative match, AND logic (multiple conditions)
- regex: pattern match, negative match, AND logic (regex + exists)

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

Part of DSPX-4100.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@khvirtru
khvirtru requested a review from a team as a code owner July 29, 2026 13:38
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 60428150-5ad5-4410-9731-b8b9f0f66dca

📥 Commits

Reviewing files that changed from the base of the PR and between 843f8f6 and 8d038ce.

📒 Files selected for processing (7)
  • tests-bdd/features/ers-condition-and-logic.feature
  • tests-bdd/features/ers-condition-and-mixed.feature
  • tests-bdd/features/ers-condition-contains.feature
  • tests-bdd/features/ers-condition-equals-ci.feature
  • tests-bdd/features/ers-condition-equals-multi.feature
  • tests-bdd/features/ers-condition-equals.feature
  • tests-bdd/features/ers-condition-regex.feature

📝 Walkthrough

Walkthrough

Adds BDD feature coverage for ERS contains, equals, and regex JWT claim conditions, including case-insensitive matching, multi-value matching, non-matching denial, and combined-condition behavior using LDAP-backed configurations.

Changes

ERS condition operators

Layer / File(s) Summary
Single-condition operator scenarios
tests-bdd/features/ers-condition-contains.feature, tests-bdd/features/ers-condition-equals*.feature, tests-bdd/features/ers-condition-regex.feature
Adds LDAP-backed scenarios for case-insensitive contains and equals matching, regex matching, and denial when conditions do not match.
Equals multi-value scenarios
tests-bdd/features/ers-condition-equals-multi.feature
Verifies PERMIT when the claim matches either configured value and DENY when it matches neither.
Combined condition logic
tests-bdd/features/ers-condition-and-logic.feature, tests-bdd/features/ers-condition-and-mixed.feature
Verifies AND semantics for multiple contains conditions and for mixed regex plus contains conditions.

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

Suggested reviewers: jrschumacher

Poem

A rabbit hops through claims so bright,
Tests match by day and deny by night.
Equals, contains, regex in flight,
LDAP guides each decision right.
“PERMIT!” we cheer in moonbeam light.

🚥 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 accurately summarizes the main change: new BDD scenarios covering equals, contains, and regex ERS condition operators.
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.

With @stateless, the platform starts once per feature file and the ERS
config from the Background is fixed for all scenarios. Scenarios that
need different strategy configs must be in separate feature files.

Split into 5 feature files:
- ers-condition-equals: match + no-match (shared strategy)
- ers-condition-equals-ci: case-insensitive (values: ["ALICE"])
- ers-condition-contains: substring match + no-match
- ers-condition-regex: pattern match + no-match
- ers-condition-and-logic: multiple conditions AND logic + partial match

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment thread tests-bdd/features/ers-condition-and-logic.feature Outdated
Comment thread tests-bdd/features/ers-condition-and-logic.feature
Comment thread tests-bdd/features/ers-condition-contains.feature
Comment thread tests-bdd/features/ers-condition-contains.feature Outdated
Comment thread tests-bdd/features/ers-condition-equals.feature
elizabethhealy
elizabethhealy previously approved these changes Jul 30, 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.

looks good, some comments about some cases to add to get fuller coverage + 1 about discrepancy in the description vs what its actually testing. but you could tackle them as a follow on if you want

@policy-bot-opentdf
policy-bot-opentdf Bot dismissed elizabethhealy’s stale review July 30, 2026 15:02

Comment was edited

Fixes and additions per Elizabeth Healy's review:

1. Fix AND partial-match: change conditions from contains "an" + "di"
   to contains "a" + "di" so alice matches one (not zero) — properly
   tests AND short-circuit

2. Fix contains case-insensitivity: change values to ["ALI"] (uppercase)
   so existing scenarios actually validate case-insensitive matching

3. Add mixed-operator AND: new ers-condition-and-mixed.feature with
   regex + contains conditions (diana matches both, alice matches only
   regex)

4. Add multi-value OR: new ers-condition-equals-multi.feature with
   values: ["alice", "diana"] testing OR-within-condition semantics

5. Array claim testing noted as blocked by opentdf#3790 (requires
   Entity_Claims which needs JWTClaimsContextKey fix)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@elizabethhealy
elizabethhealy added this pull request to the merge queue Jul 30, 2026
Merged via the queue into opentdf:main with commit 8ce0e17 Jul 30, 2026
46 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