feat(domains): Domain registrieren mit Schutz vor Doppelbestellung, Aufträge, Changelog und Anleitung
- Verfügbarkeitsprüfung über DomainStudio, Entwurf mit Kontakten und Nameservern, Zusammenfassung mit System und Preis - Verbindliches Abschicken: atomarer Anspruch DRAFT -> SUBMITTING vor dem Netzaufruf, genau ein POST /domain ohne Wiederholung, unklarer Ausgang als UNKNOWN, Bindung an das System - Aufträge: Stand aus dem AutoDNS-Auftrag, Abgleich unklarer Aufträge, Verwerfen erst nach Abgleich - Reiter Registrieren und Aufträge, Changelog, Anwender- und Administrationshandbuch, Mandantenschutz-Inventar Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -17,8 +17,19 @@ const MANAGE_HANDLERS = [
|
||||
'deleteCustomer',
|
||||
'createContact',
|
||||
'assignContacts',
|
||||
'checkAvailability',
|
||||
'createOrder',
|
||||
'submitOrder',
|
||||
'cancelOrder',
|
||||
];
|
||||
const USE_HANDLERS = [
|
||||
'getStatus',
|
||||
'listCustomers',
|
||||
'listContacts',
|
||||
'listDomains',
|
||||
'listOrders',
|
||||
'refreshOrders',
|
||||
];
|
||||
const USE_HANDLERS = ['getStatus', 'listCustomers', 'listContacts', 'listDomains'];
|
||||
|
||||
function makeDirectory() {
|
||||
return {
|
||||
@@ -33,6 +44,17 @@ function makeDirectory() {
|
||||
};
|
||||
}
|
||||
|
||||
function makeOrders() {
|
||||
return {
|
||||
checkAvailability: vi.fn(async (..._a: unknown[]) => ({})),
|
||||
listOrders: vi.fn(async (..._a: unknown[]) => []),
|
||||
createOrder: vi.fn(async (..._a: unknown[]) => ({})),
|
||||
refreshOpenOrders: vi.fn(async (..._a: unknown[]) => []),
|
||||
submitOrder: vi.fn(async (..._a: unknown[]) => ({})),
|
||||
cancelOrder: vi.fn(async (..._a: unknown[]) => ({})),
|
||||
};
|
||||
}
|
||||
|
||||
function makeSettings() {
|
||||
return {
|
||||
getStatus: vi.fn(async (..._a: unknown[]) => ({})),
|
||||
@@ -80,6 +102,12 @@ describe('DomainsController — Metadaten', () => {
|
||||
expect(route('listDomains')).toEqual([0, 'domains']);
|
||||
expect(route('updateCustomer')).toEqual([2, 'customers/:id']);
|
||||
expect(route('deleteCustomer')).toEqual([3, 'customers/:id']);
|
||||
expect(route('checkAvailability')).toEqual([1, 'availability']);
|
||||
expect(route('listOrders')).toEqual([0, 'orders']);
|
||||
expect(route('createOrder')).toEqual([1, 'orders']);
|
||||
expect(route('refreshOrders')).toEqual([1, 'orders/refresh']);
|
||||
expect(route('submitOrder')).toEqual([1, 'orders/:id/submit']);
|
||||
expect(route('cancelOrder')).toEqual([1, 'orders/:id/cancel']);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -97,11 +125,22 @@ describe('DomainsController — Routen-Reihenfolge (statisch vor :id)', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('DomainsController — Auftraege: Reihenfolge', () => {
|
||||
it("'orders/refresh' steht vor jedem :id-Handler", () => {
|
||||
const names = Object.getOwnPropertyNames(DomainsController.prototype);
|
||||
const refresh = names.indexOf('refreshOrders');
|
||||
expect(refresh).toBeGreaterThan(-1);
|
||||
for (const n of ['updateCustomer', 'deleteCustomer', 'submitOrder', 'cancelOrder']) {
|
||||
expect(refresh, n).toBeLessThan(names.indexOf(n));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('DomainsController — Verhalten', () => {
|
||||
it('reicht req.tenantId weiter', async () => {
|
||||
const settings = makeSettings();
|
||||
const directory = makeDirectory();
|
||||
const c = new DomainsController(settings as any, directory as any);
|
||||
const c = new DomainsController(settings as any, directory as any, makeOrders() as any);
|
||||
await c.getStatus(req('t1'));
|
||||
await c.getSettings(req('t1'));
|
||||
await c.saveSettings(req('t1'), { demoUser: 'x' } as any);
|
||||
@@ -115,7 +154,7 @@ describe('DomainsController — Verhalten', () => {
|
||||
it('Kunden-, Kontakt- und Domainwege reichen req.tenantId weiter; refresh nur bei 1/true', async () => {
|
||||
const settings = makeSettings();
|
||||
const directory = makeDirectory();
|
||||
const c = new DomainsController(settings as any, directory as any);
|
||||
const c = new DomainsController(settings as any, directory as any, makeOrders() as any);
|
||||
const id = '11111111-1111-4111-8111-111111111111';
|
||||
await c.listCustomers(req('t1'));
|
||||
await c.createCustomer(req('t1'), { name: 'A' } as any);
|
||||
@@ -147,7 +186,44 @@ describe('DomainsController — Verhalten', () => {
|
||||
});
|
||||
|
||||
it('ohne Mandantenkontext 403', async () => {
|
||||
const c = new DomainsController(makeSettings() as any, makeDirectory() as any);
|
||||
const c = new DomainsController(
|
||||
makeSettings() as any,
|
||||
makeDirectory() as any,
|
||||
makeOrders() as any,
|
||||
);
|
||||
await expect(c.getStatus(req(undefined))).rejects.toBeInstanceOf(ForbiddenException);
|
||||
});
|
||||
});
|
||||
|
||||
describe('DomainsController — Auftraege: Verhalten', () => {
|
||||
const user = { id: 'u1', username: 'anna' } as any;
|
||||
const id = '22222222-2222-4222-8222-222222222222';
|
||||
|
||||
it('reicht Organisation, Benutzer und Auftragsnummer weiter', async () => {
|
||||
const orders = makeOrders();
|
||||
const c = new DomainsController(makeSettings() as any, makeDirectory() as any, orders as any);
|
||||
await c.checkAvailability(req('t1'), { domain: 'beispiel.de' });
|
||||
await c.listOrders(req('t1'));
|
||||
await c.createOrder(req('t1'), user, { domain: 'beispiel.de' } as any);
|
||||
await c.refreshOrders(req('t1'));
|
||||
await c.submitOrder(req('t1'), user, id);
|
||||
await c.cancelOrder(req('t1'), id);
|
||||
expect(orders.checkAvailability).toHaveBeenCalledWith('t1', 'beispiel.de');
|
||||
expect(orders.listOrders).toHaveBeenCalledWith('t1');
|
||||
expect(orders.createOrder).toHaveBeenCalledWith('t1', 'u1', { domain: 'beispiel.de' });
|
||||
expect(orders.refreshOpenOrders).toHaveBeenCalledWith('t1');
|
||||
expect(orders.submitOrder).toHaveBeenCalledWith('t1', { id: 'u1', username: 'anna' }, id);
|
||||
expect(orders.cancelOrder).toHaveBeenCalledWith('t1', id);
|
||||
});
|
||||
|
||||
it('ohne Mandantenkontext 403', async () => {
|
||||
const c = new DomainsController(
|
||||
makeSettings() as any,
|
||||
makeDirectory() as any,
|
||||
makeOrders() as any,
|
||||
);
|
||||
await expect(c.submitOrder(req(undefined), user, id)).rejects.toBeInstanceOf(
|
||||
ForbiddenException,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user