Plesk: Domains, Postfächer, Datenbanken und FTP anlegen, ändern, löschen
- Unterobjekte schreibbar (children.write): Sites/Subdomains anlegen und löschen (Hauptdomain geschützt), Postfächer (anlegen, Passwort, Größe, löschen), MySQL-Datenbanken mit Benutzer (anlegen, Passwort, löschen), FTP-Benutzer (anlegen, Passwort/Verzeichnis, löschen) - Mandantentrennung: vor jeder Änderung Zugehörigkeit zum Abonnement prüfen; Anlegen wiederholbar, Löschen idempotent - Live an Plesk 18.0.81 geprüft; Eigenheiten berücksichtigt: set-db-user mit <id>, create-non-existent, Fehler 1024 (Limit) = Ablehnung statt Retry, Teilanlage von Postfächern bei Größenfehler wird zurückgerollt - Nachbau verhält sich entsprechend; 5 neue Tests (22 gesamt) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
612ab5fc53
commit
119a4fe07e
4 changed files with 245 additions and 46 deletions
|
|
@ -23,7 +23,7 @@ Paket `packages/connector-plesk`, gebaut nach der Plesk-Dokumentation (XML-API,
|
|||
- **Bereitstellung** (Bestellung): Kunde mit Login `kc` + Ziffern der Vertragsnummer und Vermerk „Kundencenter K-… V-…“, dann Abonnement `kc<Nr>.<Domain für neue Abonnements>` auf dem Plan. Wiederholung findet Kunde (am Vermerk) und Abonnement (am Besitzer) wieder statt doppelt anzulegen. Passwörter (Kunde, FTP) werden zufällig erzeugt und **nie gespeichert**; Zugang über den Panel-Login.
|
||||
- **Aktionen**: Sperren/Entsperren (Status 16/0), Planwechsel (`switch-subscription`), Löschen des Abonnements (Kunde bleibt; nie automatisch wiederholt), Passwort des Besitzers neu setzen.
|
||||
- **Panel-Login**: Einmal-Sitzung für den Besitzer (`server/create_session` → `rsession_init.php`), nie gespeichert.
|
||||
- **Unterobjekte nur lesend**: Domains (Hauptdomain + weitere Sites), Postfächer, Datenbanken, FTP-Benutzer – jeweils auf das Abonnement gefiltert.
|
||||
- **Unterobjekte** (Freigabe pro Produkt/Ressource wie bei KeyHelp): Domains (weitere Sites/Subdomains anlegen und löschen; Hauptdomain geschützt), Postfächer (anlegen, Passwort/Größe, löschen), Datenbanken (MySQL mit gleichnamigem Benutzer, Passwort, löschen), FTP-Benutzer (anlegen, Passwort/Verzeichnis, löschen; `/www/` aus der Oberfläche wird zu `/httpdocs`). Vor jeder Änderung wird geprüft, dass das Objekt zum Abonnement gehört; Anlegen ist wiederholbar, Löschen idempotent. Domain-Einstellungen (PHP, Let’s Encrypt) bitte im Plesk-Panel ändern.
|
||||
|
||||
### Sicherheit
|
||||
- Alle Werte werden in XML maskiert (keine Element-Injektion); Antworten mit DOCTYPE/ENTITY werden abgelehnt (kein XXE).
|
||||
|
|
@ -42,11 +42,12 @@ Paket `packages/connector-plesk`, gebaut nach der Plesk-Dokumentation (XML-API,
|
|||
| `site/get`, `mail/get_info`, `database/get-db`, `ftp-user/get` | ✅ bestätigt; bei 0 Treffern liefert Plesk ein leeres `<result>` ohne `id` → wird ausgefiltert (behoben) |
|
||||
| Sperren/Entsperren, Planwechsel, Passwort, Löschen | ✅ bestätigt (Zielzustand, Wiederholung unschädlich) |
|
||||
| Mandantentrennung bei Unterobjekten | ✅ bestätigt |
|
||||
| Unterobjekte ändern (`site/add·del`, `mail/create·update·remove`, `database/add-db·add-db-user·set-db-user·del-db`, `ftp-user/add·set·del`) | ✅ bestätigt; Eigenheiten: `set-db-user` erwartet `<id>` direkt (kein `<filter>`), Element heißt `create-non-existent` (für neue FTP-Verzeichnisse nötig), Plan-/Lizenzlimits kommen als Fehler **1024** (jetzt Ablehnung statt Wiederholung), **`mail/create` legt das Postfach an und meldet erst danach einen Größenfehler** → Connector rollt zurück |
|
||||
|
||||
Hinweis: Mit der kostenlosen Edition „Web Admin SE“ sind höchstens 3 Kunden/3 Domains möglich; für echten Betrieb ist eine Plesk-Lizenz mit Kundenverwaltung (z. B. Web Pro/Web Host) nötig.
|
||||
|
||||
### Noch nicht umgesetzt
|
||||
Neue Service-Pläne aus dem Kundencenter anlegen, Ändern von Domains/Postfächern/Datenbanken/FTP, SSL-Zertifikate, DNS, Reseller, mehrere Abonnements je Bestellung.
|
||||
Neue Service-Pläne aus dem Kundencenter anlegen, Domain-Einstellungen (PHP-Version, Let’s Encrypt), Weiterleitungen/Aliase von Postfächern, SSL-Zertifikate, DNS, Reseller, mehrere Abonnements je Bestellung.
|
||||
|
||||
### Testen ohne eigenen Server
|
||||
Plesk bietet ein offizielles Docker-Image (`plesk/plesk`) und eine kostenlose Testlizenz (14 Tage). Das Skript für den Live-Test liegt nicht im Repo (nutzt echte Zugangsdaten); Ablauf: read → provision → actions → sso → children → cleanup.
|
||||
|
|
|
|||
|
|
@ -15,7 +15,8 @@ export interface PleskDeps extends HttpOptions { randomPassword?: () => string }
|
|||
|
||||
type ErrCode = ConstructorParameters<typeof ConnectorError>[0];
|
||||
/** Fehlercodes der XML-API → normalisierte Fehler. */
|
||||
const ERRCODE: Record<string, ErrCode> = { '1001': 'AUTH_FAILED', '1003': 'AUTH_FAILED', '1006': 'AUTH_FAILED', '1013': 'NOT_FOUND', '1015': 'NOT_FOUND', '1007': 'CONFLICT', '1014': 'INVALID_INPUT', '1019': 'INVALID_INPUT', '1018': 'INVALID_INPUT', '1023': 'UPSTREAM_ERROR', '1002': 'UNSUPPORTED', '1005': 'UPSTREAM_ERROR' };
|
||||
const ERRCODE: Record<string, ErrCode> = { '1001': 'AUTH_FAILED', '1003': 'AUTH_FAILED', '1006': 'AUTH_FAILED', '1013': 'NOT_FOUND', '1015': 'NOT_FOUND', '1007': 'CONFLICT', '1014': 'INVALID_INPUT', '1019': 'INVALID_INPUT', '1018': 'INVALID_INPUT', '1023': 'UPSTREAM_ERROR', '1002': 'UNSUPPORTED', '1005': 'UPSTREAM_ERROR',
|
||||
/** Limit des Plans/der Lizenz erreicht (z. B. Websites, Postfachgröße): Ablehnung, kein vorübergehender Fehler (an 18.0.81 beobachtet). */ '1024': 'INVALID_INPUT' };
|
||||
/** Abonnement-Status: 0 aktiv, 4 Sicherung/Wiederherstellung läuft, 16 vom Admin gesperrt, 32 vom Reseller, 64 vom Kunden, 256 abgelaufen. */
|
||||
const STATUS_LABEL: Record<string, string> = { '0': 'aktiv', '4': 'Sicherung/Wiederherstellung', '16': 'vom Administrator gesperrt', '32': 'vom Reseller gesperrt', '64': 'vom Kunden deaktiviert', '256': 'abgelaufen' };
|
||||
const stateOf = (s: string | null): NormalizedResource['state'] => (s === null ? 'unknown' : s === '0' || s === '4' ? 'active' : s === '256' ? 'expired' : 'suspended');
|
||||
|
|
@ -185,48 +186,142 @@ export function createPleskConnector(deps: PleskDeps = {}): Connector {
|
|||
const p = (await plans(ctx)).find((x0) => x0.id === pid); if (!p) throw new ConnectorError('BAD_CONFIG', `Service-Plan ${pid} gibt es in Plesk nicht (mehr)`); return p;
|
||||
}
|
||||
|
||||
// ---- Unterobjekte (nur lesen; Änderungen folgen nach dem Test an einer echten Instanz) ----
|
||||
const children: ChildAccess = {
|
||||
async kinds() { return [{ kind: 'domain', canWrite: false }, { kind: 'email', canWrite: false }, { kind: 'database', canWrite: false }, { kind: 'ftp', canWrite: false }]; },
|
||||
async list(ctx, parentRef, kind): Promise<NormalizedChild[]> {
|
||||
const w = await webspace(ctx, parentRef); // prüft, dass es das Abonnement gibt; alle Abfragen sind auf dieses Abonnement gefiltert
|
||||
const sites = async () => {
|
||||
const op = await packet(ctx, xs('site', xs('get', x('filter', { 'parent-id': w.id }), xs('dataset', x('gen_info')))), false);
|
||||
return results(op, 'get', true).map((r) => { const gi = path(r, 'data', 'gen_info'); return { id: txt(r, 'id') ?? '', name: txt(gi, 'name') ?? '', status: txt(gi, 'status'), parent: txt(gi, 'webspace-id') }; })
|
||||
.filter((s) => s.id && (s.parent === null || s.parent === w.id));
|
||||
};
|
||||
if (kind === 'domain') {
|
||||
const list = await sites(); const all = [{ id: w.id, name: w.name, status: w.status }, ...list.filter((s) => s.id !== w.id)];
|
||||
const names = all.map((s) => s.name.toLowerCase());
|
||||
return all.map((s): NormalizedChild => ({ id: s.id, kind, name: s.name, state: s.status === null || s.status === '0' ? 'active' : 'disabled',
|
||||
details: { subdomain: names.some((n) => s.name.toLowerCase() !== n && s.name.toLowerCase().endsWith(`.${n}`)), system: false, main: s.id === w.id } }));
|
||||
}
|
||||
if (kind === 'email') {
|
||||
const siteList = [{ id: w.id, name: w.name }, ...(await sites()).filter((s) => s.id !== w.id)]; const out: NormalizedChild[] = [];
|
||||
for (const s of siteList) {
|
||||
const op = await packet(ctx, xs('mail', xs('get_info', x('filter', { 'site-id': s.id }), x('mailbox'))), false);
|
||||
for (const r of results(op, 'get_info', true)) for (const m of kids(r, 'mailname')) {
|
||||
const enabled = txt(path(m, 'mailbox'), 'enabled'); const quota = num(txt(path(m, 'mailbox'), 'quota'));
|
||||
out.push({ id: `${s.id}:${txt(m, 'id') ?? txt(m, 'name')}`, kind, name: `${txt(m, 'name')}@${s.name}`, state: enabled === 'false' ? 'disabled' : 'active', details: { maxSizeBytes: quota !== null && quota >= 0 ? quota : null, mailbox: enabled !== null } });
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
if (kind === 'database') {
|
||||
const op = await packet(ctx, xs('database', xs('get-db', x('filter', { 'webspace-id': w.id }))), false);
|
||||
// Ein leeres Ergebnis ohne id bedeutet „keine Datenbanken“ (an Plesk 18.0.81 beobachtet)
|
||||
return results(op, 'get-db', true).filter((r) => txt(r, 'id') && (txt(r, 'webspace-id') ?? w.id) === w.id).map((r) => ({ id: txt(r, 'id') ?? '', kind, name: txt(r, 'name') ?? '', state: 'active', details: { type: txt(r, 'type') } }));
|
||||
}
|
||||
if (kind === 'ftp') {
|
||||
const op = await packet(ctx, xs('ftp-user', xs('get', x('filter', { 'webspace-id': w.id }))), false);
|
||||
return results(op, 'get', true).filter((r) => txt(r, 'id') && (txt(r, 'webspace-id') ?? w.id) === w.id).map((r) => ({ id: txt(r, 'id') ?? '', kind, name: txt(r, 'name') ?? '', state: 'active', details: { home: txt(r, 'home') } }));
|
||||
}
|
||||
throw new ConnectorError('UNSUPPORTED', `${kind as ChildKind} wird bei Plesk noch nicht gelesen`);
|
||||
},
|
||||
async act() { throw new ConnectorError('UNSUPPORTED', 'Änderungen an Domains/Postfächern/Datenbanken sind für Plesk noch nicht freigeschaltet'); },
|
||||
// ---- Unterobjekte: Lesen und Ändern (an Plesk 18.0.81 geprüft) ----------------------------------------
|
||||
/** Weitere Domains (Sites) des Abonnements; Hauptdomain = das Abonnement selbst. */
|
||||
async function sitesOf(ctx: ConnectorContext, w: Webspace): Promise<{ id: string; name: string; status: string | null }[]> {
|
||||
const op = await packet(ctx, xs('site', xs('get', x('filter', { 'parent-id': w.id }), xs('dataset', x('gen_info')))), false);
|
||||
const extra = results(op, 'get', true).map((r) => { const gi = path(r, 'data', 'gen_info'); return { id: txt(r, 'id') ?? '', name: txt(gi, 'name') ?? '', status: txt(gi, 'status'), parent: txt(gi, 'webspace-id') }; })
|
||||
.filter((x0) => x0.id && x0.id !== w.id && (x0.parent === null || x0.parent === w.id));
|
||||
return [{ id: w.id, name: w.name, status: w.status }, ...extra];
|
||||
}
|
||||
const LOCAL_RE = /^[a-z0-9._+-]{1,64}$/i; const DBNAME_RE = /^[a-z0-9_]{1,64}$/; const FTPUSER_RE = /^[a-z0-9._-]{1,32}$/i;
|
||||
const str = (v: unknown, name: string, max = 200): string => { if (typeof v !== 'string' || !v.trim() || v.length > max || /[\0\r\n]/.test(v)) throw bad(`${name} fehlt oder ist ungültig`); return v.trim(); };
|
||||
const pw = (sec: Record<string, string> | undefined): string => { const p = sec?.password; if (!p || p.length < 8 || p.length > 128 || /[\0\r\n]/.test(p)) throw bad('Passwort fehlt oder ist ungültig (mindestens 8 Zeichen)'); return p; };
|
||||
const rand = (n = 6) => randomBytes(8).toString('hex').slice(0, n);
|
||||
/** FTP-/Web-Verzeichnis relativ zum Abonnement; "/www/" (KeyHelp-Standard der Oberfläche) wird zu /httpdocs. */
|
||||
const homeDir = (v: unknown): string => { const h = typeof v === 'string' && v.trim() ? v.trim() : '/httpdocs'; const n = h === '/www/' || h === '/www' ? '/httpdocs' : h; if (!/^\/[\w./-]{0,200}$/.test(n) || n.split('/').includes('..')) throw bad('Ungültiges Verzeichnis'); return n.replace(/\/+$/, '') || '/'; };
|
||||
async function dbList(ctx: ConnectorContext, w: Webspace) {
|
||||
const op = await packet(ctx, xs('database', xs('get-db', x('filter', { 'webspace-id': w.id }))), false);
|
||||
return results(op, 'get-db', true).filter((r) => txt(r, 'id') && (txt(r, 'webspace-id') ?? w.id) === w.id).map((r) => ({ id: txt(r, 'id')!, name: txt(r, 'name') ?? '', type: txt(r, 'type') }));
|
||||
}
|
||||
async function ftpList(ctx: ConnectorContext, w: Webspace) {
|
||||
const op = await packet(ctx, xs('ftp-user', xs('get', x('filter', { 'webspace-id': w.id }))), false);
|
||||
return results(op, 'get', true).filter((r) => txt(r, 'id') && (txt(r, 'webspace-id') ?? w.id) === w.id).map((r) => ({ id: txt(r, 'id')!, name: txt(r, 'name') ?? '', home: txt(r, 'home') }));
|
||||
}
|
||||
async function mailOf(ctx: ConnectorContext, siteId: string) {
|
||||
const op = await packet(ctx, xs('mail', xs('get_info', x('filter', { 'site-id': siteId }), x('mailbox'))), false);
|
||||
return results(op, 'get_info', true).flatMap((r) => kids(r, 'mailname')).map((m) => ({ id: txt(m, 'id') ?? '', name: txt(m, 'name') ?? '', enabled: txt(path(m, 'mailbox'), 'enabled'), quota: num(txt(path(m, 'mailbox'), 'quota')) }));
|
||||
}
|
||||
const toChild = {
|
||||
domain: (s0: { id: string; name: string; status: string | null }, names: string[], mainId: string): NormalizedChild => ({ id: s0.id, kind: 'domain', name: s0.name, state: s0.status === null || s0.status === '0' ? 'active' : 'disabled',
|
||||
details: { subdomain: names.some((n) => s0.name.toLowerCase() !== n && s0.name.toLowerCase().endsWith(`.${n}`)), system: false, main: s0.id === mainId } }),
|
||||
email: (site: { id: string; name: string }, m: { id: string; name: string; enabled: string | null; quota: number | null }): NormalizedChild => ({ id: `${site.id}:${m.id || m.name}`, kind: 'email', name: `${m.name}@${site.name}`, state: m.enabled === 'false' ? 'disabled' : 'active', details: { maxSizeBytes: m.quota !== null && m.quota >= 0 ? m.quota : null, mailbox: m.enabled !== null } }),
|
||||
database: (d: { id: string; name: string; type: string | null }): NormalizedChild => ({ id: d.id, kind: 'database', name: d.name, state: 'active', details: { type: d.type, user: d.name.slice(0, 16) } }),
|
||||
ftp: (f: { id: string; name: string; home: string | null }): NormalizedChild => ({ id: f.id, kind: 'ftp', name: f.name, state: 'active', details: { home: f.home } }),
|
||||
};
|
||||
|
||||
const capabilities: Capability[] = ['customers.list', 'catalog.list', 'resources.list', 'resources.get', 'status.read', 'usage.read', 'lifecycle.create', 'lifecycle.suspend', 'lifecycle.unsuspend', 'lifecycle.terminate', 'plan.change', 'sso.login', 'children.read', 'panel.password_reset'];
|
||||
const children: ChildAccess = {
|
||||
async kinds() { return [{ kind: 'domain', canWrite: true }, { kind: 'email', canWrite: true }, { kind: 'database', canWrite: true }, { kind: 'ftp', canWrite: true }]; },
|
||||
async list(ctx, parentRef, kind): Promise<NormalizedChild[]> {
|
||||
const w = await webspace(ctx, parentRef); // alle Abfragen sind auf dieses Abonnement gefiltert
|
||||
if (kind === 'domain') { const all = await sitesOf(ctx, w); const names = all.map((s0) => s0.name.toLowerCase()); return all.map((s0) => toChild.domain(s0, names, w.id)); }
|
||||
if (kind === 'email') { const out: NormalizedChild[] = []; for (const site of await sitesOf(ctx, w)) for (const m of await mailOf(ctx, site.id)) out.push(toChild.email(site, m)); return out; }
|
||||
if (kind === 'database') return (await dbList(ctx, w)).map(toChild.database);
|
||||
if (kind === 'ftp') return (await ftpList(ctx, w)).map(toChild.ftp);
|
||||
throw new ConnectorError('UNSUPPORTED', `${kind as ChildKind} wird bei Plesk nicht unterstützt`);
|
||||
},
|
||||
/**
|
||||
* Anlegen/Ändern/Löschen. Mandantentrennung: Der Secret Key ist ein Administratorzugang, deshalb wird VOR jeder Änderung geprüft,
|
||||
* dass das Objekt zum Abonnement gehört; neue Objekte werden immer im Abonnement angelegt. Anlegen ist wiederholbar (gleicher Name im
|
||||
* selben Abonnement = schon angelegt), Löschen ist idempotent (schon weg = Ziel erreicht).
|
||||
*/
|
||||
async act(ctx, req) {
|
||||
const { kind, op } = req; const d = req.data ?? {};
|
||||
const w = await webspace(ctx, req.parentRef);
|
||||
if (kind === 'domain') {
|
||||
const all = await sitesOf(ctx, w); const names = all.map((s0) => s0.name.toLowerCase());
|
||||
if (op === 'delete') {
|
||||
const s0 = all.find((x0) => x0.id === String(req.id ?? '')); if (!s0) return {};
|
||||
if (s0.id === w.id) throw bad('Die Hauptdomain des Abonnements kann hier nicht gelöscht werden');
|
||||
results(await packet(ctx, xs('site', xs('del', x('filter', { id: s0.id }))), true), 'del', true); return {};
|
||||
}
|
||||
if (op === 'update') throw new ConnectorError('UNSUPPORTED', 'Domain-Einstellungen bitte im Plesk-Panel ändern');
|
||||
const name = str(d.domain, 'Domain', 253).toLowerCase(); if (!DOMAIN_RE.test(name)) throw bad('Ungültiger Domainname');
|
||||
const mine = all.find((s0) => s0.name.toLowerCase() === name); if (mine) return { child: toChild.domain(mine, names, w.id) };
|
||||
const add = xs('site', xs('add', x('gen_setup', { name, 'webspace-id': w.id }), xs('hosting', xs('vrt_hst', x('property', { name: 'www_root', value: name })))));
|
||||
const r = await packet(ctx, add, true); const ar = results(r, 'add');
|
||||
const id = txt(one(ar), 'id'); if (!id) throw new ConnectorError('INVALID_RESPONSE', 'keine Domain-ID');
|
||||
const after = await sitesOf(ctx, w); const s0 = after.find((x0) => x0.id === id); if (!s0) throw new ConnectorError('INVALID_RESPONSE', 'Domain nach dem Anlegen nicht im Abonnement');
|
||||
return { child: toChild.domain(s0, after.map((x0) => x0.name.toLowerCase()), w.id) };
|
||||
}
|
||||
if (kind === 'email') {
|
||||
const sites = await sitesOf(ctx, w);
|
||||
if (op === 'delete' || op === 'update') {
|
||||
const [siteId, mailId] = String(req.id ?? '').split(':'); const site = sites.find((x0) => x0.id === siteId); if (!site) { if (op === 'delete') return {}; throw new ConnectorError('NOT_FOUND'); }
|
||||
const m = (await mailOf(ctx, site.id)).find((x0) => x0.id === mailId || x0.name === mailId); if (!m) { if (op === 'delete') return {}; throw new ConnectorError('NOT_FOUND'); }
|
||||
if (op === 'delete') { results(await packet(ctx, xs('mail', xs('remove', x('filter', { 'site-id': site.id, name: m.name }))), true), 'remove', true); return {}; }
|
||||
const parts: string[] = [x('name', m.name)];
|
||||
if (d.maxSizeBytes !== undefined) { const n = Number(d.maxSizeBytes); if (!Number.isInteger(n) || n < -1) throw bad('Postfachgröße ungültig'); parts.push(x('mailbox', { enabled: true, quota: n })); }
|
||||
if (req.secrets?.password) parts.push(x('password', { value: pw(req.secrets), type: 'plain' }));
|
||||
if (parts.length === 1) throw bad('Keine Änderung angegeben');
|
||||
results(await packet(ctx, xs('mail', xs('update', xs('set', xs('filter', x('site-id', site.id), xs('mailname', ...parts))))), true), 'update', false);
|
||||
const m2 = (await mailOf(ctx, site.id)).find((x0) => x0.name === m.name)!; return { child: toChild.email(site, m2) };
|
||||
}
|
||||
const local = str(d.local, 'Postfach', 64).toLowerCase(); const dom = str(d.domain, 'Domain', 253).toLowerCase(); if (!LOCAL_RE.test(local) || !DOMAIN_RE.test(dom)) throw bad('Ungültige E-Mail-Adresse');
|
||||
const site = sites.find((x0) => x0.name.toLowerCase() === dom); if (!site) throw bad('Die Domain gehört nicht zu diesem Abonnement');
|
||||
const ex = (await mailOf(ctx, site.id)).find((x0) => x0.name.toLowerCase() === local); if (ex) return { child: toChild.email(site, ex) };
|
||||
const mb: Record<string, unknown> = { enabled: true }; if (d.maxSizeBytes !== undefined) { const n = Number(d.maxSizeBytes); if (!Number.isInteger(n) || n < 0) throw bad('Postfachgröße ungültig'); mb.quota = n; }
|
||||
try { results(await packet(ctx, xs('mail', xs('create', xs('filter', x('site-id', site.id), xs('mailname', x('name', local), x('mailbox', mb as never), x('password', { value: pw(req.secrets), type: 'plain' }))))), true), 'create'); }
|
||||
catch (e) {
|
||||
// Plesk legt das Postfach teils an und meldet DANACH einen Fehler (z. B. Größe über dem Plan-Limit): halben Zustand zurückrollen
|
||||
if (e instanceof ConnectorError && e.code === 'INVALID_INPUT' && (await mailOf(ctx, site.id)).some((x0) => x0.name.toLowerCase() === local))
|
||||
await packet(ctx, xs('mail', xs('remove', x('filter', { 'site-id': site.id, name: local }))), true).catch(() => undefined);
|
||||
throw e;
|
||||
}
|
||||
const m = (await mailOf(ctx, site.id)).find((x0) => x0.name.toLowerCase() === local); if (!m) throw new ConnectorError('INVALID_RESPONSE', 'Postfach nach dem Anlegen nicht gefunden');
|
||||
return { child: toChild.email(site, m) };
|
||||
}
|
||||
if (kind === 'database') {
|
||||
const list = await dbList(ctx, w);
|
||||
if (op === 'delete') { const db = list.find((x0) => x0.id === String(req.id ?? '')); if (!db) return {}; results(await packet(ctx, xs('database', xs('del-db', x('filter', { id: db.id }))), true), 'del-db', true); return {}; }
|
||||
if (op === 'update') {
|
||||
const db = list.find((x0) => x0.id === String(req.id ?? '')); if (!db) throw new ConnectorError('NOT_FOUND');
|
||||
const users = results(await packet(ctx, xs('database', xs('get-db-users', x('filter', { 'db-id': db.id }))), false), 'get-db-users', true).filter((r) => txt(r, 'id'));
|
||||
const u = users[0]; if (!u) throw new ConnectorError('NOT_FOUND', 'Kein Datenbankbenutzer');
|
||||
results(await packet(ctx, xs('database', xs('set-db-user', x('id', txt(u, 'id')), x('password', pw(req.secrets)))), true), 'set-db-user'); // set-db-user erwartet <id> direkt (kein <filter>)
|
||||
return { child: toChild.database(db) };
|
||||
}
|
||||
const given = d.name === undefined || d.name === '' ? undefined : str(d.name, 'Datenbankname', 64).toLowerCase(); if (given && !DBNAME_RE.test(given)) throw bad('Datenbankname: nur a-z, 0-9 und Unterstrich');
|
||||
const name = given ?? `db_${rand()}`; const password = pw(req.secrets);
|
||||
let db = list.find((x0) => x0.name === name);
|
||||
if (!db) {
|
||||
const id = txt(one(results(await packet(ctx, xs('database', xs('add-db', x('webspace-id', w.id), x('name', name), x('type', 'mysql'))), true), 'add-db')), 'id');
|
||||
if (!id) throw new ConnectorError('INVALID_RESPONSE', 'keine Datenbank-ID'); db = { id, name, type: 'mysql' };
|
||||
}
|
||||
const users = results(await packet(ctx, xs('database', xs('get-db-users', x('filter', { 'db-id': db.id }))), false), 'get-db-users', true).filter((r) => txt(r, 'id'));
|
||||
if (!users.length) results(await packet(ctx, xs('database', xs('add-db-user', x('db-id', db.id), x('login', name.slice(0, 16)), x('password', password))), true), 'add-db-user');
|
||||
return { child: toChild.database(db) };
|
||||
}
|
||||
if (kind === 'ftp') {
|
||||
const list = await ftpList(ctx, w);
|
||||
if (op === 'delete') { const f = list.find((x0) => x0.id === String(req.id ?? '')); if (!f) return {}; results(await packet(ctx, xs('ftp-user', xs('del', x('filter', { id: f.id }))), true), 'del', true); return {}; }
|
||||
if (op === 'update') {
|
||||
const f = list.find((x0) => x0.id === String(req.id ?? '')); if (!f) throw new ConnectorError('NOT_FOUND');
|
||||
const v: Record<string, unknown> = {}; if (req.secrets?.password) v.password = pw(req.secrets); if (d.home !== undefined) { v.home = homeDir(d.home); v['create-non-existent'] = true; } if (!Object.keys(v).length) throw bad('Keine Änderung angegeben');
|
||||
results(await packet(ctx, xs('ftp-user', xs('set', x('filter', { id: f.id }), x('values', v as never))), true), 'set');
|
||||
return { child: toChild.ftp((await ftpList(ctx, w)).find((x0) => x0.id === f.id) ?? f) };
|
||||
}
|
||||
const given = d.username === undefined || d.username === '' ? undefined : str(d.username, 'FTP-Benutzer', 32); if (given && !FTPUSER_RE.test(given)) throw bad('FTP-Benutzername ungültig');
|
||||
const name = given ?? `ftp${rand()}`; const ex = list.find((x0) => x0.name === name); if (ex) return { child: toChild.ftp(ex) };
|
||||
results(await packet(ctx, xs('ftp-user', xs('add', x('name', name), x('password', pw(req.secrets)), x('home', homeDir(d.home)), x('create-non-existent', true), x('webspace-id', w.id))), true), 'add');
|
||||
const f = (await ftpList(ctx, w)).find((x0) => x0.name === name); if (!f) throw new ConnectorError('INVALID_RESPONSE', 'FTP-Zugang nach dem Anlegen nicht gefunden');
|
||||
return { child: toChild.ftp(f) };
|
||||
}
|
||||
throw new ConnectorError('UNSUPPORTED', `${kind} wird bei Plesk nicht unterstützt`);
|
||||
},
|
||||
};
|
||||
|
||||
const capabilities: Capability[] = ['customers.list', 'catalog.list', 'resources.list', 'resources.get', 'status.read', 'usage.read', 'lifecycle.create', 'lifecycle.suspend', 'lifecycle.unsuspend', 'lifecycle.terminate', 'plan.change', 'sso.login', 'children.read', 'children.write', 'panel.password_reset'];
|
||||
|
||||
return {
|
||||
contractVersion: CONTRACT_VERSION, key: 'plesk', displayName: 'Plesk (Webhosting)',
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import { esc, kid, kids, parseXml, path, txt, type XNode } from '../src/xml.js';
|
|||
type Row = Record<string, any>;
|
||||
export interface Fake {
|
||||
fetch: typeof fetch;
|
||||
state: { customers: Row[]; webspaces: Row[]; plans: Row[]; sites: Row[]; mail: Row[]; dbs: Row[]; ftp: Row[]; sessions: string[] };
|
||||
state: { customers: Row[]; webspaces: Row[]; plans: Row[]; sites: Row[]; mail: Row[]; dbs: Row[]; dbUsers: Row[]; ftp: Row[]; sessions: string[] };
|
||||
calls: { op: string; body: string; key?: string }[];
|
||||
opts: { fail503: number };
|
||||
}
|
||||
|
|
@ -37,6 +37,7 @@ export function createFake(secret = 'test-secret'): Fake {
|
|||
mail: [{ id: 41, site: 21, name: 'info', enabled: true, quota: 1073741824, passwd: 'GEHEIM-MAIL' }, { id: 42, site: 32, name: 'post', enabled: false, quota: -1 }, { id: 43, site: 23, name: 'bernd', enabled: true, quota: -1 }],
|
||||
dbs: [{ id: 51, ws: 21, name: 'alpha_wp', type: 'mysql' }, { id: 52, ws: 23, name: 'beta_db', type: 'mysql' }],
|
||||
ftp: [{ id: 61, ws: 21, name: 'alpha_dev', home: '/httpdocs' }, { id: 62, ws: 23, name: 'beta_ftp', home: '/' }],
|
||||
dbUsers: [{ id: 71, db: 51, login: 'alpha_wp', passwd: 'GEHEIM-DB' }],
|
||||
sessions: [],
|
||||
};
|
||||
const calls: Fake['calls'] = []; const opts: Fake['opts'] = { fail503: 0 };
|
||||
|
|
@ -108,6 +109,52 @@ export function createFake(secret = 'test-secret'): Fake {
|
|||
// Echtes Plesk liefert bei 0 Treffern ein leeres <result><status>ok</status></result> (an 18.0.81 beobachtet)
|
||||
if (o === 'database' && n === 'get-db') { const f = filt(operation); const l = state.dbs.filter((d) => String(d.ws) === f.ws); return wrap(l.length ? l.map((d) => ok(`${v('id', d.id)}${v('name', d.name)}${v('type', d.type)}${v('webspace-id', d.ws)}`)).join('') : ok('')); }
|
||||
if (o === 'ftp-user' && n === 'get') { const f = filt(operation); const l = state.ftp.filter((u) => String(u.ws) === f.ws); return wrap(l.length ? l.map((u) => ok(`${v('id', u.id)}${v('name', u.name)}${v('home', u.home)}${v('webspace-id', u.ws)}`)).join('') : ok('')); }
|
||||
// ---- Schreiben (Verhalten an Plesk 18.0.81 beobachtet: Elementnamen, Limits als 1024, Teilanlage bei Postfachgröße) ----
|
||||
const limitErr = (what: string) => wrap(errR('1024', `There are no available resources of this type (${what}) left. Requested: 1; available: 0.`));
|
||||
if (o === 'site' && n === 'add') {
|
||||
const gs = kid(operation, 'gen_setup'); const name = txt(gs, 'name')!; const ws = Number(txt(gs, 'webspace-id')); const w = state.webspaces.find((x0) => x0.id === ws); if (!w) return wrap(errR('1013', 'Webspace does not exist'));
|
||||
const lim = state.plans.find((p) => p.guid === w.plan)?.limits.max_site ?? -1; if (lim >= 0 && 1 + state.sites.filter((x0) => x0.parent === ws).length >= lim) return limitErr('sites');
|
||||
if (state.sites.some((x0) => x0.name === name) || state.webspaces.some((x0) => x0.name === name)) return wrap(errR('1007', 'Domain already exists'));
|
||||
const site = { id: ++seq, name, parent: ws, status: 0 }; state.sites.push(site); return wrap(ok(v('id', site.id)));
|
||||
}
|
||||
if (o === 'site' && n === 'del') { const f = filt(operation); const i = state.sites.findIndex((x0) => String(x0.id) === f.id); if (i < 0) return wrap(errR('1013', 'Site does not exist')); state.sites.splice(i, 1); return wrap(ok(v('id', f.id))); }
|
||||
if (o === 'mail' && n === 'create') {
|
||||
const f = kid(operation, 'filter'); const site = txt(f, 'site-id'); const mn = kid(f, 'mailname'); const name = txt(mn, 'name')!; const quota = Number(txt(path(mn, 'mailbox'), 'quota') ?? -1);
|
||||
if (!txt(path(mn, 'password'), 'value')) return wrap(errR('1019', 'password required'));
|
||||
if (state.mail.some((m) => String(m.site) === site && m.name === name)) return wrap(errR('1007', 'Mailname already exists'));
|
||||
const m = { id: ++seq, site: Number(site), name, enabled: true, quota: -1, passwd: txt(path(mn, 'password'), 'value') }; state.mail.push(m); // Plesk legt an …
|
||||
if (quota > 10 * 1024 ** 3) return wrap(errR('1024', 'Unable to set the mailbox size limit for the domain: The size of this mailbox must not exceed the limit')); // … und meldet DANN den Fehler
|
||||
m.quota = quota; return wrap(ok(`<mailname>${v('id', m.id)}${v('name', m.name)}</mailname>`));
|
||||
}
|
||||
if (o === 'mail' && n === 'remove') { const f = kid(operation, 'filter'); const i = state.mail.findIndex((m) => String(m.site) === txt(f, 'site-id') && m.name === txt(f, 'name')); if (i < 0) return wrap(errR('1013', 'Mailname does not exist')); state.mail.splice(i, 1); return wrap(ok('')); }
|
||||
if (o === 'mail' && n === 'update') {
|
||||
const f = path(operation, 'set', 'filter'); const mn = kid(f, 'mailname'); const m = state.mail.find((x0) => String(x0.site) === txt(f, 'site-id') && x0.name === txt(mn, 'name')); if (!m) return wrap(errR('1013', 'Mailname does not exist'));
|
||||
const p0 = txt(path(mn, 'password'), 'value'); if (p0) m.passwd = p0; const q = txt(path(mn, 'mailbox'), 'quota'); if (q !== null) m.quota = Number(q); return wrap(ok(''));
|
||||
}
|
||||
if (o === 'database' && n === 'add-db') {
|
||||
const ws = Number(txt(operation, 'webspace-id')); const name = txt(operation, 'name')!; if (state.dbs.some((d) => d.name === name)) return wrap(errR('1007', 'Database already exists'));
|
||||
const d = { id: ++seq, ws, name, type: txt(operation, 'type') }; state.dbs.push(d); return wrap(ok(v('id', d.id)));
|
||||
}
|
||||
if (o === 'database' && n === 'get-db-users') { const f = filt(operation); const dbId = txt(kid(operation, 'filter'), 'db-id'); void f; const l = state.dbUsers.filter((u) => String(u.db) === dbId); return wrap(l.length ? l.map((u) => ok(`${v('id', u.id)}${v('login', u.login)}${v('db-id', u.db)}`)).join('') : ok('')); }
|
||||
if (o === 'database' && n === 'add-db-user') { const u = { id: ++seq, db: Number(txt(operation, 'db-id')), login: txt(operation, 'login'), passwd: txt(operation, 'password') }; state.dbUsers.push(u); return wrap(ok(v('id', u.id))); }
|
||||
if (o === 'database' && n === 'set-db-user') {
|
||||
if (operation.children[0]?.name !== 'id') return wrap(errR('1014', "Parser error: Element 'filter': This element is not expected. Expected is ( id )."));
|
||||
const u = state.dbUsers.find((x0) => String(x0.id) === txt(operation, 'id')); if (!u) return wrap(errR('1013', 'User does not exist')); u.passwd = txt(operation, 'password'); return wrap(ok(v('id', u.id)));
|
||||
}
|
||||
if (o === 'database' && n === 'del-db') { const f = filt(operation); const i = state.dbs.findIndex((d) => String(d.id) === f.id); if (i < 0) return wrap(errR('1013', 'Database does not exist')); const [d] = state.dbs.splice(i, 1); state.dbUsers = state.dbUsers.filter((u) => u.db !== d!.id); return wrap(ok(v('id', f.id))); }
|
||||
const badFtpEl = (node: XNode | undefined) => (node?.children ?? []).some((c) => c.name === 'create_non_existent');
|
||||
if (o === 'ftp-user' && n === 'add') {
|
||||
if (badFtpEl(operation)) return wrap(errR('1014', "Parser error: Element 'create_non_existent': This element is not expected."));
|
||||
const name = txt(operation, 'name')!; if (state.ftp.some((u) => u.name === name)) return wrap(errR('1007', 'FTP user already exists'));
|
||||
const u = { id: ++seq, ws: Number(txt(operation, 'webspace-id')), name, home: txt(operation, 'home'), passwd: txt(operation, 'password') }; state.ftp.push(u); return wrap(ok(v('id', u.id)));
|
||||
}
|
||||
if (o === 'ftp-user' && n === 'set') {
|
||||
const f = filt(operation); const vals = kid(operation, 'values'); if (badFtpEl(vals)) return wrap(errR('1014', "Parser error: Element 'create_non_existent': This element is not expected."));
|
||||
const u = state.ftp.find((x0) => String(x0.id) === f.id); if (!u) return wrap(errR('1013', 'FTP user does not exist'));
|
||||
const h = txt(vals, 'home'); if (h && h !== '/httpdocs' && txt(vals, 'create-non-existent') !== 'true') return wrap(errR('1013', 'Home path does not exist'));
|
||||
if (h) u.home = h; const p0 = txt(vals, 'password'); if (p0) u.passwd = p0; return wrap(ok(v('id', u.id)));
|
||||
}
|
||||
if (o === 'ftp-user' && n === 'del') { const f = filt(operation); const i = state.ftp.findIndex((u) => String(u.id) === f.id); if (i < 0) return wrap(errR('1013', 'FTP user does not exist')); state.ftp.splice(i, 1); return wrap(ok(v('id', f.id))); }
|
||||
return wrap(errR('1014', `unbekannte Operation ${o}/${n}`));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ describe('Plesk-Connector: Bereitstellung und Aktionen', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('Plesk-Connector: Unterobjekte (nur lesen, nur eigenes Abonnement)', () => {
|
||||
describe('Plesk-Connector: Unterobjekte lesen (nur eigenes Abonnement)', () => {
|
||||
it('Domains, Postfächer, Datenbanken und FTP des Abonnements', async () => {
|
||||
const c = mk(createFake());
|
||||
expect((await c.children!.list(ctx(), '21', 'domain')).map((d) => [d.name, d.details.subdomain, d.details.main])).toEqual([['alpha.test', false, true], ['blog.alpha.test', true, false], ['alpha-zwei.test', false, false]]);
|
||||
|
|
@ -117,7 +117,6 @@ describe('Plesk-Connector: Unterobjekte (nur lesen, nur eigenes Abonnement)', ()
|
|||
expect((await c.children!.list(ctx(), '21', 'database')).map((d) => d.name)).toEqual(['alpha_wp']);
|
||||
expect((await c.children!.list(ctx(), '21', 'ftp')).map((d) => d.name)).toEqual(['alpha_dev']);
|
||||
const all = JSON.stringify(await c.children!.list(ctx(), '23', 'email')); expect(all).toMatch(/bernd@beta\.test/); expect(all).not.toMatch(/alpha|GEHEIM/);
|
||||
expect(await code(c.children!.act(ctx(), { parentRef: '21', kind: 'email', op: 'create', data: {}, idempotencyKey: 'x' }))).toBe('UNSUPPORTED');
|
||||
expect(await code(c.children!.list(ctx(), '../21', 'domain'))).toBe('NOT_FOUND');
|
||||
expect(await c.children!.list(ctx(), '22', 'database')).toEqual([]); expect(await c.children!.list(ctx(), '22', 'ftp')).toEqual([]); // leeres Ergebnis = keine Einträge
|
||||
});
|
||||
|
|
@ -135,3 +134,60 @@ describe('Plesk-Connector: Konfiguration und Fehler', () => {
|
|||
expect(f.calls.every((k) => k.key === 'test-secret' && !k.body.includes('test-secret'))).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Plesk-Connector: Unterobjekte ändern (Verhalten wie Plesk 18.0.81)', () => {
|
||||
const PW = { password: 'Sicheres-Pw-1' };
|
||||
const act = (c: ReturnType<typeof mk>, req: Record<string, unknown>) => c.children!.act(ctx(), { parentRef: '21', idempotencyKey: 'k', data: {}, ...req } as never);
|
||||
it('Domain: anlegen (wiederholbar), Plan-Limit als klare Ablehnung, löschen (idempotent), Hauptdomain geschützt', async () => {
|
||||
const f = createFake(); f.state.plans[0]!.limits.max_site = 4; const c = mk(f);
|
||||
const d = (await act(c, { kind: 'domain', op: 'create', data: { domain: 'neu.alpha.test' } })).child!;
|
||||
expect(d).toMatchObject({ name: 'neu.alpha.test', details: { subdomain: true, main: false } });
|
||||
expect((await act(c, { kind: 'domain', op: 'create', data: { domain: 'neu.alpha.test' } })).child!.id).toBe(d.id);
|
||||
expect(f.calls.find((k) => k.op === 'site/add')!.body).toMatch(/<gen_setup><name>neu\.alpha\.test<\/name><webspace-id>21<\/webspace-id><\/gen_setup>/);
|
||||
f.state.plans[0]!.limits.max_site = 2;
|
||||
const e = await act(c, { kind: 'domain', op: 'create', data: { domain: 'voll.alpha.test' } }).catch((x0) => x0);
|
||||
expect(e).toBeInstanceOf(ConnectorError); expect(e.code).toBe('INVALID_INPUT'); expect(e.retryable).toBe(false); expect(e.message).toMatch(/no available resources/);
|
||||
await act(c, { kind: 'domain', op: 'delete', id: d.id }); expect(f.state.sites.some((s) => String(s.id) === d.id)).toBe(false);
|
||||
expect(await code(act(c, { kind: 'domain', op: 'delete', id: d.id }))).toBe('OK');
|
||||
expect(await code(act(c, { kind: 'domain', op: 'delete', id: '21' }))).toBe('INVALID_INPUT');
|
||||
expect(await code(act(c, { kind: 'domain', op: 'delete', id: '33' }))).toBe('OK'); expect(f.state.sites.some((s) => s.id === 33)).toBe(true); // fremde Site bleibt unberührt
|
||||
});
|
||||
it('Postfach: anlegen nur auf eigenen Domains, Passwort/Größe ändern, löschen; Teilanlage bei Größenfehler wird zurückgerollt', async () => {
|
||||
const f = createFake(); const c = mk(f);
|
||||
const m = (await act(c, { kind: 'email', op: 'create', data: { local: 'Kontakt', domain: 'alpha.test', maxSizeBytes: 1048576 }, secrets: PW })).child!;
|
||||
expect(m).toMatchObject({ name: 'kontakt@alpha.test', details: { maxSizeBytes: 1048576 } });
|
||||
expect(f.calls.find((k) => k.op === 'mail/create')!.body).toMatch(/<mailname><name>kontakt<\/name><mailbox><enabled>true<\/enabled><quota>1048576<\/quota><\/mailbox><password><value>Sicheres-Pw-1<\/value><type>plain<\/type><\/password><\/mailname>/);
|
||||
await act(c, { kind: 'email', op: 'update', id: m.id, secrets: { password: 'Neues-Pw-12' } }); expect(f.state.mail.find((x0) => x0.name === 'kontakt')!.passwd).toBe('Neues-Pw-12');
|
||||
expect(await code(act(c, { kind: 'email', op: 'create', data: { local: 'x', domain: 'beta.test' }, secrets: PW }))).toBe('INVALID_INPUT'); // Domain eines anderen Kunden
|
||||
expect(await code(act(c, { kind: 'email', op: 'create', data: { local: 'gross', domain: 'alpha.test', maxSizeBytes: 50 * 1024 ** 3 }, secrets: PW }))).toBe('INVALID_INPUT');
|
||||
expect(f.state.mail.some((x0) => x0.name === 'gross')).toBe(false); // nichts Halbes zurückgelassen
|
||||
await act(c, { kind: 'email', op: 'delete', id: m.id }); expect(f.state.mail.some((x0) => x0.name === 'kontakt')).toBe(false);
|
||||
expect(await code(act(c, { kind: 'email', op: 'delete', id: m.id }))).toBe('OK');
|
||||
expect(await code(act(c, { kind: 'email', op: 'create', data: { local: 'ohne', domain: 'alpha.test' } }))).toBe('INVALID_INPUT'); // Passwort fehlt
|
||||
});
|
||||
it('Datenbank: anlegen mit Benutzer (wiederholbar), Passwort über set-db-user <id>, löschen nur im eigenen Abonnement', async () => {
|
||||
const f = createFake(); const c = mk(f);
|
||||
const d = (await act(c, { kind: 'database', op: 'create', data: { name: 'alpha_shop' }, secrets: PW })).child!;
|
||||
expect(d).toMatchObject({ name: 'alpha_shop', details: { user: 'alpha_shop' } }); expect(f.state.dbUsers.filter((u) => String(u.db) === d.id)).toHaveLength(1);
|
||||
await act(c, { kind: 'database', op: 'create', data: { name: 'alpha_shop' }, secrets: PW }); expect(f.state.dbUsers.filter((u) => String(u.db) === d.id)).toHaveLength(1);
|
||||
await act(c, { kind: 'database', op: 'update', id: d.id, secrets: { password: 'Db-Neu-1234' } }); expect(f.state.dbUsers.find((u) => String(u.db) === d.id)!.passwd).toBe('Db-Neu-1234');
|
||||
expect(await code(act(c, { kind: 'database', op: 'create', data: { name: 'Böse;DROP' }, secrets: PW }))).toBe('INVALID_INPUT');
|
||||
expect((await act(c, { kind: 'database', op: 'create', data: {}, secrets: PW })).child!.name).toMatch(/^db_[0-9a-f]{6}$/);
|
||||
await act(c, { kind: 'database', op: 'delete', id: '52' }); expect(f.state.dbs.some((x0) => x0.id === 52)).toBe(true); // fremde Datenbank bleibt
|
||||
await act(c, { kind: 'database', op: 'delete', id: d.id }); expect(f.state.dbs.some((x0) => String(x0.id) === d.id)).toBe(false);
|
||||
});
|
||||
it('FTP: /www/ → /httpdocs, neues Verzeichnis mit create-non-existent, automatischer Name, löschen', async () => {
|
||||
const f = createFake(); const c = mk(f);
|
||||
const u = (await act(c, { kind: 'ftp', op: 'create', data: { username: 'alpha_shop', home: '/www/' }, secrets: PW })).child!;
|
||||
expect(u).toMatchObject({ name: 'alpha_shop', details: { home: '/httpdocs' } });
|
||||
expect((await act(c, { kind: 'ftp', op: 'update', id: u.id, data: { home: '/httpdocs/shop' }, secrets: { password: 'Ftp-Neu-123' } })).child!.details.home).toBe('/httpdocs/shop');
|
||||
expect(await code(act(c, { kind: 'ftp', op: 'update', id: u.id, data: { home: '/../etc' } }))).toBe('INVALID_INPUT');
|
||||
expect((await act(c, { kind: 'ftp', op: 'create', data: {}, secrets: PW })).child!.name).toMatch(/^ftp[0-9a-f]{6}$/);
|
||||
await act(c, { kind: 'ftp', op: 'delete', id: '62' }); expect(f.state.ftp.some((x0) => x0.id === 62)).toBe(true); // fremder FTP-Zugang bleibt
|
||||
await act(c, { kind: 'ftp', op: 'delete', id: u.id }); expect(f.state.ftp.some((x0) => String(x0.id) === u.id)).toBe(false);
|
||||
});
|
||||
it('meldet Schreibrechte für alle Arten', async () => {
|
||||
expect((await mk(createFake()).children!.kinds(ctx(), '21')).every((k) => k.canWrite)).toBe(true);
|
||||
expect(mk(createFake()).capabilities(ctx())).toContain('children.write');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue