Skip to content

feat(ci): Enhance authorization bdd test coverage - #3298

Merged
elizabethhealy merged 59 commits into
mainfrom
dspx-1311-add-more-authorization-bdd-tests
Jun 25, 2026
Merged

feat(ci): Enhance authorization bdd test coverage#3298
elizabethhealy merged 59 commits into
mainfrom
dspx-1311-add-more-authorization-bdd-tests

Conversation

@elizabethhealy

@elizabethhealy elizabethhealy commented Apr 10, 2026

Copy link
Copy Markdown
Member

Proposed Changes

  • Enhances cukes authorization test covererage to cover: attribute rules, enhanced obligations coverage, enhanced RR coverage, multi resource decisions

Checklist

  • I have added or updated unit tests
  • I have added or updated integration tests (if appropriate)
  • I have added or updated documentation

Testing Instructions

Summary by CodeRabbit

  • New Features

    • Configuration-driven enabling of direct entitlements from claims-based entities
    • Multi-resource authorization decisioning with per-resource decision evaluation
    • Attribute rules decisioning supporting anyOf, allOf, and hierarchy evaluation patterns
  • Tests

    • Comprehensive BDD coverage for direct entitlements validation
    • Multi-resource decision request scenarios and assertions
    • Registered resource decisioning and attribute rules evaluation test cases

@github-actions

Copy link
Copy Markdown
Contributor
Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 195.515474ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 99.671175ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 398.536906ms
Throughput 250.92 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 42.426087379s
Average Latency 422.579076ms
Throughput 117.85 requests/second

Base automatically changed from dspx-2753-rr-aav-bdd-namespaced-policy-tests to main April 22, 2026 20:52
@github-actions

Copy link
Copy Markdown
Contributor
Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 175.525407ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 91.162492ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 420.433638ms
Throughput 237.85 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 42.628249579s
Average Latency 424.946181ms
Throughput 117.29 requests/second

@elizabethhealy
elizabethhealy marked this pull request as ready for review April 24, 2026 19:21
@elizabethhealy
elizabethhealy requested a review from a team as a code owner April 24, 2026 19:21

@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: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@service/entityresolution/claims/v2/entity_resolution_test.go`:
- Around line 96-153: Add a third test (e.g.,
Test_ClaimsResolveEntityDirectEntitlementsMalformed) in
entity_resolution_test.go that builds a claims struct with malformed/partial
"direct_entitlements" (e.g., an entry missing "attribute_value_fqn" and another
with "actions" as a non-array), call claims.EntityResolution(...) with the
feature flag enabled (true), and assert the function safely ignores malformed
entries (no panic/error and resulting
entityRepresentations[0].GetDirectEntitlements() does not include invalid items
— expect empty or only valid entries) to pin down parser skip/error behavior;
reference claims.EntityResolution and the existing
Test_ClaimsResolveEntityDirectEntitlements/Test_ClaimsResolveEntityDirectEntitlementsDisabled
for structure.

In `@service/entityresolution/claims/v2/entity_resolution.go`:
- Around line 262-298: In parseDirectEntitlementActions, the case handling
[]string is effectively unreachable when inputs come from structpb
(Struct.AsMap/Value_ListValue yields []interface{}); either remove the []string
branch to avoid confusion or keep it but add a brief comment above the case
noting it is defensive for non-structpb inputs, so future readers understand why
it exists; reference the function name parseDirectEntitlementActions and the
[]string case to locate the change.
- Around line 38-49: Replace the stdlib log.Fatalf call in RegisterClaimsERS
with a panic using fmt.Sprintf so startup errors are raised consistently with
other registry-aware ERS constructors; when mapstructure.Decode returns an
error, keep the existing logger.Error line and then call
panic(fmt.Sprintf("Failed to decode claims entity resolution configuration: %v",
err)) so the service registry can catch and handle the panic (refer to
RegisterClaimsERS, mapstructure.Decode and logger.Error in this function).

In `@tests-bdd/cukes/steps_authorization.go`:
- Around line 493-545: In parseClaimsTable, avoid silently swallowing JSON parse
errors: when rawValue is non-empty and looks JSON-like (e.g., starts with '{' or
'[' or a digit) attempt json.Unmarshal and if it fails return that unmarshal
error instead of falling back to the raw string; only use parsed = rawValue as a
fallback for non-JSON-like tokens. Update the json.Unmarshal error handling in
parseClaimsTable to detect JSON-like rawValue and propagate the error for those
cases while preserving the existing string fallback for plain tokens.
- Around line 129-135: The local variable named "entity" shadows the imported
package "entity"; rename the local variable (e.g., to entityObj or
subjectEntity) where it's defined in the Entity literal so it no longer
conflicts with the package, update all subsequent uses (including
scenarioContext.RecordObject(referenceID, ...)) to the new name, and ensure
references to package-level identifiers like entity.Entity_CATEGORY_SUBJECT and
entity.Entity_Claims remain as package-qualified names.
🪄 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

Run ID: b1a5b8cd-7ba8-49cb-b6f5-0e4baf2f576e

📥 Commits

Reviewing files that changed from the base of the PR and between 1179486 and 4adac6f.

📒 Files selected for processing (11)
  • service/entityresolution/claims/v2/entity_resolution.go
  • service/entityresolution/claims/v2/entity_resolution_test.go
  • tests-bdd/cukes/resources/platform.direct_entitlements.template
  • tests-bdd/cukes/steps_authorization.go
  • tests-bdd/cukes/steps_obligations.go
  • tests-bdd/cukes/steps_registeredresources.go
  • tests-bdd/features/attribute-rules.feature
  • tests-bdd/features/direct-entitlements.feature
  • tests-bdd/features/multi-resource.feature
  • tests-bdd/features/obligations.feature
  • tests-bdd/features/registered-resources.feature
💤 Files with no reviewable changes (1)
  • tests-bdd/cukes/steps_obligations.go

Comment thread service/entityresolution/claims/v2/entity_resolution_test.go Outdated
Comment thread service/entityresolution/claims/v2/entity_resolution.go Outdated
Comment thread service/entityresolution/claims/v2/entity_resolution.go Outdated
Comment thread tests-bdd/cukes/steps_authorization.go Outdated
Comment thread tests-bdd/cukes/steps_authorization.go Outdated
@github-actions

Copy link
Copy Markdown
Contributor
Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 204.026241ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 113.961993ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 426.550718ms
Throughput 234.44 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 46.117583266s
Average Latency 459.393453ms
Throughput 108.42 requests/second

@github-actions

Copy link
Copy Markdown
Contributor
Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 228.487702ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 116.790728ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 444.707858ms
Throughput 224.87 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 45.900000057s
Average Latency 457.362777ms
Throughput 108.93 requests/second

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Govulncheck found vulnerabilities ⚠️

The following modules have known vulnerabilities:

  • examples
  • otdfctl
  • sdk
  • service
  • lib/fixtures
  • tests-bdd

See the workflow run for details.

@elizabethhealy
elizabethhealy added this pull request to the merge queue Jun 25, 2026
Merged via the queue into main with commit 06678e3 Jun 25, 2026
79 of 81 checks passed
@elizabethhealy
elizabethhealy deleted the dspx-1311-add-more-authorization-bdd-tests branch June 25, 2026 22:54
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