mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
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:
@@ -0,0 +1,43 @@
|
||||
import type { ProviderFactory } from '../../../../../src/identity/configuration/ProviderFactory';
|
||||
import type { Interaction } from '../../../../../src/identity/interaction/InteractionHandler';
|
||||
import { ForgetWebIdHandler } from '../../../../../src/identity/interaction/oidc/ForgetWebIdHandler';
|
||||
import type Provider from '../../../../../templates/types/oidc-provider';
|
||||
|
||||
describe('A ForgetWebIdHandler', (): void => {
|
||||
let oidcInteraction: Interaction;
|
||||
let provider: jest.Mocked<Provider>;
|
||||
let providerFactory: jest.Mocked<ProviderFactory>;
|
||||
let handler: ForgetWebIdHandler;
|
||||
|
||||
beforeEach(async(): Promise<void> => {
|
||||
oidcInteraction = {
|
||||
lastSubmission: { login: { accountId: 'id' }},
|
||||
persist: jest.fn(),
|
||||
session: {
|
||||
cookie: 'cookie',
|
||||
},
|
||||
returnTo: 'returnTo',
|
||||
} as any;
|
||||
|
||||
provider = {
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
Session: {
|
||||
find: jest.fn().mockResolvedValue({ persist: jest.fn() }),
|
||||
},
|
||||
/* eslint-enable @typescript-eslint/naming-convention */
|
||||
} as any;
|
||||
|
||||
providerFactory = {
|
||||
getProvider: jest.fn().mockResolvedValue(provider),
|
||||
};
|
||||
|
||||
handler = new ForgetWebIdHandler(providerFactory);
|
||||
});
|
||||
|
||||
it('forgets the WebID and updates the interaction.', async(): Promise<void> => {
|
||||
await expect(handler.handle({ oidcInteraction } as any)).rejects.toThrow(expect.objectContaining({
|
||||
statusCode: 302,
|
||||
location: 'returnTo',
|
||||
}));
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user