feat: Use RequestParser and ResponseWriter for IDP

This commit is contained in:
Joachim Van Herwegen
2021-08-05 10:34:41 +02:00
parent a7a22bf43a
commit 7b7040a196
19 changed files with 264 additions and 194 deletions

View File

@@ -1,7 +1,7 @@
import type { Interaction } from '../../../../src/identity/interaction/email-password/handler/InteractionHandler';
import { SessionHttpHandler } from '../../../../src/identity/interaction/SessionHttpHandler';
import { NotImplementedHttpError } from '../../../../src/util/errors/NotImplementedHttpError';
import { createPostFormRequest } from './email-password/handler/Util';
import { createPostFormOperation } from './email-password/handler/Util';
describe('A SessionHttpHandler', (): void => {
const webId = 'http://test.com/id#me';
@@ -16,14 +16,14 @@ describe('A SessionHttpHandler', (): void => {
it('requires a defined oidcInteraction with a session.', async(): Promise<void> => {
oidcInteraction!.session = undefined;
await expect(handler.handle({ request: {} as any, oidcInteraction })).rejects.toThrow(NotImplementedHttpError);
await expect(handler.handle({ operation: {} as any, oidcInteraction })).rejects.toThrow(NotImplementedHttpError);
await expect(handler.handle({ request: {} as any })).rejects.toThrow(NotImplementedHttpError);
await expect(handler.handle({ operation: {} as any })).rejects.toThrow(NotImplementedHttpError);
});
it('returns an InteractionCompleteResult when done.', async(): Promise<void> => {
const request = createPostFormRequest({ remember: true });
await expect(handler.handle({ request, oidcInteraction })).resolves.toEqual({
const operation = createPostFormOperation({ remember: true });
await expect(handler.handle({ operation, oidcInteraction })).resolves.toEqual({
details: { webId, shouldRemember: true },
type: 'complete',
});