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

@@ -2,23 +2,34 @@ import type { InteractionRoute } from '../../../../../src/identity/interaction/r
import {
RelativePathInteractionRoute,
} from '../../../../../src/identity/interaction/routing/RelativePathInteractionRoute';
import { InternalServerError } from '../../../../../src/util/errors/InternalServerError';
describe('A RelativePathInteractionRoute', (): void => {
const relativePath = '/relative/';
let route: jest.Mocked<InteractionRoute>;
let relativeRoute: RelativePathInteractionRoute;
let route: jest.Mocked<InteractionRoute<'base'>>;
let relativeRoute: RelativePathInteractionRoute<'base'>;
beforeEach(async(): Promise<void> => {
route = {
getPath: jest.fn().mockReturnValue('http://example.com/'),
matchPath: jest.fn().mockReturnValue({ base: 'base' }),
};
relativeRoute = new RelativePathInteractionRoute(route, relativePath);
});
it('returns the joined path.', async(): Promise<void> => {
relativeRoute = new RelativePathInteractionRoute(route, relativePath);
expect(relativeRoute.getPath()).toBe('http://example.com/relative/');
});
relativeRoute = new RelativePathInteractionRoute('http://example.com/test/', relativePath);
expect(relativeRoute.getPath()).toBe('http://example.com/test/relative/');
it('matches paths by checking if the tail matches the relative path.', async(): Promise<void> => {
expect(relativeRoute.matchPath('http://example.com/relative/')).toEqual({ base: 'base' });
expect(relativeRoute.matchPath('http://example.com/relative')).toBeUndefined();
});
it('errors if the base path does not end in a slash.', async(): Promise<void> => {
route.getPath.mockReturnValueOnce('http://example.com/foo');
expect((): string => relativeRoute.getPath()).toThrow(InternalServerError);
});
});