Add local authentication option (#37)
All checks were successful
Build and Push Image / docker-build-and-push (push) Successful in 2m20s

Co-authored-by: Shaun Campbell <shaun@campbellwireless.net>
Reviewed-on: #37
Co-authored-by: AI Agent <ai-agent@campbellwireless.net>
Co-committed-by: AI Agent <ai-agent@campbellwireless.net>
This commit was merged in pull request #37.
This commit is contained in:
2026-02-22 05:17:45 +00:00
committed by shaun
parent 42fe36ca86
commit fc8e80186d
26 changed files with 695 additions and 71 deletions

View File

@@ -0,0 +1,37 @@
import { beforeEach, describe, expect, it } from 'vitest';
import { load } from './+page.server';
beforeEach(() => {
process.env.AUTH_URL = 'https://example.com/auth';
});
describe('login page load', () => {
it('returns auth options when local auth is enabled', async () => {
process.env.LOCAL_AUTH_ENABLED = 'true';
const result = await load({
url: new URL('https://example.com/login')
} as Parameters<typeof load>[0]);
expect(result.signinUrl).toBe('https://example.com/auth/signin/synology');
expect(result.localSigninUrl).toBe('https://example.com/auth/signin/local');
expect(result.localAuthEnabled).toBe(true);
});
it('maps credentials errors to a generic message', async () => {
process.env.LOCAL_AUTH_ENABLED = 'true';
const result = await load({
url: new URL('https://example.com/login?error=CredentialsSignin')
} as Parameters<typeof load>[0]);
expect(result.error).toBe('Invalid credentials');
});
it('disables local auth in the response when disabled', async () => {
process.env.LOCAL_AUTH_ENABLED = 'false';
const result = await load({
url: new URL('https://example.com/login')
} as Parameters<typeof load>[0]);
expect(result.localAuthEnabled).toBe(false);
});
});