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:
Joachim Van Herwegen
2022-03-16 10:12:13 +01:00
parent ade977bb4f
commit a47f5236ef
366 changed files with 12345 additions and 5111 deletions

View File

@@ -1,24 +1,22 @@
import { BasicRepresentation } from '../../../../src/http/representation/BasicRepresentation';
import { RepresentationMetadata } from '../../../../src/http/representation/RepresentationMetadata';
import type {
InteractionHandler,
InteractionHandlerInput,
} from '../../../../src/identity/interaction/InteractionHandler';
JsonInteractionHandler,
JsonInteractionHandlerInput,
} from '../../../../src/identity/interaction/JsonInteractionHandler';
import { LocationInteractionHandler } from '../../../../src/identity/interaction/LocationInteractionHandler';
import { FoundHttpError } from '../../../../src/util/errors/FoundHttpError';
import { NotFoundHttpError } from '../../../../src/util/errors/NotFoundHttpError';
import { readJsonStream } from '../../../../src/util/StreamUtil';
describe('A LocationInteractionHandler', (): void => {
const representation = new BasicRepresentation();
const input: InteractionHandlerInput = {
operation: {
target: { path: 'http://example.com/target' },
preferences: {},
method: 'GET',
body: new BasicRepresentation(),
},
const input: JsonInteractionHandlerInput = {
target: { path: 'http://example.com/target' },
method: 'GET',
json: { input: 'data' },
metadata: new RepresentationMetadata(),
};
let source: jest.Mocked<InteractionHandler>;
let source: jest.Mocked<JsonInteractionHandler>;
let handler: LocationInteractionHandler;
beforeEach(async(): Promise<void> => {
@@ -50,8 +48,8 @@ describe('A LocationInteractionHandler', (): void => {
source.handle.mockRejectedValueOnce(new FoundHttpError(location));
const response = await handler.handle(input);
expect(response.metadata.identifier.value).toEqual(input.operation.target.path);
await expect(readJsonStream(response.data)).resolves.toEqual({ location });
expect(response.metadata?.identifier.value).toEqual(input.target.path);
expect(response.json).toEqual({ location });
});
it('rethrows non-redirect errors.', async(): Promise<void> => {