mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-03 09:38:54 +00:00
fix(immich): a server with a self-signed certificate can be connected, as the other providers can
Synology Photos, AirTrail and Dawarich each have a switch to trust a self-signed certificate; Immich had none, so every request to such a server failed with a bare "fetch failed" (#2475). Immich gets the same switch, per user and off by default: - users.immich_allow_insecure_tls (migration 243, column guarded) and a settings row labelled with the existing skipSSLVerification string, so no new translations. The settings card on desktop and phone draws it from that row. - Every request to the user's Immich (status, browse, search, asset info and proxy, albums, upload) passes rejectUnauthorized from the switch. Only 1 counts as on. A shared photo follows its owner's switch, since it goes to the owner's server with the owner's key. - Settings PUT and the connection test take allow_insecure_tls as a boolean. Absent on a save keeps the stored choice, so an older client cannot clear it; disconnecting turns it off again. - A failed request names its cause, e.g. "fetch failed (self-signed certificate)", instead of only the undici message. - The upload mirror gets a timeout: the journey upload waits on it. Fresh installs also never showed "Mirror journey photos to Immich on upload": migration 112 added that row only where the Immich provider already existed, and on a new database the seeds create it after the migrations. The row is now in the seeds, and migration 243 adds it where the provider exists without it. Wiki: Photo-Providers.md documents the switch.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// FE-COMP-PHOTOPROVIDERS-001 to FE-COMP-PHOTOPROVIDERS-024
|
||||
// FE-COMP-PHOTOPROVIDERS-001 to FE-COMP-PHOTOPROVIDERS-026
|
||||
import { render, screen, waitFor } from '../../../tests/helpers/render';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { http, HttpResponse } from 'msw';
|
||||
@@ -470,3 +470,56 @@ describe('PhotoProvidersSection – checkbox fields and failures', () => {
|
||||
await screen.findByText('Connected to Immich');
|
||||
});
|
||||
});
|
||||
|
||||
// ── The Immich self-signed switch, as the server describes it (025, 026) ─────
|
||||
|
||||
/** The Immich card exactly as the provider rows seed it (#2475). */
|
||||
const immichProvider = {
|
||||
...fakeProvider,
|
||||
fields: [
|
||||
{ key: 'immich_url', label: 'providerUrl', input_type: 'url', placeholder: 'https://immich.example.com', required: true, secret: false, settings_key: 'immich_url', payload_key: 'immich_url', sort_order: 0 },
|
||||
{ key: 'immich_api_key', label: 'providerApiKey', input_type: 'password', placeholder: 'API Key', required: true, secret: true, settings_key: null, payload_key: 'immich_api_key', sort_order: 1 },
|
||||
{ key: 'immich_allow_insecure_tls', label: 'skipSSLVerification', input_type: 'checkbox', placeholder: null, required: false, secret: false, settings_key: 'allow_insecure_tls', payload_key: 'allow_insecure_tls', sort_order: 2 },
|
||||
],
|
||||
};
|
||||
|
||||
describe('PhotoProvidersSection: Immich self-signed certificates', () => {
|
||||
it('FE-COMP-PHOTOPROVIDERS-025: a stored switch shows as on under its Synology wording', async () => {
|
||||
server.use(
|
||||
http.get('/api/addons/immich/settings', () =>
|
||||
HttpResponse.json({ immich_url: 'https://immich.lan', connected: true, auto_upload: false, allow_insecure_tls: true }),
|
||||
),
|
||||
);
|
||||
seedMemoriesEnabled([immichProvider]);
|
||||
render(<PhotoProvidersSection />);
|
||||
|
||||
expect(await screen.findByText('Skip SSL certificate verification')).toBeInTheDocument();
|
||||
await waitFor(() => expect(checkboxToggle()).toHaveAttribute('aria-pressed', 'true'));
|
||||
});
|
||||
|
||||
it('FE-COMP-PHOTOPROVIDERS-026: turning it on sends it with the connection test, as a boolean', async () => {
|
||||
const user = userEvent.setup();
|
||||
let body: Record<string, unknown> | null = null;
|
||||
server.use(
|
||||
http.get('/api/addons/immich/settings', () =>
|
||||
HttpResponse.json({ immich_url: 'https://immich.lan', connected: false, auto_upload: false, allow_insecure_tls: false }),
|
||||
),
|
||||
http.post('/api/addons/immich/test', async ({ request }) => {
|
||||
body = (await request.json()) as Record<string, unknown>;
|
||||
return HttpResponse.json({ connected: true });
|
||||
}),
|
||||
);
|
||||
seedMemoriesEnabled([immichProvider]);
|
||||
render(<PhotoProvidersSection />);
|
||||
|
||||
await screen.findByDisplayValue('https://immich.lan');
|
||||
await waitFor(() => expect(checkboxToggle()).toHaveAttribute('aria-pressed', 'false'));
|
||||
await user.type(screen.getByPlaceholderText('API Key'), 'secret-key');
|
||||
await user.click(checkboxToggle());
|
||||
await user.click(screen.getByRole('button', { name: /test connection/i }));
|
||||
|
||||
await waitFor(() =>
|
||||
expect(body).toEqual({ immich_url: 'https://immich.lan', immich_api_key: 'secret-key', allow_insecure_tls: true }),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user