feat: Move redirect support from IDP handler to specific handlers

This commit is contained in:
Joachim Van Herwegen
2021-11-12 11:46:00 +01:00
parent 7163a0317b
commit 4241c5348d
24 changed files with 350 additions and 246 deletions

View File

@@ -1,8 +1,9 @@
import type {
InteractionHandler,
} from '../../../../../src/identity/interaction/email-password/handler/InteractionHandler';
} from '../../../../../src/identity/interaction/InteractionHandler';
import { BasicInteractionRoute } from '../../../../../src/identity/interaction/routing/BasicInteractionRoute';
import { BadRequestHttpError } from '../../../../../src/util/errors/BadRequestHttpError';
import { FoundHttpError } from '../../../../../src/util/errors/FoundHttpError';
import { InternalServerError } from '../../../../../src/util/errors/InternalServerError';
describe('A BasicInteractionRoute', (): void => {
@@ -57,6 +58,12 @@ describe('A BasicInteractionRoute', (): void => {
.resolves.toEqual({ type: 'error', error, templateFiles: viewTemplates });
});
it('re-throws redirect errors.', async(): Promise<void> => {
const error = new FoundHttpError('http://test.com/redirect');
handler.handleSafe.mockRejectedValueOnce(error);
await expect(route.handleOperation({ method: 'POST' } as any)).rejects.toThrow(error);
});
it('creates an internal error in case of non-native errors.', async(): Promise<void> => {
handler.handleSafe.mockRejectedValueOnce('notAnError');
await expect(route.handleOperation({ method: 'POST' } as any)).resolves.toEqual({