-
Notifications
You must be signed in to change notification settings - Fork 39
feat(ers): DSPX-4581 add ERS multi-strategy and transformation BDD scenarios #3953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
khvirtru
wants to merge
4
commits into
main
Choose a base branch
from
feat/dspx-4581-ers-bdd-gaps
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+210
−0
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
dd63184
feat(bdd): add ERS multi-success and transformation BDD scenarios
khvirtru 5e442b3
feat(bdd): add AND semantics gap scenario for multi-entity chains
khvirtru 2061791
fix(bdd): clarify scenario names and add AND semantics gap test
khvirtru 8688ec2
fix(bdd): align multi-strategy scenarios with ADR first-match-wins be…
khvirtru File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| @ers-transformation-service @stateless | ||
| Feature: Transformations through the ERS service path | ||
| Validate that output_mapping transformations (array, csv_to_array, lowercase) | ||
| work correctly through the full ERS service → gRPC → authorization pipeline, | ||
| not just at the unit test level. | ||
|
|
||
| Transformation unit tests exist in claims_mapper_test.go and ldap_mapper_test.go, | ||
| but no BDD feature exercises a transformation through the actual service path | ||
| where OutputMapper is called (service.go:269-271). This catches integration | ||
| issues between transformation output format and subject mapping evaluation. | ||
|
|
||
| This covers Jake's gap analysis row #5. | ||
|
|
||
| Background: | ||
| And an ERS configuration with mode "multi-strategy" and failure strategy "continue" | ||
| And an ERS provider "jwt_claims" of type "claims" | ||
| And an ERS mapping strategy "claims_with_array_transform" using provider "jwt_claims" | ||
| """ | ||
| entity_type: subject | ||
| conditions: | ||
| jwt_claims: | ||
| - claim: userName | ||
| operator: exists | ||
| output_mapping: | ||
| - source_claim: department | ||
| claim_name: department | ||
| transformation: array | ||
| - source_claim: userName | ||
| claim_name: username | ||
| """ | ||
| And a local platform with inline ERS configuration | ||
|
|
||
| Scenario: Array transformation — string claim transformed to array matches anyOf selector | ||
| Given I submit a request to create a namespace with name "xform-array.test" and reference id "ns_xa" | ||
| And I send a request to create an attribute with: | ||
| | namespace_id | name | rule | values | | ||
| | ns_xa | department | anyOf | engineering,marketing,security | | ||
| Then the response should be successful | ||
| Given a condition group referenced as "cg_xa" with an "or" operator with conditions: | ||
| | selector_value | operator | values | | ||
| | .department[] | in | engineering | | ||
| And a subject set referenced as "ss_xa" containing the condition groups "cg_xa" | ||
| And I send a request to create a subject condition set referenced as "scs_xa" containing subject sets "ss_xa" | ||
| And I send a request to create a subject mapping with: | ||
| | reference_id | attribute_value | condition_set_name | standard actions | custom actions | | ||
| | sm_xa | https://xform-array.test/attr/department/value/engineering | scs_xa | read | | | ||
| Then the response should be successful | ||
| Given there is a claims subject entity referenced as "alice_xa" with claims: | ||
| """ | ||
| {"userName":"alice","department":"engineering"} | ||
| """ | ||
| When I send a decision request for entity chain "alice_xa" for "read" action on resource "https://xform-array.test/attr/department/value/engineering" | ||
| Then the response should be successful | ||
| And I should get a "PERMIT" decision response | ||
|
|
||
| Scenario: Array transformation — non-matching value gets DENY | ||
| Given I submit a request to create a namespace with name "xform-array-deny.test" and reference id "ns_xad" | ||
| And I send a request to create an attribute with: | ||
| | namespace_id | name | rule | values | | ||
| | ns_xad | department | anyOf | engineering,marketing,security | | ||
| Then the response should be successful | ||
| Given a condition group referenced as "cg_xad" with an "or" operator with conditions: | ||
| | selector_value | operator | values | | ||
| | .department[] | in | engineering | | ||
| And a subject set referenced as "ss_xad" containing the condition groups "cg_xad" | ||
| And I send a request to create a subject condition set referenced as "scs_xad" containing subject sets "ss_xad" | ||
| And I send a request to create a subject mapping with: | ||
| | reference_id | attribute_value | condition_set_name | standard actions | custom actions | | ||
| | sm_xad | https://xform-array-deny.test/attr/department/value/engineering | scs_xad | read | | | ||
| Then the response should be successful | ||
| Given there is a claims subject entity referenced as "bob_xad" with claims: | ||
| """ | ||
| {"userName":"bob","department":"marketing"} | ||
| """ | ||
| When I send a decision request for entity chain "bob_xad" for "read" action on resource "https://xform-array-deny.test/attr/department/value/engineering" | ||
| Then the response should be successful | ||
| And I should get a "DENY" decision response | ||
|
|
107 changes: 107 additions & 0 deletions
107
tests-bdd/features/multi-strategy-ers-multi-success.feature
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| @multi-strategy-ers-multi-success @stateless | ||
| Feature: Multiple successful strategies under continue build multi-entity chain | ||
| Validate that failure_strategy "continue" keeps evaluating strategies after a | ||
| successful match, building a richer entity chain via CreateEntityChainsFromTokens. | ||
| When both claims and LDAP strategies succeed for the same JWT token, the chain | ||
| contains entities from both strategies. Each entity is evaluated independently | ||
| for authorization (AND semantics), so both must be entitled for PERMIT. | ||
|
|
||
| This covers Jake's gap analysis row #4: no existing test verifies the resulting | ||
| multi-entity chain when two strategies both succeed under continue. | ||
|
|
||
| Background: | ||
| Given an LDAP directory with test users | ||
| And a user exists with username "alice" and email "alice@opentdf.test" and the following attributes: | ||
| | name | value | | ||
| And a user exists with username "eve" and email "eve@opentdf.test" and the following attributes: | ||
| | name | value | | ||
| And an ERS configuration with mode "multi-strategy" and failure strategy "continue" | ||
| And an ERS provider "jwt_claims" of type "claims" | ||
| And an ERS provider "ldap_directory" of type "ldap" connected to the LDAP directory | ||
| And an ERS mapping strategy "claims_identity" using provider "jwt_claims" | ||
| """ | ||
| entity_type: subject | ||
| conditions: | ||
| jwt_claims: | ||
| - claim: preferred_username | ||
| operator: exists | ||
| output_mapping: | ||
| - source_claim: preferred_username | ||
| claim_name: username | ||
| """ | ||
| And an ERS mapping strategy "ldap_department" using provider "ldap_directory" | ||
| """ | ||
| entity_type: subject | ||
| conditions: | ||
| jwt_claims: | ||
| - claim: preferred_username | ||
| operator: exists | ||
| ldap_search: | ||
| base_dn: "ou=users,dc=opentdf,dc=test" | ||
| filter: "(&(objectClass=inetOrgPerson)(uid={username}))" | ||
| scope: subtree | ||
| attributes: ["uid", "departmentNumber"] | ||
| input_mapping: | ||
| - jwt_claim: preferred_username | ||
| parameter: username | ||
| output_mapping: | ||
| - source_attribute: departmentNumber | ||
| claim_name: department | ||
| - source_attribute: uid | ||
| claim_name: username | ||
| """ | ||
| And a local platform with inline ERS configuration | ||
|
|
||
| Scenario: Both strategies succeed — multi-entity chain built, both entities entitled → PERMIT | ||
| Given I submit a request to create a namespace with name "multi-success.test" and reference id "ns_ms" | ||
| And I send a request to create an attribute with: | ||
| | namespace_id | name | rule | values | | ||
| | ns_ms | department | anyOf | engineering,marketing,security | | ||
| Then the response should be successful | ||
| # Subject mapping uses .username which both claims and LDAP entities output. | ||
| # This ensures both entities in the multi-entity chain are entitled (AND semantics). | ||
| Given a condition group referenced as "cg_ms" with an "or" operator with conditions: | ||
| | selector_value | operator | values | | ||
| | .username | in | alice | | ||
| And a subject set referenced as "ss_ms" containing the condition groups "cg_ms" | ||
| And I send a request to create a subject condition set referenced as "scs_ms" containing subject sets "ss_ms" | ||
| And I send a request to create a subject mapping with: | ||
| | reference_id | attribute_value | condition_set_name | standard actions | custom actions | | ||
| | sm_ms | https://multi-success.test/attr/department/value/engineering | scs_ms | read | | | ||
| Then the response should be successful | ||
| # Alice's token triggers both strategies under continue: | ||
| # 1. Claims strategy outputs {username: alice} | ||
| # 2. LDAP strategy finds alice → outputs {department: engineering, username: alice} | ||
| # Both entities have username=alice → both match subject mapping → PERMIT | ||
| # This proves continue builds a 2-entity chain (not just the first match). | ||
| Given a user access token for "alice" stored as "alice_token" | ||
| When I send a decision request for token "alice_token" for "read" action on resource "https://multi-success.test/attr/department/value/engineering" | ||
| Then the response should be successful | ||
| And I should get a "PERMIT" decision response | ||
|
|
||
| Scenario: Both strategies succeed — one entity not entitled → DENY (AND semantics) | ||
| Given I submit a request to create a namespace with name "multi-success-deny.test" and reference id "ns_msd" | ||
| And I send a request to create an attribute with: | ||
| | namespace_id | name | rule | values | | ||
| | ns_msd | department | anyOf | engineering,marketing,security | | ||
| Then the response should be successful | ||
| # Subject mapping requires department=engineering. Claims entity doesn't output | ||
| # department so it fails entitlement. Even though LDAP entity has department=operations, | ||
| # both entities must pass (AND) → DENY. | ||
| Given a condition group referenced as "cg_msd" with an "or" operator with conditions: | ||
| | selector_value | operator | values | | ||
| | .department | in | engineering | | ||
| And a subject set referenced as "ss_msd" containing the condition groups "cg_msd" | ||
| And I send a request to create a subject condition set referenced as "scs_msd" containing subject sets "ss_msd" | ||
| And I send a request to create a subject mapping with: | ||
| | reference_id | attribute_value | condition_set_name | standard actions | custom actions | | ||
| | sm_msd | https://multi-success-deny.test/attr/department/value/engineering | scs_msd | read | | | ||
| Then the response should be successful | ||
| # Eve's token also triggers both strategies: | ||
| # 1. Claims entity: no department → not entitled | ||
| # 2. LDAP entity: department=operations (not engineering) → not entitled | ||
| # Both entities fail → DENY | ||
| Given a user access token for "eve" stored as "eve_token" | ||
| When I send a decision request for token "eve_token" for "read" action on resource "https://multi-success-deny.test/attr/department/value/engineering" | ||
| Then the response should be successful | ||
| And I should get a "DENY" decision response | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Make the DENY case distinguish AND evaluation.
Both entities currently fail
.department in engineering: the claims entity has nodepartment, and the LDAP entity is described asdepartment=operations. An OR evaluator or a first-success evaluator also returns DENY.Set Eve's LDAP
departmentNumbertoengineering. The LDAP entity will then match while the claims entity fails. The expected DENY will prove that both entities must be entitled.🤖 Prompt for AI Agents