Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

fix(settings): restore Ollama Basic Auth configuration

pulse-triage[bot]e8449477ff10
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 5f478d1831..36c00db010 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -25,6 +25,14 @@ that same result. Successful reads retain their content and execution provenance
## Purpose
+### Ollama Basic Auth continuity
+Patrol's runtime provider factory must carry the persisted Ollama username and
+password into streaming requests without trimming password bytes.
+`TestPatrolProviderUsesPersistedOllamaCredentials` verifies the persisted-config
+to runtime-factory to HTTP Basic Auth path with a synthetic server. This is not
+model capability or installed Patrol acceptance.
+
+
### Incident lifecycle occurrence identity (7 September 2026)
Fired, resolved and acknowledgement snapshots with a nonzero start time select
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index f1de125d8d..3997df8562 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -20,6 +20,15 @@
## Purpose
+### Ollama credential lifecycle
+Settings return only `ollama_username` and `ollama_password_set`, never the
+password. An omitted password preserves it, a supplied password replaces it
+verbatim, and `clear_ollama_password: true` removes it. An empty username clears
+the username independently. `TestAISettingsOllamaPasswordLifecycle` proves these
+existing wire semantics against persistence; the connection and provider tests
+verify authenticated requests to synthetic Ollama endpoints.
+
+
### Node import preview response ownership
The node credential editor calls the existing monitored-system-ledger preview
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 31dba43d96..3f2e74a231 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -20,6 +20,16 @@
## Purpose
+### Ollama credential editing
+The provider panel exposes the existing Basic Auth configuration. Saved passwords
+are represented by presence text, never a placeholder secret or input value.
+Blank password input preserves the saved value; explicit clearing takes precedence
+over a draft replacement. Successful saves discard the password draft. Username
+clearing is independent. Password bytes are not trimmed. Tests exercise preservation,
+replacement and clearing through the Settings save action. Connection testing uses
+saved settings; the panel tells users to save before testing and use HTTPS remotely.
+
+
Assistant owns composer registration and focus on every open, rather than only
on component mount. Closing clears the registered input so later keyboard
commands cannot target a detached composer. A handoff must leave Escape and
diff --git a/frontend-modern/browser-verification.json b/frontend-modern/browser-verification.json
index cdf6cc0b67..7acab11dcc 100644
--- a/frontend-modern/browser-verification.json
+++ b/frontend-modern/browser-verification.json
@@ -1,20 +1,22 @@
{
"version": 1,
- "base_sha": "837a5b8843fa4a4ca293f66f43123b9f9c127d4d",
- "verified_at": "2026-09-10T14:54:37.800409Z",
+ "base_sha": "7294e60afdbf473830ea3270c29b5c8961edbba7",
+ "verified_at": "2026-09-10T17:21:10.327527Z",
"result": "passed",
"changed_paths": [
- "internal/monitoring/monitored_system_usage.go",
- "internal/unifiedresources/monitor_adapter.go",
- "internal/unifiedresources/registry.go"
+ "frontend-modern/src/components/Settings/AIProviderConfigurationSection.tsx",
+ "frontend-modern/src/components/Settings/aiSettingsModel.ts",
+ "frontend-modern/src/components/Settings/useAISettingsState.ts",
+ "frontend-modern/src/types/ai.ts"
],
"content_sha256": {
- "internal/monitoring/monitored_system_usage.go": "125f39dbfc448a37d0ee74756a03534d435abdacb4e0c7fed8c0710364af5f4a",
- "internal/unifiedresources/monitor_adapter.go": "7720ba164373cdf6a8a9f950215f27e0e5a24e48edc2f9c1e444b4144e35b3d6",
- "internal/unifiedresources/registry.go": "b49125258595bfdabb2a0a06dc51e51e7e27f998c8d9cb8e8ad69cffc1e4272c"
+ "frontend-modern/src/components/Settings/AIProviderConfigurationSection.tsx": "76f3ed93e95cbe9f24f5cd55d49aeae7397f739e6520665f1b8de074ccaeaa96",
+ "frontend-modern/src/components/Settings/aiSettingsModel.ts": "9dee0d8b8bd013e870732c3893fa4742e40914ec4931a044b1698bc90f598c22",
+ "frontend-modern/src/components/Settings/useAISettingsState.ts": "d4bdd6ce19279e5e243b69e9ca769436c3d88a50f243bd8241c7aeffafeb2613",
+ "frontend-modern/src/types/ai.ts": "bdad2e3926976f761b2a75db03ed4473f67e73cdc60e6327f15acc6626225507"
},
"routes": [
- "/proxmox"
+ "/ (isolated AISettings component harness)"
],
"viewports": [
{
@@ -27,17 +29,21 @@
}
],
"states": [
- "6.4.1 reproduction shows Offline and unavailable CPU despite live host report",
- "Repaired backend output shows current agent and 17 percent CPU",
- "Explicit offline control remains offline with unavailable live metrics",
- "Expanded node Overview displays current agent identity"
+ "Saved password presence with blank masked input",
+ "Unrelated save preserves credentials",
+ "Replacement preserves password whitespace and discards draft after save",
+ "Explicit password and username clearing",
+ "Reload retains cleared state"
],
"interactions": [
- "Two reloads preserve current identity, metrics and node count",
- "Hover node row and expand inline details",
- "Hover and focus collapse button, Escape preserves inline disclosure, Enter collapses it",
- "Inspect actual pixels for node status, CPU, identity and narrow layout"
+ "Expand Ollama accordion",
+ "Focus password and Tab",
+ "Save unrelated option",
+ "Replace credentials and save",
+ "Clear saved credentials and save",
+ "Reload and inspect no horizontal overflow",
+ "Inspect desktop and narrow screenshots"
],
- "command": "node .agent-coordination/issue-1913-upgrade/browser-check.cjs (workspace root)",
- "notes": "Current local frontend with a synthetic canonical resource emitted by the exact Go reproduction, added to the existing local API inventory. Browser isolated from inventory websocket updates. Compared original 6.4.1 backend output with repaired source. No production mutations or reporter environment access. Initial full-inventory replacement fixture caused reactive-cache errors and was excluded from proof. Final fixture preserves the existing inventory and source-query contract. Screenshots and backend receipts retained in the local issue investigation directory."
+ "command": "pulse-heavy-run -- node .ai-coordination/ollama/browser.cjs",
+ "notes": "Production-built current AISettings component and real API client against synthetic HTTP responses, not a running Pulse backend or customer server. Normal frontend CSS and esnext build target. Go race tests separately prove persistence, Basic Auth connection endpoints and Patrol runtime streaming factory. Private evidence retains harness and screenshots; initial build target and ambiguous-locator failures are retained, not counted as passes."
}
diff --git a/frontend-modern/src/components/Settings/AIProviderConfigurationSection.tsx b/frontend-modern/src/components/Settings/AIProviderConfigurationSection.tsx
index 2a800d3f91..c995d7802c 100644
--- a/frontend-modern/src/components/Settings/AIProviderConfigurationSection.tsx
+++ b/frontend-modern/src/components/Settings/AIProviderConfigurationSection.tsx
@@ -261,7 +261,7 @@ export const AIProviderConfigurationSection: Component<AIProviderConfigurationSe
}
placeholder={extraField.placeholder}
aria-label={`${getAIProviderDisplayName(config.provider)} ${extraField.label}`}
- autocomplete="off"
+ autocomplete={extraField.type === 'password' ? 'new-password' : 'off'}
class={controlClass()}
disabled={props.saving()}
/>
@@ -272,6 +272,24 @@ export const AIProviderConfigurationSection: Component<AIProviderConfigurationSe
)}
</For>
+ <Show when={config.provider === 'ollama'}>
+ <p class="text-xs text-muted">
+ {props.settings()?.ollama_password_set
+ ? 'Ollama password is saved.'
+ : 'No Ollama password saved.'}
+ </p>
+ <label class="flex items-center gap-2 text-sm">
+ <input
+ type="checkbox"
+ checked={props.form.clearOllamaPassword}
+ onChange={(event) =>
+ props.setForm('clearOllamaPassword', event.currentTarget.checked)
+ }
+ disabled={props.saving()}
+ />
+ Clear saved Ollama password
+ </label>
+ </Show>
<Show when={config.provider === 'ollama' && suggestedModel()}>
<div class="space-y-1">
<p class="text-xs text-muted">
diff --git a/frontend-modern/src/components/Settings/__tests__/AISettings.test.tsx b/frontend-modern/src/components/Settings/__tests__/AISettings.test.tsx
index ed3f85bef9..ad4fe57fd9 100644
--- a/frontend-modern/src/components/Settings/__tests__/AISettings.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/AISettings.test.tsx
@@ -934,6 +934,54 @@ describe('AISettings Ollama provider options', () => {
cleanup();
});
+ it('keeps saved passwords write-only and supports replacement and explicit clearing', async () => {
+ const saved = {
+ ...baseSettings(),
+ configured: true,
+ model: 'ollama:llama3',
+ ollama_configured: true,
+ configured_providers: ['ollama'],
+ ollama_username: 'monitor',
+ ollama_password_set: true,
+ };
+ getSettingsMock.mockResolvedValue(saved);
+ updateSettingsMock.mockResolvedValue(saved);
+ renderComponent();
+ fireEvent.click(await screen.findByRole('button', { name: /ollama/i }));
+ const password = (await screen.findByLabelText('Ollama Password')) as HTMLInputElement;
+ expect(password.type).toBe('password');
+ expect(password.value).toBe('');
+ expect(screen.getByText('Ollama password is saved.')).toBeInTheDocument();
+ fireEvent.input(screen.getByLabelText('Ollama Keep Alive'), { target: { value: '24h' } });
+ fireEvent.click(screen.getByRole('button', { name: /Save provider settings/i }));
+ await waitFor(() => expect(updateSettingsMock).toHaveBeenCalledTimes(1));
+ expect(updateSettingsMock.mock.calls[0][0]).not.toHaveProperty('ollama_password');
+
+ fireEvent.input(password, { target: { value: ' replacement with spaces ' } });
+ fireEvent.input(screen.getByLabelText('Ollama Username'), { target: { value: 'new-monitor' } });
+ fireEvent.click(screen.getByRole('button', { name: /Save provider settings/i }));
+ await waitFor(() => expect(updateSettingsMock).toHaveBeenCalledTimes(2));
+ expect(updateSettingsMock.mock.calls[1][0]).toEqual(
+ expect.objectContaining({
+ ollama_username: 'new-monitor',
+ ollama_password: ' replacement with spaces ',
+ }),
+ );
+ await waitFor(() => expect(password.value).toBe(''));
+
+ fireEvent.input(screen.getByLabelText('Ollama Username'), { target: { value: '' } });
+ fireEvent.click(screen.getByLabelText('Clear saved Ollama password'));
+ fireEvent.click(screen.getByRole('button', { name: /Save provider settings/i }));
+ await waitFor(() => expect(updateSettingsMock).toHaveBeenCalledTimes(3));
+ expect(updateSettingsMock.mock.calls[2][0]).toEqual(
+ expect.objectContaining({
+ ollama_username: '',
+ clear_ollama_password: true,
+ }),
+ );
+ expect(updateSettingsMock.mock.calls[2][0]).not.toHaveProperty('ollama_password');
+ });
+
it('saves Ollama keep alive through the provider settings panel', async () => {
getSettingsMock.mockResolvedValue({
...baseSettings(),
diff --git a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
index 5251f0ac31..82ba4d8a5b 100644
--- a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
@@ -1026,6 +1026,18 @@ describe('settings architecture guardrails', () => {
expect(aiSettingsModelSource).not.toContain('qwen');
});
+ it('keeps Ollama credentials in the provider editor with write-only saved state', () => {
+ expect(aiProviderConfigurationSectionSource).toContain('props.settings()?.ollama_password_set');
+ expect(aiProviderConfigurationSectionSource).toContain('Clear saved Ollama password');
+ expect(aiProviderConfigurationSectionSource).not.toMatch(/props\.settings\(\)\?\.ollama_password\b/);
+ expect(aiSettingsModelSource).toContain("inputField: 'ollamaPassword'");
+ expect(aiSettingsStateSource).toContain("ollamaPassword: ''");
+ expect(aiSettingsStateSource).not.toMatch(/data\.ollama_password\b/);
+ expect(aiSettingsStateSource).toContain('payload.ollama_password = form.ollamaPassword;');
+ expect(aiSettingsStateSource).toContain('payload.clear_ollama_password = true;');
+ expect(aiSettingsStateSource).not.toContain('form.ollamaPassword.trim()');
+ });
+
it('keeps local provider inheritance and removal on explicit lifecycle contracts', () => {
expect(aiSettingsStateSource).toContain("data.ollama_keep_alive ?? ''");
expect(aiSettingsStateSource).toContain('remove_providers: [provider]');
@@ -1420,7 +1432,10 @@ describe('settings architecture guardrails', () => {
"autocomplete={config.inputType === 'password' ? 'new-password' : 'off'}",
);
expect(aiProviderConfigurationSectionSource).toContain(
- 'aria-label={`${getAIProviderDisplayName(config.provider)} ${extraField.label}`}\n autocomplete="off"',
+ 'aria-label={`${getAIProviderDisplayName(config.provider)} ${extraField.label}`}',
+ );
+ expect(aiProviderConfigurationSectionSource).toContain(
+ "autocomplete={extraField.type === 'password' ? 'new-password' : 'off'}",
);
});
diff --git a/frontend-modern/src/components/Settings/aiSettingsModel.ts b/frontend-modern/src/components/Settings/aiSettingsModel.ts
index 08ab5b67f1..c7eb167f7c 100644
--- a/frontend-modern/src/components/Settings/aiSettingsModel.ts
+++ b/frontend-modern/src/components/Settings/aiSettingsModel.ts
@@ -22,6 +22,9 @@ export type AIProviderCredentialsFormState = {
geminiApiKey: string;
ollamaBaseUrl: string;
ollamaKeepAlive: string;
+ ollamaUsername: string;
+ ollamaPassword: string;
+ clearOllamaPassword: boolean;
openaiBaseUrl: string;
zaiBaseUrl: string;
codexSubscriptionEnabled: boolean;
@@ -46,7 +49,7 @@ export type AIProviderConfig = {
helpContentId?: string;
inputField: keyof AIProviderCredentialsFormState;
placeholder: string;
- type?: 'url' | 'text';
+ type?: 'url' | 'text' | 'password';
helperText?: string;
}>;
clearTitle: string;
@@ -299,6 +302,20 @@ export const AI_PROVIDER_CONFIGS: AIProviderConfig[] = [
actionLinkHref: 'https://ollama.ai',
actionLinkSuffix: ' · Free & local',
extraFields: [
+ {
+ label: 'Username',
+ inputField: 'ollamaUsername',
+ placeholder: 'Optional Basic Auth username',
+ type: 'text',
+ },
+ {
+ label: 'Password',
+ inputField: 'ollamaPassword',
+ placeholder: 'Leave blank to keep saved password',
+ type: 'password',
+ helperText:
+ 'Save provider settings before testing. Use HTTPS for remote authenticated servers.',
+ },
{
label: 'Keep Alive',
helpContentId: 'ai.ollama.keepAlive',
diff --git a/frontend-modern/src/components/Settings/useAISettingsState.ts b/frontend-modern/src/components/Settings/useAISettingsState.ts
index 1a2472425f..90e5ab21a8 100644
--- a/frontend-modern/src/components/Settings/useAISettingsState.ts
+++ b/frontend-modern/src/components/Settings/useAISettingsState.ts
@@ -74,7 +74,13 @@ const AI_SETTINGS_PROVIDER_PAYLOAD_FIELDS: Record<AIProvider, string[]> = {
together: ['together_api_key'],
fireworks: ['fireworks_api_key'],
gemini: ['gemini_api_key'],
- ollama: ['ollama_base_url', 'ollama_keep_alive'],
+ ollama: [
+ 'ollama_base_url',
+ 'ollama_keep_alive',
+ 'ollama_username',
+ 'ollama_password',
+ 'clear_ollama_password',
+ ],
'codex-subscription': ['codex_subscription_enabled'],
'claude-subscription': ['claude_subscription_enabled'],
};
@@ -400,6 +406,9 @@ export const useAISettingsState = (options: AISettingsStateOptions = {}) => {
geminiApiKey: '',
ollamaBaseUrl: 'http://localhost:11434',
ollamaKeepAlive: '',
+ ollamaUsername: '',
+ ollamaPassword: '',
+ clearOllamaPassword: false,
openaiBaseUrl: '',
zaiBaseUrl: '',
codexSubscriptionEnabled: false,
@@ -500,6 +509,9 @@ export const useAISettingsState = (options: AISettingsStateOptions = {}) => {
geminiApiKey: '',
ollamaBaseUrl: 'http://localhost:11434',
ollamaKeepAlive: '',
+ ollamaUsername: '',
+ ollamaPassword: '',
+ clearOllamaPassword: false,
openaiBaseUrl: '',
zaiBaseUrl: '',
codexSubscriptionEnabled: false,
@@ -548,6 +560,9 @@ export const useAISettingsState = (options: AISettingsStateOptions = {}) => {
geminiApiKey: '',
ollamaBaseUrl: data.ollama_base_url || 'http://localhost:11434',
ollamaKeepAlive: data.ollama_keep_alive ?? '',
+ ollamaUsername: data.ollama_username ?? '',
+ ollamaPassword: '',
+ clearOllamaPassword: false,
openaiBaseUrl: data.openai_base_url || '',
zaiBaseUrl: data.zai_base_url || '',
codexSubscriptionEnabled: Boolean(data.codex_subscription_enabled),
@@ -1154,6 +1169,14 @@ export const useAISettingsState = (options: AISettingsStateOptions = {}) => {
if (form.ollamaKeepAlive.trim() !== (settings()?.ollama_keep_alive ?? '')) {
payload.ollama_keep_alive = form.ollamaKeepAlive.trim();
}
+ if (form.ollamaUsername.trim() !== (settings()?.ollama_username ?? '')) {
+ payload.ollama_username = form.ollamaUsername.trim();
+ }
+ if (form.clearOllamaPassword) {
+ payload.clear_ollama_password = true;
+ } else if (form.ollamaPassword !== '') {
+ payload.ollama_password = form.ollamaPassword;
+ }
if (form.openaiBaseUrl !== (settings()?.openai_base_url || '')) {
payload.openai_base_url = form.openaiBaseUrl.trim();
}
diff --git a/frontend-modern/src/types/ai.ts b/frontend-modern/src/types/ai.ts
index d512bb578f..a44bd74e78 100644
--- a/frontend-modern/src/types/ai.ts
+++ b/frontend-modern/src/types/ai.ts
@@ -113,6 +113,8 @@ export interface AISettings {
codex_subscription_enabled?: boolean; // local Codex CLI signed in with ChatGPT
claude_subscription_enabled?: boolean; // local Claude CLI signed in with a Claude plan
ollama_configured: boolean; // true (always available for attempt)
+ ollama_username?: string;
+ ollama_password_set?: boolean;
ollama_base_url: string; // Ollama server URL
ollama_keep_alive: string; // Ollama keep_alive value; empty uses the server default
openai_base_url?: string; // Custom OpenAI base URL
@@ -254,6 +256,9 @@ export interface AISettingsUpdateRequest {
cerebras_api_key?: string; // Set Cerebras API key
together_api_key?: string; // Set Together AI API key
fireworks_api_key?: string; // Set Fireworks AI API key
+ ollama_username?: string;
+ ollama_password?: string;
+ clear_ollama_password?: boolean;
ollama_base_url?: string; // Set Ollama server URL
ollama_keep_alive?: string; // Set Ollama keep_alive; empty uses the server default
openai_base_url?: string; // Set custom OpenAI base URL
diff --git a/internal/ai/patrol_ollama_auth_test.go b/internal/ai/patrol_ollama_auth_test.go
new file mode 100644
index 0000000000..0503d90758
--- /dev/null
+++ b/internal/ai/patrol_ollama_auth_test.go
@@ -0,0 +1,54 @@
+package ai
+
+import (
+ "context"
+ "net/http"
+ "net/http/httptest"
+ "sync/atomic"
+ "testing"
+
+ "github.com/rcourtman/pulse-go-rewrite/internal/ai/providers"
+ "github.com/rcourtman/pulse-go-rewrite/internal/config"
+ "github.com/stretchr/testify/require"
+)
+
+// Exercise the runtime Patrol factory, not a directly constructed Ollama client.
+func TestPatrolProviderUsesPersistedOllamaCredentials(t *testing.T) {
+ var chats atomic.Int32
+ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ user, password, ok := r.BasicAuth()
+ if !ok || user != "monitor" || password != " fixture password " {
+ t.Error("missing or changed synthetic Basic Auth credentials")
+ w.WriteHeader(http.StatusUnauthorized)
+ return
+ }
+ switch r.URL.Path {
+ case "/api/chat":
+ chats.Add(1)
+ w.Header().Set("Content-Type", "application/x-ndjson")
+ _, _ = w.Write([]byte("{\"model\":\"llama3\",\"message\":{\"role\":\"assistant\",\"content\":\"ok\"},\"done\":true}\n"))
+ default:
+ http.NotFound(w, r)
+ }
+ }))
+ defer server.Close()
+ persistence := config.NewConfigPersistence(t.TempDir())
+ cfg := config.NewDefaultAIConfig()
+ cfg.Enabled = true
+ cfg.Model = "ollama:llama3"
+ cfg.PatrolModel = "ollama:llama3"
+ cfg.OllamaBaseURL = server.URL
+ cfg.OllamaUsername = "monitor"
+ cfg.OllamaPassword = " fixture password "
+ require.NoError(t, persistence.SaveAIConfig(*cfg))
+ loaded, err := persistence.LoadAIConfig()
+ require.NoError(t, err)
+ service := NewService(persistence, nil)
+ service.cfg = loaded
+ provider, err := service.createPatrolProviderForModel(loaded.GetPatrolModel())
+ require.NoError(t, err)
+ require.NoError(t, provider.ChatStream(context.Background(), providers.ChatRequest{
+ Messages: []providers.Message{{Role: "user", Content: "Synthetic authentication probe"}},
+ }, func(providers.StreamEvent) {}))
+ require.Equal(t, int32(1), chats.Load())
+}
diff --git a/internal/api/ai_ollama_auth_lifecycle_test.go b/internal/api/ai_ollama_auth_lifecycle_test.go
new file mode 100644
index 0000000000..e55bcb74b9
--- /dev/null
+++ b/internal/api/ai_ollama_auth_lifecycle_test.go
@@ -0,0 +1,40 @@
+package api
+
+import (
+ "bytes"
+ "encoding/json"
+ "net/http"
+ "net/http/httptest"
+ "testing"
+
+ "github.com/rcourtman/pulse-go-rewrite/internal/config"
+ "github.com/stretchr/testify/require"
+)
+
+func TestAISettingsOllamaPasswordLifecycle(t *testing.T) {
+ tmp := t.TempDir()
+ persistence := config.NewConfigPersistence(tmp)
+ handler := newTestAISettingsHandler(&config.Config{DataPath: tmp}, persistence, nil)
+ for _, step := range []struct {
+ name, payload, username, password string
+ }{
+ {"set", `{"ollama_username":"monitor","ollama_password":" fixture password "}`, "monitor", " fixture password "},
+ {"preserve", `{"ollama_keep_alive":"24h"}`, "monitor", " fixture password "},
+ {"replace", `{"ollama_password":"replacement"}`, "monitor", "replacement"},
+ {"clear", `{"ollama_username":"","clear_ollama_password":true}`, "", ""},
+ } {
+ t.Run(step.name, func(t *testing.T) {
+ rec := httptest.NewRecorder()
+ handler.HandleUpdateAISettings(rec, newLoopbackRequest(http.MethodPut, "/api/settings/ai", bytes.NewBufferString(step.payload)))
+ require.Equal(t, http.StatusOK, rec.Code)
+ var response map[string]any
+ require.NoError(t, json.Unmarshal(rec.Body.Bytes(), &response))
+ require.NotContains(t, response, "ollama_password")
+ require.Equal(t, step.password != "", response["ollama_password_set"])
+ stored, err := persistence.LoadAIConfig()
+ require.NoError(t, err)
+ require.Equal(t, step.username, stored.OllamaUsername)
+ require.Equal(t, step.password, stored.OllamaPassword)
+ })
+ }
+}