feat: Split up IDP HTML, routing, and handler behaviour

This commit is contained in:
Joachim Van Herwegen
2021-12-02 09:57:23 +01:00
parent 8f8e8e6df4
commit bc0eeb1012
45 changed files with 1013 additions and 716 deletions

View File

@@ -1,22 +1,20 @@
import { BasicRepresentation } from '../../../../src/http/representation/BasicRepresentation';
import type {
InteractionResponseResult,
} from '../../../../src/identity/interaction/InteractionHandler';
import type { Representation } from '../../../../src/http/representation/Representation';
import {
InteractionHandler,
} from '../../../../src/identity/interaction/InteractionHandler';
import { NotImplementedHttpError } from '../../../../src/util/errors/NotImplementedHttpError';
class SimpleInteractionHandler extends InteractionHandler {
public async handle(): Promise<InteractionResponseResult> {
return { type: 'response' };
public async handle(): Promise<Representation> {
return new BasicRepresentation();
}
}
describe('An InteractionHandler', (): void => {
const handler = new SimpleInteractionHandler();
it('only supports JSON data.', async(): Promise<void> => {
it('only supports JSON data or empty bodies.', async(): Promise<void> => {
let representation = new BasicRepresentation('{}', 'application/json');
await expect(handler.canHandle({ operation: { body: representation }} as any)).resolves.toBeUndefined();
@@ -24,6 +22,7 @@ describe('An InteractionHandler', (): void => {
await expect(handler.canHandle({ operation: { body: representation }} as any))
.rejects.toThrow(NotImplementedHttpError);
await expect(handler.canHandle({ operation: {}} as any)).rejects.toThrow(NotImplementedHttpError);
representation = new BasicRepresentation();
await expect(handler.canHandle({ operation: { body: representation }} as any)).resolves.toBeUndefined();
});
});