feat: Create SetupHttpHandler

This handler allows users to set up servers with a pod
and without having to enable public access first
This commit is contained in:
Joachim Van Herwegen
2021-09-15 16:52:16 +02:00
parent 02df2905de
commit 4e1a2f5981
11 changed files with 1094 additions and 489 deletions

View File

@@ -37,13 +37,23 @@ describe('A GeneratedPodManager', (): void => {
it('throws an error if the generate identifier is not available.', async(): Promise<void> => {
store.resourceExists.mockResolvedValueOnce(true);
const result = manager.createPod({ path: `${base}user/` }, settings);
const result = manager.createPod({ path: `${base}user/` }, settings, false);
await expect(result).rejects.toThrow(`There already is a resource at ${base}user/`);
await expect(result).rejects.toThrow(ConflictHttpError);
});
it('generates an identifier and writes containers before writing the resources in them.', async(): Promise<void> => {
await expect(manager.createPod({ path: `${base}${settings.login}/` }, settings)).resolves.toBeUndefined();
await expect(manager.createPod({ path: `${base}${settings.login}/` }, settings, false)).resolves.toBeUndefined();
expect(store.setRepresentation).toHaveBeenCalledTimes(3);
expect(store.setRepresentation).toHaveBeenNthCalledWith(1, { path: '/path/' }, '/');
expect(store.setRepresentation).toHaveBeenNthCalledWith(2, { path: '/path/a/' }, '/a/');
expect(store.setRepresentation).toHaveBeenNthCalledWith(3, { path: '/path/a/b' }, '/a/b');
});
it('allows overwriting when enabled.', async(): Promise<void> => {
store.resourceExists.mockResolvedValueOnce(true);
await expect(manager.createPod({ path: `${base}${settings.login}/` }, settings, true)).resolves.toBeUndefined();
expect(store.setRepresentation).toHaveBeenCalledTimes(3);
expect(store.setRepresentation).toHaveBeenNthCalledWith(1, { path: '/path/' }, '/');