fix: Allow clients to be remembered in the SessionHttpHandler

This commit is contained in:
Joachim Van Herwegen
2021-08-17 15:55:03 +02:00
parent 1173f98b5d
commit 47b3a2d77f
7 changed files with 28 additions and 13 deletions

View File

@@ -1,10 +1,9 @@
import type { Interaction } from '../../../../src/identity/interaction/email-password/handler/InteractionHandler';
import { SessionHttpHandler } from '../../../../src/identity/interaction/SessionHttpHandler';
import type { HttpRequest } from '../../../../src/server/HttpRequest';
import { NotImplementedHttpError } from '../../../../src/util/errors/NotImplementedHttpError';
import { createPostFormRequest } from './email-password/handler/Util';
describe('A SessionHttpHandler', (): void => {
const request: HttpRequest = {} as any;
const webId = 'http://test.com/id#me';
let oidcInteraction: Interaction;
let handler: SessionHttpHandler;
@@ -17,14 +16,15 @@ describe('A SessionHttpHandler', (): void => {
it('requires a defined oidcInteraction with a session.', async(): Promise<void> => {
oidcInteraction!.session = undefined;
await expect(handler.handle({ request, oidcInteraction })).rejects.toThrow(NotImplementedHttpError);
await expect(handler.handle({ request: {} as any, oidcInteraction })).rejects.toThrow(NotImplementedHttpError);
await expect(handler.handle({ request })).rejects.toThrow(NotImplementedHttpError);
await expect(handler.handle({ request: {} 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({
details: { webId },
details: { webId, shouldRemember: true },
type: 'complete',
});
});