fix(kas): remove testcontainers from consumer dependency graph - #3132
fix(kas): remove testcontainers from consumer dependency graph#3132pflynn-virtru wants to merge 12 commits into
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors the service layer by relocating two internal Go packages, Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Paths now redefined, Tests can run in isolation, Code finds new freedom. Footnotes
|
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
There was a problem hiding this comment.
Code Review
This pull request refactors the project structure by moving two internal packages, fixtures and subjectmappingbuiltin, to public paths under service/pkg/. The goal is to allow downstream consumers to import these packages for test isolation. The changes involve moving files and updating import paths in numerous files, along with adjusting YAML fixture load paths. The changes are consistent with the stated goal of refactoring for test isolation. The new package locations are service/pkg/testutil/fixtures/ and service/pkg/subjectmappingbuiltin/. The import and file path updates across the codebase appear to be correct based on this refactoring. No behavioral changes were introduced.
Note: Security Review did not run due to the size of the PR.
8d3ab27 to
e3a7d00
Compare
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
## Summary - Moved keycloak integration tests from `sdk/auth/oauth/oauth_test.go` to a new `test/integration/` module with its own `go.mod` - Removed `testcontainers-go` and 60+ transitive container dependencies (docker, containerd, moby, etc.) from `sdk/go.mod` - Downstream SDK consumers no longer inherit test-only dependencies that trigger false CVE alerts in vulnerability scanners ## Details The `sdk/go.mod` previously listed `testcontainers-go` as a direct dependency because `oauth_test.go` imported it for keycloak integration tests. Even though it was only used in test files, Go modules include all dependencies (test and non-test) in `go.mod`. Any downstream consumer running `go get github.com/opentdf/platform/sdk` would inherit these deps. **This PR (SDK only):** Unit test (`TestTokenExpiration_RespectsLeeway`) stays in the SDK; keycloak integration suite moves to `test/integration/oauth/`. **Service module:** Still has testcontainers in `service/go.mod` from `service/integration/` and `service/entityresolution/integration/` tests. This is being addressed in #3132 (export internal packages) and a follow-up PR to move service integration tests to their own module. Part of [DSPX-2582](https://virtru.atlassian.net/browse/DSPX-2582) ## Test plan - [x] SDK unit tests pass (`go test ./...` in `sdk/`) - [x] `testcontainers-go` no longer in `sdk/go.mod` - [x] No docker/containerd/moby deps in `sdk/go.mod` - [x] Integration tests compile in `test/integration/` module - [ ] CI checks pass - [ ] Verify with `go mod why -m github.com/testcontainers/testcontainers-go` from a downstream consumer after release 🤖 Generated with [Claude Code](https://claude.com/claude-code) [DSPX-2582]: https://virtru.atlassian.net/browse/DSPX-2582?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --------- Signed-off-by: Paul Flynn <pflynn@virtru.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
e3a7d00 to
54a2f04
Compare
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
44ed71c to
63cd3e7
Compare
|
CI coverage seems reduced after the move. In this workflow, only That means Could we add dedicated checks (or matrix entries) for:
|
|
/gemini review |
…tion Move fixtures and subjectmappingbuiltin out of service/internal/ so they can be imported from a separate integration-test module (DSPX-2582). This eliminates the testcontainers-go transitive dependency leak into downstream consumers by enabling integration tests to live in their own Go module. - service/internal/fixtures/ → service/pkg/testutil/fixtures/ - service/internal/subjectmappingbuiltin/ → service/pkg/subjectmappingbuiltin/ - Update all import paths and YAML load paths Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Paul Flynn <pflynn@virtru.com>
Move service/integration/ and service/entityresolution/integration/ into test/integration/ so that testcontainers-go and its 60+ transitive dependencies no longer leak into service/go.mod. Downstream consumers that depend on the service module will no longer pull in Docker, OCI, and container runtime libraries. - service/integration/ → test/integration/policy/ - service/entityresolution/integration/ → test/integration/entityresolution/ - Update test/integration/go.mod with service replace directive - Update CI workflow to run policy integration tests from new path - Verify: grep testcontainers service/go.mod → empty Part of DSPX-2582 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Paul Flynn <pflynn@virtru.com>
Fixtures are test-only code and should not be part of the service's public API surface. Move them to a dedicated test/fixtures module with its own go.mod, importable by test/integration via replace directive. - service/pkg/testutil/fixtures/ → test/fixtures/ (own go.mod) - Extract provisionCmd to service/cmd/provision.go (provisionKeycloak needs it) - Delete service/cmd/provisionFixtures.go from service binary - Create test/integration/cmd/provision-fixtures/ as standalone tool - Update all 15 integration test imports and YAML load path Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Paul Flynn <pflynn@virtru.com>
The keycloak provisioner is test infrastructure, not a platform requirement. Move it out of the service binary into a standalone tool alongside provision-fixtures. Update CI workflows, composite action, and documentation to use the new invocation pattern. - service/cmd/provisionKeycloak.go → test/integration/cmd/provision-keycloak/ - Delete service/cmd/provision.go (no longer needed) - CI uses: GOWORK=off go run -C test/integration ./cmd/provision-keycloak - Update docs: Contributing.md, Consuming.md, service/README.md Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Paul Flynn <pflynn@virtru.com>
Move subjectmappingbuiltin from service/pkg/ back to service/internal/ now that no cross-module imports remain. The claims_attributes_test.go unit test (selector evaluation logic) moves into the package itself. The keycloak_attributes_test.go integration test is refactored to assert on flattened entity keys instead of calling EvaluateSubjectMappings directly. - service/pkg/subjectmappingbuiltin/ → service/internal/subjectmappingbuiltin/ - claims_attributes_test.go → service/internal/subjectmappingbuiltin/ - keycloak_attributes_test.go refactored to remove subjectmappingbuiltin import - Update all 8 import paths within service/ Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Paul Flynn <pflynn@virtru.com>
This file was unintentionally staged in a prior commit on this branch. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Paul Flynn <pflynn@virtru.com>
- Merge test/integration/go.mod and test/fixtures/go.mod into test/go.mod - Create test/main.go CLI: `go run . provision keycloak|fixtures` - Add `make provision-keycloak` and `make provision-fixtures` Makefile targets - Move keycloak_data.yaml from service/cmd/ to test/fixtures/ - Update CI workflows, docs, and action.yaml to use new paths - Docs now lead with `make` targets for better developer experience Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Paul Flynn <pflynn@virtru.com>
842f6bc to
7eb3efd
Compare
There was a problem hiding this comment.
Code Review
This pull request effectively refactors the project to separate integration test dependencies from the main service module. By moving test-related code, including fixtures and integration tests, into a new test Go module, you've successfully removed testcontainers-go and its large number of transitive dependencies from the service's dependency graph. The changes to the Makefile, documentation, and CI workflows are consistent with this refactoring. The overall change significantly improves the dependency hygiene for downstream consumers of the service module. I have one suggestion to improve the error handling in the new provisioning CLI tool.
X-Test Failure Report✅ go-v0.9.0 |
The BDD tests imported cmd.LoadKeycloakData from service/cmd which was removed when provision tools moved to test/. Inline the function directly in steps_localplatform.go since it's a small utility. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Paul Flynn <pflynn@virtru.com>
X-Test Failure Report✅ go-v0.9.0 |
- provision fixtures needs -config-file ../opentdf.yaml since -C test changes CWD away from repo root where opentdf.yaml lives - integration policy tests need ./integration/policy/... path prefix and GOWORK=off since working-directory changed from test/integration to test Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Paul Flynn <pflynn@virtru.com>
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
X-Test Failure Report✅ go-v0.9.0 |
The start-up-with-containers action is referenced at @main by external consumers. Add fallback to legacy `go run ./service provision` so the action works with both old and new platform layouts during transition. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Paul Flynn <pflynn@virtru.com>
…ternal-packages # Conflicts: # service/go.mod
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
X-Test Failure Report✅ go-v0.9.0 |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Paul Flynn <pflynn@virtru.com>
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
X-Test Failure Report✅ go-v0.9.0 |
Summary
Remove
testcontainers-goand its 60+ transitive dependencies fromservice/go.modso downstream consumers no longer pull in Docker, OCI, and container runtime libraries.Two commits:
service/internal/fixtures/andservice/internal/subjectmappingbuiltin/toservice/pkg/so they can be imported from outside the service moduleservice/integration/andservice/entityresolution/integration/intotest/integration/(separate Go module), which is the actual home for testcontainers usagePart of DSPX-2582
Changes
service/internal/fixtures/→service/pkg/testutil/fixtures/service/internal/subjectmappingbuiltin/→service/pkg/subjectmappingbuiltin/service/integration/→test/integration/policy/service/entityresolution/integration/→test/integration/entityresolution/test/integration/go.modwith service replace directive and new depsVerification
grep testcontainers service/go.mod→ empty (the goal)cd service && go build ./...— passescd service && golangci-lint run ./...— 0 issuescd test/integration && go build ./...— passescd test/integration && golangci-lint run ./...— 0 issuesTest plan
go build ./...passes in both service and test/integrationgo test ./... -shortpasses in servicego test ./policy/... -shortpasses in test/integrationgolangci-lintandgofumptclean on all changed files🤖 Generated with Claude Code