修复:调整游客取号限流策略
问题:移动网络共享出口 IP 会造成游客取号被误限流。 实现:移除公开取号 IP 限制,改用项目总量与手机号 HMAC 限流,并支持 Retry-After 倒计时。
This commit is contained in:
@@ -106,6 +106,22 @@ describe("public visitor lookup", () => {
|
||||
expect(response.ticket.party_size).toBe(4);
|
||||
expect(response.public_token).toBe("visitor-token");
|
||||
});
|
||||
|
||||
it("exposes Retry-After for rate-limited ticket requests", async () => {
|
||||
const fetchMock = vi.fn().mockResolvedValue(new Response(JSON.stringify({
|
||||
error: { code: "PUBLIC_TICKET_RATE_LIMITED", message: "取号次数过多,请稍后再试" },
|
||||
}), {
|
||||
status: 429,
|
||||
headers: { "Content-Type": "application/json", "Retry-After": "17" },
|
||||
}));
|
||||
vi.stubGlobal("fetch", fetchMock);
|
||||
|
||||
await expect(api.publicCreateTicket("project-1", { phone: "13800138000", party_size: 1 })).rejects.toMatchObject({
|
||||
code: "PUBLIC_TICKET_RATE_LIMITED",
|
||||
status: 429,
|
||||
retryAfterSeconds: 17,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("public display overview", () => {
|
||||
|
||||
Reference in New Issue
Block a user