Commit c59e749
Add unit tests for clientpool auth code paths (#236)
## 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 #227
and #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
#212 bug (fixed in #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
#203 bug (fixed in #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 #227 fix →
`TestFetchMTLS_CACertAppendsToSystemPool` fails
- [x] Manually revert the PR #232 fix →
`TestDialAndUpsert_APIKeySkipsCheckHealth` fails
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 62dbdb8 commit c59e749
2 files changed
Lines changed: 378 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
61 | 70 | | |
62 | 71 | | |
63 | 72 | | |
64 | 73 | | |
65 | | - | |
66 | | - | |
67 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
68 | 79 | | |
69 | 80 | | |
70 | 81 | | |
| |||
141 | 152 | | |
142 | 153 | | |
143 | 154 | | |
144 | | - | |
| 155 | + | |
145 | 156 | | |
146 | 157 | | |
147 | 158 | | |
| |||
260 | 271 | | |
261 | 272 | | |
262 | 273 | | |
263 | | - | |
| 274 | + | |
264 | 275 | | |
265 | 276 | | |
266 | 277 | | |
| |||
0 commit comments