From d8254c4f1d438ec9fcca2aab14443705f3941b9b Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Mon, 14 Sep 2026 13:48:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client-test-env-acceptance-contract.test.mjs | 13 +++++++++++++ scripts/client-test-env-acceptance.mjs | 14 +++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 scripts/client-test-env-acceptance-contract.test.mjs diff --git a/scripts/client-test-env-acceptance-contract.test.mjs b/scripts/client-test-env-acceptance-contract.test.mjs new file mode 100644 index 000000000..576890d63 --- /dev/null +++ b/scripts/client-test-env-acceptance-contract.test.mjs @@ -0,0 +1,13 @@ +import test from 'node:test' +import assert from 'node:assert/strict' +import { readFile } from 'node:fs/promises' + +const source = await readFile(new URL('./client-test-env-acceptance.mjs', import.meta.url), 'utf8') + +test('client registration distinguishes incomplete-registration replay from credential conflicts', () => { + assert.match(source, /same credentials replay the incomplete registration/) + assert.match(source, /\['accountId', 'tenantId', 'membershipId'\]/) + assert.match(source, /String\(json\.data\[field\]\), String\(registration\.json\.data\[field\]\)/) + assert.match(source, /duplicate username with different credentials is rejected/) + assert.match(source, /body: \{ \.\.\.registrationBody, password: `Different/) +}) diff --git a/scripts/client-test-env-acceptance.mjs b/scripts/client-test-env-acceptance.mjs index 380fe7493..ad6943a31 100644 --- a/scripts/client-test-env-acceptance.mjs +++ b/scripts/client-test-env-acceptance.mjs @@ -142,8 +142,20 @@ async function registrationModule() { report.resources.tenantId = registration.json.data.tenantId report.resources.membershipId = registration.json.data.membershipId - await apiStep('registration', 'duplicate username is rejected', { + await apiStep('registration', 'same credentials replay the incomplete registration without creating another customer', { method: 'POST', path: '/api/auth/register', body: registrationBody, + }, ({ json }) => { + requireSuccess(json) + for (const field of ['accountId', 'tenantId', 'membershipId']) { + assertPresent(json.data?.[field], field) + assertEqual(String(json.data[field]), String(registration.json.data[field]), `replayed ${field}`) + } + assertEqual(json.data?.tenantStatus, 'PROFILE_REQUIRED', 'replayed tenantStatus') + }) + + await apiStep('registration', 'duplicate username with different credentials is rejected', { + method: 'POST', path: '/api/auth/register', + body: { ...registrationBody, password: `Different${randomUUID()}9!` }, }, ({ json, status }) => { assertEqual(status, 200, 'HTTP status') assertEqual(String(json?.code), 'A0409', 'business code')