update server

This commit is contained in:
2026-07-30 15:06:38 +08:00
parent dee13d69d5
commit 692d8dd18a
9 changed files with 189 additions and 479 deletions
+28
View File
@@ -619,6 +619,34 @@ test("issued licenses can be listed, validated, and revoked", async () => {
assert.equal(rejected.status, "revoked");
});
test("revokeLicense returns actionable errors and accepts legacy request fields", async () => {
const invalidToken = await post({
type: "revokeLicense", licenseId: crypto.randomUUID(), adminToken: "wrong-token"
});
assert.deepEqual(invalidToken, {
success: false, errMsg: "B端管理令牌无效", errCode: "ADMIN_TOKEN_INVALID"
});
const missingLicenseId = await post({ type: "revokeLicense", licenseId: " ", adminToken: "test-token" });
assert.deepEqual(missingLicenseId, {
success: false, errMsg: "licenseId 不能为空", errCode: "LICENSE_ID_REQUIRED"
});
const notFound = await post({
type: "revokeLicense", licenseId: crypto.randomUUID(), adminToken: "test-token"
});
assert.deepEqual(notFound, {
success: false, errMsg: "许可证不存在", errCode: "LICENSE_NOT_FOUND"
});
const legacy = await post({
type: "revoke_license", license_id: " ", admin_token: "test-token"
});
assert.deepEqual(legacy, {
success: false, errMsg: "licenseId 不能为空", errCode: "LICENSE_ID_REQUIRED"
});
});
test("license creation verifies the signed payload and validates expiry in real time", async () => {
const company = await post({
type: "createCompany", name: "安全校验公司", code: "security-co", adminToken: "test-token"