Conversation
Introduces clientpool_test.go with 8 tests that directly cover the two regression patterns that slipped through CI: - TestFetchMTLS_CACertAppendsToSystemPool: regression test for PR #227 (empty cert pool replacing system CAs). Injects a fake system pool and verifies both injected system CAs and the custom ca.crt are trusted. - TestDialAndUpsert_APIKeySkipsCheckHealth: regression test for PR #232 (CheckHealth called unconditionally). Verifies CheckHealth is not invoked when AuthModeAPIKey is used. To make both code paths injectable in tests, ClientPool gains two new function fields (dialFn, systemCertPoolFn) wired to sdkclient.Dial and x509.SystemCertPool by default — no behavior change in production. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
shashwatsuri
pushed a commit
to shashwatsuri/temporal-worker-controller
that referenced
this pull request
Apr 28, 2026
## Summary - Adds `clientpool_test.go` with 8 unit tests covering the auth code paths that had no test coverage - Two tests are explicit regression guards for the bugs fixed in temporalio#227 and temporalio#232 - Makes `dialFn` and `systemCertPoolFn` injectable on `ClientPool` (no behavior change in production) to enable testing without network I/O or OS trust store dependencies ## Regression tests **`TestFetchMTLS_CACertAppendsToSystemPool`** — guards against the PR temporalio#212 bug (fixed in temporalio#227): `fetchClientUsingMTLSSecret` used `x509.NewCertPool()` (empty) instead of `x509.SystemCertPool()`, silently dropping system root CAs and breaking Temporal Cloud connections. The test injects a fake system pool and verifies both the injected system CAs and the custom `ca.crt` are present in the returned pool. This test fails if the fix is reverted. **`TestDialAndUpsert_APIKeySkipsCheckHealth`** — guards against the PR temporalio#203 bug (fixed in temporalio#232): `DialAndUpsertClient` called `CheckHealth` unconditionally, which fails on Temporal Cloud with namespace-scoped API keys. The test uses an injected mock client and asserts `CheckHealth` is never called for `AuthModeAPIKey`. This test fails if the fix is reverted. ## Test plan - [x] `go test ./internal/controller/clientpool/... -v` — all 8 tests pass - [x] `go build ./...` — no compilation errors - [x] Manually revert the PR temporalio#227 fix → `TestFetchMTLS_CACertAppendsToSystemPool` fails - [x] Manually revert the PR temporalio#232 fix → `TestDialAndUpsert_APIKeySkipsCheckHealth` fails 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
clientpool_test.gowith 8 unit tests covering the auth code paths that had no test coveragedialFnandsystemCertPoolFninjectable onClientPool(no behavior change in production) to enable testing without network I/O or OS trust store dependenciesRegression tests
TestFetchMTLS_CACertAppendsToSystemPool— guards against the PR #212 bug (fixed in #227):fetchClientUsingMTLSSecretusedx509.NewCertPool()(empty) instead ofx509.SystemCertPool(), silently dropping system root CAs and breaking Temporal Cloud connections. The test injects a fake system pool and verifies both the injected system CAs and the customca.crtare present in the returned pool. This test fails if the fix is reverted.TestDialAndUpsert_APIKeySkipsCheckHealth— guards against the PR #203 bug (fixed in #232):DialAndUpsertClientcalledCheckHealthunconditionally, which fails on Temporal Cloud with namespace-scoped API keys. The test uses an injected mock client and assertsCheckHealthis never called forAuthModeAPIKey. This test fails if the fix is reverted.Test plan
go test ./internal/controller/clientpool/... -v— all 8 tests passgo build ./...— no compilation errorsTestFetchMTLS_CACertAppendsToSystemPoolfailsTestDialAndUpsert_APIKeySkipsCheckHealthfails🤖 Generated with Claude Code