mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: Full rework of account management
Complete rewrite of the account management and related systems. Makes the architecture more modular, allowing for easier extensions and configurations.
This commit is contained in:
33
test/unit/identity/interaction/oidc/PromptHandler.test.ts
Normal file
33
test/unit/identity/interaction/oidc/PromptHandler.test.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import type { Interaction } from '../../../../../src/identity/interaction/InteractionHandler';
|
||||
import { PromptHandler } from '../../../../../src/identity/interaction/oidc/PromptHandler';
|
||||
import type { InteractionRoute } from '../../../../../src/identity/interaction/routing/InteractionRoute';
|
||||
import { BadRequestHttpError } from '../../../../../src/util/errors/BadRequestHttpError';
|
||||
|
||||
describe('A PromptHandler', (): void => {
|
||||
let oidcInteraction: Interaction;
|
||||
let promptRoutes: Record<string, jest.Mocked<InteractionRoute>>;
|
||||
let handler: PromptHandler;
|
||||
|
||||
beforeEach(async(): Promise<void> => {
|
||||
oidcInteraction = { prompt: { name: 'login' }} as any;
|
||||
promptRoutes = {
|
||||
login: { getPath: jest.fn().mockReturnValue('http://example.com/idp/login/') } as any,
|
||||
};
|
||||
handler = new PromptHandler(promptRoutes);
|
||||
});
|
||||
|
||||
it('errors if there is no interaction.', async(): Promise<void> => {
|
||||
await expect(handler.handle({ } as any)).rejects.toThrow(BadRequestHttpError);
|
||||
});
|
||||
|
||||
it('errors if the prompt is unsupported.', async(): Promise<void> => {
|
||||
oidcInteraction.prompt.name = 'unsupported';
|
||||
await expect(handler.handle({ oidcInteraction } as any)).rejects.toThrow(BadRequestHttpError);
|
||||
});
|
||||
|
||||
it('returns a JSON body with the location and prompt.', async(): Promise<void> => {
|
||||
await expect(handler.handle({ oidcInteraction } as any)).resolves.toEqual(
|
||||
{ json: { prompt: 'login', location: 'http://example.com/idp/login/' }},
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user