fix(services): test connection merges stored secrets for blank fields

The credential tester (POST /api/services/test) used only body.secrets — the
values typed in the form. When editing an existing service the secret fields
are masked and intentionally left blank ("leave blank to keep current"), so the
test ran with empty credentials and failed auth even though the stored secret
was valid.

When body.id is set, look up the stored service, decrypt its secrets, and fall
back to the stored value for any known secret key that is absent or blank in
the input. The test still uses the freshly-typed config (so you can test an
edited URL) but authenticates with the effective credentials. New-service tests
(no id) are unchanged.

Test: editing a service and testing with empty secrets now authenticates with
the stored secret (asserts the stored key reaches the upstream request).
402/402 backend pass; ruff clean.
This commit is contained in:
Developer
2026-07-12 15:55:10 +00:00
parent 0b039529f6
commit e757f4ba21
4 changed files with 59 additions and 6 deletions
@@ -2,7 +2,7 @@
dir: backend/src/media_library_viewer_api/routers
## role
FastAPI router package that organizes and exposes all REST API endpoints for the media library viewer backend, covering authentication, dashboards, media management, backups, monitoring, services, files, and task execution.
FastAPI router package that defines all REST API endpoint modules for the media library viewer backend.
## parent
index: backend/src/media_library_viewer_api/.pi-map.index.md
map: backend/src/media_library_viewer_api/.pi-map.md