feat(makelore): add platform oidc login
This commit is contained in:
1 parent
87d3f03d75
commit
7236def07d
12 files changed
+528
-10
No files matched your search
@@ -21,10 +21,16 @@ const providerServiceMock = vi.hoisted(() => ({
|
||||
deleteAccountApiKey: vi.fn(),
|
||||
}));
|
||||
|
||||
const platformAuthMock = vi.hoisted(() => ({
|
||||
startPlatformAuthorization: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('@electron/services/providers/provider-service', () => ({
|
||||
getProviderService: () => providerServiceMock,
|
||||
}));
|
||||
|
||||
vi.mock('@electron/services/platform-auth', () => platformAuthMock);
|
||||
|
||||
function createResponse() {
|
||||
const chunks: string[] = [];
|
||||
const res = {
|
||||
@@ -66,6 +72,31 @@ describe('auth host api routes', () => {
|
||||
resetRememberedPasswordForTests();
|
||||
providerServiceMock.deleteAccountApiKey.mockReset();
|
||||
providerServiceMock.deleteAccountApiKey.mockResolvedValue(true);
|
||||
platformAuthMock.startPlatformAuthorization.mockReset();
|
||||
platformAuthMock.startPlatformAuthorization.mockResolvedValue({
|
||||
requestId: 'request-1',
|
||||
authorizationUrl: 'https://square.example.test/authorize?state=state-1',
|
||||
});
|
||||
});
|
||||
|
||||
it('starts platform OIDC in Main and returns only the browser authorization URL', async () => {
|
||||
const response = createResponse();
|
||||
|
||||
const handled = await handleAuthRoutes(
|
||||
createRequest('POST', {}),
|
||||
response.res,
|
||||
new URL('http://127.0.0.1:13210/api/auth/platform/start'),
|
||||
{} as never,
|
||||
);
|
||||
|
||||
expect(handled).toBe(true);
|
||||
expect(response.statusCode).toBe(200);
|
||||
expect(response.json()).toEqual({
|
||||
success: true,
|
||||
requestId: 'request-1',
|
||||
authorizationUrl: 'https://square.example.test/authorize?state=state-1',
|
||||
});
|
||||
expect(platformAuthMock.startPlatformAuthorization).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it('projects a safe current-user identity and module access without exposing secrets', async () => {
|
||||
|
||||
Reference in new issue
Block a user