Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+47
@@ -0,0 +1,47 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
validateCsrf: vi.fn(),
|
||||
requireIdentity: vi.fn(),
|
||||
revokeSession: vi.fn(),
|
||||
clearCookie: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("~/services/customer-portal/portal-csrf.server", () => ({
|
||||
validatePortalCsrfToken: (...args: unknown[]) => mocks.validateCsrf(...args),
|
||||
}));
|
||||
vi.mock("~/services/customer-portal/portal-data.server", () => ({
|
||||
portalNotFound: () => new Response(null, { status: 404 }),
|
||||
requirePortalSessionIdentity: (...args: unknown[]) => mocks.requireIdentity(...args),
|
||||
revokePortalSession: (...args: unknown[]) => mocks.revokeSession(...args),
|
||||
}));
|
||||
vi.mock("~/services/customer-portal/portal-session-cookie.server", () => ({
|
||||
clearPortalSessionCookie: (...args: unknown[]) => mocks.clearCookie(...args),
|
||||
}));
|
||||
|
||||
import { action } from "./logout";
|
||||
|
||||
describe("customer portal logout", () => {
|
||||
it("passes the authenticated request into the atomic revoke-and-audit boundary", async () => {
|
||||
const identity = { tenantSlug: "acme", tenantId: "tenant_1", portalUserId: "portal_user_1", portalSessionId: "session_1" };
|
||||
const request = new Request("https://portal.hivegrid.test/acme/logout", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"content-type": "application/x-www-form-urlencoded",
|
||||
"x-hivegrid-portal-origin": "https://portal.hivegrid.test",
|
||||
"x-hivegrid-portal-tenant": "acme",
|
||||
"x-request-id": "logout-request-1",
|
||||
},
|
||||
body: "csrf=token",
|
||||
});
|
||||
mocks.requireIdentity.mockResolvedValue(identity);
|
||||
mocks.revokeSession.mockResolvedValue(undefined);
|
||||
mocks.clearCookie.mockResolvedValue("__Host-hivegrid_portal_session=; Max-Age=0");
|
||||
|
||||
await expect(action({ request, params: { tenant: "acme" }, context: {} } as never)).rejects.toMatchObject({ status: 302 });
|
||||
|
||||
expect(mocks.validateCsrf).toHaveBeenCalledOnce();
|
||||
expect(mocks.revokeSession).toHaveBeenCalledWith(identity, request);
|
||||
expect(mocks.clearCookie).toHaveBeenCalledOnce();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user