MCPcopy Create free account
hub / github.com/langgenius/dify / ceRegisterAccount

Function ceRegisterAccount

cli/test/e2e/setup/global-setup.ts:316–347  ·  view source on GitHub ↗

* Register a CE account idempotently. * Tries /init (fresh server) first, then falls back to /register. * A 409 "already exists" response is treated as success.

(consoleBase: string, email: string, password: string)

Source from the content-addressed store, hash-verified

314 * A 409 "already exists" response is treated as success.
315 */
316async function ceRegisterAccount(consoleBase: string, email: string, password: string): Promise<void> {
317 const passwordB64 = Buffer.from(password, 'utf8').toString('base64')
318 const name = email.split('@')[0] ?? 'e2e-user'
319
320 const initRes = await fetch(`${consoleBase}/console/api/init`, {
321 method: 'POST',
322 headers: { 'Content-Type': 'application/json' },
323 body: JSON.stringify({ email, name, password: passwordB64 }),
324 signal: AbortSignal.timeout(15_000),
325 })
326
327 if (initRes.ok || initRes.status === 409) {
328 console.warn(`[E2E CE] Account ready via /init (status ${initRes.status})`)
329 return
330 }
331
332 const registerRes = await fetch(`${consoleBase}/console/api/register`, {
333 method: 'POST',
334 headers: { 'Content-Type': 'application/json' },
335 body: JSON.stringify({ email, name, password: passwordB64 }),
336 signal: AbortSignal.timeout(15_000),
337 })
338
339 if (!registerRes.ok && registerRes.status !== 409) {
340 console.warn(
341 `[E2E CE] /register returned HTTP ${registerRes.status} — account may already exist; continuing`,
342 )
343 }
344 else {
345 console.warn(`[E2E CE] Account ready via /register (status ${registerRes.status})`)
346 }
347}
348
349// ══════════════════════════════════════════════════════════════════════════════
350// Shared helpers

Callers 1

setupFunction · 0.85

Calls 5

fetchFunction · 0.85
toStringMethod · 0.45
fromMethod · 0.45
splitMethod · 0.45
warnMethod · 0.45

Tested by

no test coverage detected