자료관 로그인 복귀 및 원앤올 프록시 대기시간 반영

This commit is contained in:
2026-12-05 11:18:07 +09:00
parent 3ef863e329
commit cb1b4c19fe
8 changed files with 276 additions and 43 deletions
@@ -116,6 +116,39 @@ describe("DC login API proxy", () => {
expect(cookieSet).toHaveBeenCalledWith("refresh-token", "refresh-token-value", { httpOnly: true, sameSite: "lax", path: "/" });
});
it("forwards the ingress IP, device and refresh cookie to the user service on PUT", async () => {
cookieGet.mockReturnValue({ value: "fixture-refresh" });
const upstream = vi.fn<typeof fetch>().mockResolvedValue(new Response(null, {
headers: { "access-token": "fixture-renewed", "token-id": "fixture-user" },
}));
vi.stubGlobal("fetch", upstream);
const { PUT } = await import("./route");
const url = ["user-service", "api", "v1", "users", "token", "refresh"];
const response = await PUT(new Request(`https://frontend.example/api/proxy/${url.join("/")}`, {
method: "PUT",
headers: {
"X-Real-IP": "2001:db8::25",
"X-Client-IP": "192.0.2.99",
"X-Device-Id": "fixture-device",
},
}), { params: Promise.resolve({ url }) });
expect(cookieGet).toHaveBeenCalledWith("refresh-token");
expect(upstream).toHaveBeenCalledOnce();
expect(upstream).toHaveBeenCalledWith(
"https://backend.example/user-service/api/v1/users/token/refresh",
expect.objectContaining({ method: "PUT" }),
);
const options = upstream.mock.calls[0]?.[1];
const headers = new Headers(options?.headers);
expect(headers.get("x-client-ip")).toBe("2001:db8::25");
expect(headers.get("x-device-id")).toBe("fixture-device");
expect(headers.get("authorization")).toBe("fixture-refresh");
expect(options?.body).toBeUndefined();
expect(response.status).toBe(200);
expect(await response.json()).toEqual({ "access-token": "fixture-renewed", "token-id": "fixture-user" });
});
it("omits absent device and ingress identity headers, even if a client IP was supplied", async () => {
const fetchMock = vi.fn().mockResolvedValue(
new Response(null, {