[quality] test: pin storeLiteLLMAPIKey PVC-failure fallback semantics (src/pkg/dashboard/litellm_key_store.go) - #6359
Conversation
… (src/pkg/dashboard/litellm_key_store.go) Pins the previously-untested failure branches of storeLiteLLMAPIKey: - PVC write fails, hive-secrets Secret patch succeeds -> api_key_file records config.DefaultLiteLLMAPIKeyFile (Secret mount), save succeeds - PVC write fails, not in cluster -> save fails with the PVC error - both stores fail -> PVC (primary) error surfaces - patchKeyIntoHiveSecrets rejection is status-only and never echoes the key value; the PATCH carries the base64 key, SA token, and targets /api/v1/namespaces/<ns>/secrets/hive-secrets Uses a fake in-cluster API (httptest TLS server + temp serviceaccount dir) so the tests are hermetic. Signed-off-by: hive-quality <sec-check@hive.kubestellar.io>
|
Changelog: this PR changes code but carries no changelog entry If it is user-visible — a feature, a fix an operator would notice, a This is a reminder, not a gate; it never blocks a merge. |
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: clubanderson The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
Test Improvement
Adds
src/pkg/dashboard/litellm_key_store_fallback_test.go, pinning the previously-untested failure branches ofstoreLiteLLMAPIKey/patchKeyIntoHiveSecrets(existing coverage only exercises the PVC-write happy path and not-in-cluster short-circuits):api_key_filerecords the Secret mount path (config.DefaultLiteLLMAPIKeyFile), not the PVC path. Also pins the wire contract: PATCH to/api/v1/namespaces/<ns>/secrets/hive-secretswith the SA bearer token and base64 key.Tests are hermetic: fake in-cluster API via
httptest.NewTLSServer+ temp serviceaccount dir (token/namespace/ca.crt), PVC failure induced by a not-a-directory parent so it works at any uid.Claimed ground
Files:
src/pkg/dashboard/litellm_key_store.go(test-only PR; addssrc/pkg/dashboard/litellm_key_store_fallback_test.go). Functions:storeLiteLLMAPIKey,patchKeyIntoHiveSecrets. Disjoint from open PRs #6348/#6343/#6292 (other dashboard files) and #6355 (pkg/hub).Validation
go test -run 'TestStoreLiteLLMAPIKey|TestPatchKeyIntoHiveSecrets' ./pkg/dashboard/— 4/4 pass.Filed by quality agent (hold-gated mode). Human review required. Do not merge without removing hold (humans only).
— hive: agent=quality backend=copilot model=claude-fable-5