chore(ers): add BDD cukes for multi-strategy ERS (Claims + LDAP)#3767
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
📝 WalkthroughWalkthroughThe BDD suite provisions reusable OpenLDAP data, injects LDAP-backed inline ERS configuration into local platform startup, registers LDAP and ERS steps, and validates multi-strategy authorization with three end-to-end scenarios. ChangesLDAP-backed ERS BDD coverage
Estimated code review effort: 3 (Moderate) | ~25 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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/cukes/steps_ldap.go`:
- Around line 65-92: Update the LDAP setup flow around GenericContainer, Host,
and MappedPort so every error path terminates the already-started ldapContainer
before returning. Register cleanup immediately after successful container
creation, or explicitly invoke the same termination logic for subsequent setup
failures, while preserving the existing shutdown hook for successful setup.
🪄 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: 75c9a4d7-5468-49aa-9542-2cc355939246
📒 Files selected for processing (6)
tests-bdd/cukes/glue_platform.gotests-bdd/cukes/resources/platform.multi_strategy_ers.templatetests-bdd/cukes/steps_ldap.gotests-bdd/cukes/steps_localplatform.gotests-bdd/features/multi-strategy-ers.featuretests-bdd/platform_test.go
440837b to
39ee26b
Compare
There was a problem hiding this comment.
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/README.md`:
- Around line 323-365: Add the text language identifier to the architecture
diagram fence in the README, and insert blank lines before each listed command
fence under the prerequisites and workflow sections. Update only the Markdown
formatting around the diagram and command examples so markdownlint passes.
🪄 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: 20de5dbf-d858-457d-a7db-bd2e7cda862f
📒 Files selected for processing (7)
tests-bdd/README.mdtests-bdd/cukes/glue_platform.gotests-bdd/cukes/resources/platform.multi_strategy_ers.templatetests-bdd/cukes/steps_ldap.gotests-bdd/cukes/steps_localplatform.gotests-bdd/features/multi-strategy-ers.featuretests-bdd/platform_test.go
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tests-bdd/cukes/steps_localplatform.go (1)
537-541: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winUse the dev-mode LDAP host for ERS in DEBUG mode.
pgHostswitches tooptions.Hostnameonly when!devMode, butbuildEntityResolutionConfigalways receivesoptions.Hostname, so in-processPLATFORM_IMAGE=DEBUGruns point LDAP-backed ERS at the remote platform host instead oflocalhost:<mapped LDAP port>. Apply the same local-dev flag aspgHostand pass that LDAP host into ERS config.🤖 Prompt for 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. In `@tests-bdd/cukes/steps_localplatform.go` around lines 537 - 541, Update the ERS configuration call through buildEntityResolutionConfig to use the same devMode-dependent local host selection as pgHost: use localhost in DEBUG/dev mode and options.Hostname otherwise, ensuring in-process LDAP-backed ERS connects to the mapped local LDAP endpoint.
🤖 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/cukes/steps_ers.go`:
- Around line 111-153: Add a direct unit test in steps_ers_test.go for
buildEntityResolutionConfig, covering provider connection construction and
mapping-strategy YAML parsing/merging. Include malformed YAML to verify the
returned error and a key-collision case to validate the intended merge behavior,
keeping the test focused on this helper rather than the full BDD stack.
In `@tests-bdd/cukes/steps_localplatform.go`:
- Line 587: Update the os.WriteFile call in the rendered opentdf.yaml setup to
use restrictive 0o600 permissions when ersConfig.AutoWireLDAP embeds the LDAP
bind password, while preserving the existing permissions for configurations
without secrets.
---
Outside diff comments:
In `@tests-bdd/cukes/steps_localplatform.go`:
- Around line 537-541: Update the ERS configuration call through
buildEntityResolutionConfig to use the same devMode-dependent local host
selection as pgHost: use localhost in DEBUG/dev mode and options.Hostname
otherwise, ensuring in-process LDAP-backed ERS connects to the mapped local LDAP
endpoint.
🪄 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: 69c2457f-b10f-4428-9bc6-69068ba8bf90
📒 Files selected for processing (5)
tests-bdd/README.mdtests-bdd/cukes/steps_ers.gotests-bdd/cukes/steps_localplatform.gotests-bdd/features/multi-strategy-ers.featuretests-bdd/platform_test.go
Invalidated by push of 7148586
Add end-to-end BDD tests that validate multi-strategy entity resolution through the full gRPC stack (SDK → Connect RPC → platform → ERS → LDAP), catching serialization bugs at the gRPC/structpb boundary that direct-call integration tests miss. - 3 scenarios: PERMIT for matching department, DENY for non-matching, PERMIT for different department value - LDAP testcontainer step using osixia/openldap with existing LDIF fixtures - Multi-strategy platform template with Claims + LDAP providers - LDAPPort propagation in @stateless scenario context DSPX-4100 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Ken Ho <kho@virtru.com>
Add getting started guide, architecture diagram, key files reference, and implementation notes for the multi-strategy ERS BDD tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Ken Ho <kho@virtru.com>
Ensure the LDAP testcontainer is terminated if Host() or MappedPort() fail after the container has started, preventing leaked containers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Ken Ho <kho@virtru.com>
Extract magic numbers to constants and use errors.New for static error strings to satisfy mnd and perfsprint linters. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Ken Ho <kho@virtru.com>
Add language tag to architecture diagram fence and blank lines before code blocks to satisfy markdownlint. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Ken Ho <kho@virtru.com>
Replace the external platform.multi_strategy_ers.template with inline ERS configuration step definitions using Gherkin DocStrings. Mapping strategies, providers, and conditions are now visible directly in the feature file, making tests self-documenting per review feedback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Ken Ho <kho@virtru.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Ken Ho <kho@virtru.com>
7148586 to
68e2413
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
tests-bdd/cukes/steps_localplatform.go (1)
587-587: 🔒 Security & Privacy | 🟡 Minor | ⚡ Quick winFile containing plaintext LDAP bind password is written world-readable.
os.WriteFile(tempFileName, renderedBytes, os.FileMode(0o755))still uses0o755even though, whenersConfig.AutoWireLDAPis set,renderedBytesnow embeds the plaintext LDAP bind password (admin123). This was flagged in a prior review and remains unaddressed.🔒 Proposed fix
- err := os.WriteFile(tempFileName, renderedBytes, os.FileMode(0o755)) //nolint:mnd // mkdir dir + err := os.WriteFile(tempFileName, renderedBytes, os.FileMode(0o600)) //nolint:mnd // mkdir dir🤖 Prompt for 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. In `@tests-bdd/cukes/steps_localplatform.go` at line 587, Update the os.WriteFile call in the temporary-file setup to use restrictive permissions when renderedBytes may contain the plaintext LDAP bind password, especially when ersConfig.AutoWireLDAP is enabled; do not leave the file world-readable or executable, while preserving the existing file-writing behavior.
🤖 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/cukes/steps_localplatform.go`:
- Around line 561-585: Update the buildEntityResolutionConfig call in the
ersConfig patching block to pass the already computed devMode-aware pgHost
instead of options.Hostname, preserving localhost for devMode and the
compose-reachable hostname otherwise.
---
Duplicate comments:
In `@tests-bdd/cukes/steps_localplatform.go`:
- Line 587: Update the os.WriteFile call in the temporary-file setup to use
restrictive permissions when renderedBytes may contain the plaintext LDAP bind
password, especially when ersConfig.AutoWireLDAP is enabled; do not leave the
file world-readable or executable, while preserving the existing file-writing
behavior.
🪄 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: dab3c35a-4c4e-47df-a0bd-e764aecba86e
📒 Files selected for processing (7)
tests-bdd/README.mdtests-bdd/cukes/glue_platform.gotests-bdd/cukes/steps_ers.gotests-bdd/cukes/steps_ldap.gotests-bdd/cukes/steps_localplatform.gotests-bdd/features/multi-strategy-ers.featuretests-bdd/platform_test.go
Summary
[]stringnormalization) fixes the same class of structpb bug for multi-valued claim/metadata fields — not exercised by current test data but would be needed for LDAP attributes returning multiple values.osixia/openldap:1.5.0with existing LDIF fixtures fromservice/entityresolution/integration/ldap_test_data/What's new
Files created
tests-bdd/cukes/steps_ldap.go— LDAP testcontainer step definition (Given an LDAP directory with test users), idempotent for@statelessreusetests-bdd/cukes/steps_ers.go— Inline ERS configuration step definitions using DocString YAML:an ERS configuration with mode "X" and failure strategy "Y"— creates configan ERS provider "name" of type "type"— plain provider (e.g. claims)an ERS provider "name" of type "type" connected to the LDAP directory— auto-wires LDAP host/portan ERS mapping strategy "name" using provider "provider"+ DocString — mapping strategy with inline YAML configa local platform with inline ERS configuration— assembles config, patches base template, starts platformtests-bdd/features/multi-strategy-ers.feature— 3 scenarios tagged@multi-strategy-ers @statelessFiles modified
tests-bdd/cukes/glue_platform.go—LDAPPortfield onLocalDevScenarioOptions+ propagate in@statelessscenario copiestests-bdd/cukes/steps_localplatform.go—ldapPorttemplate variable +ersConfigYAML-patching support increatePlatformConfigurationtests-bdd/platform_test.go— Register LDAP and ERS step definitionsScenarios
How to run
Test plan
go vet --tags=cukes ./tests-bdd/...passesDSPX-4100
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests
Documentation