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
+32
@@ -0,0 +1,32 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
vi.mock("~/services/auth/session-handoff.server", () => ({ consumeSessionHandoff: vi.fn() }));
|
||||
|
||||
import { consumeSessionHandoff } from "~/services/auth/session-handoff.server";
|
||||
import { loader } from "./auth.session-handoff";
|
||||
|
||||
describe("session handoff route", () => {
|
||||
it("returns the completed host-only session response", async () => {
|
||||
const completed = new Response(null, { status: 302, headers: { Location: "/acme/dashboard" } });
|
||||
vi.mocked(consumeSessionHandoff).mockResolvedValueOnce(completed);
|
||||
const request = new Request("https://app.example.test/auth/session-handoff?code=opaque-code");
|
||||
|
||||
await expect(loader({ request, params: {}, context: {} } as never)).resolves.toBe(completed);
|
||||
expect(consumeSessionHandoff).toHaveBeenCalledWith(request, "opaque-code");
|
||||
});
|
||||
|
||||
it("redirects invalid or replayed codes without reflecting them", async () => {
|
||||
vi.mocked(consumeSessionHandoff).mockResolvedValueOnce(null);
|
||||
const response = await loader({
|
||||
request: new Request("https://app.example.test/auth/session-handoff?code=secret-replayed-code"),
|
||||
params: {},
|
||||
context: {},
|
||||
} as never);
|
||||
|
||||
expect(response.status).toBe(302);
|
||||
expect(response.headers.get("Location")).toBe("/login?error=session_handoff_invalid");
|
||||
expect(response.headers.get("Location")).not.toContain("secret-replayed-code");
|
||||
expect(response.headers.get("Cache-Control")).toBe("no-store");
|
||||
expect(response.headers.get("Referrer-Policy")).toBe("no-referrer");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user