Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
+22
-2
@@ -4,8 +4,8 @@
|
||||
*/
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
vi.mock("@toolctrl/config", async () => {
|
||||
const actual = await vi.importActual<typeof import("@toolctrl/config")>("@toolctrl/config");
|
||||
vi.mock("@hivegrid/config", async () => {
|
||||
const actual = await vi.importActual<typeof import("@hivegrid/config")>("@hivegrid/config");
|
||||
return {
|
||||
...actual,
|
||||
loadRequiredWebConfig: () => ({ nodeEnv: "test", sessionSecret: "test-session-secret-please-change" }),
|
||||
@@ -32,6 +32,7 @@ import {
|
||||
clearTrustedDeviceCookie,
|
||||
forgetCurrentTrustedDevice,
|
||||
isTrustedDevice,
|
||||
listTrustedDevices,
|
||||
rememberDeviceForUser,
|
||||
revokeAllTrustedDevices,
|
||||
revokeTrustedDevice,
|
||||
@@ -128,6 +129,25 @@ describe("trusted-device (DB-backed)", () => {
|
||||
expect(findUnique).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("lists active trusted devices scoped to the owner, newest-used first", async () => {
|
||||
const rows = [activeRow({ id: "td-1" }), activeRow({ id: "td-2" })];
|
||||
vi.mocked(db.trustedDevice.findMany).mockResolvedValue(rows as never);
|
||||
|
||||
await expect(listTrustedDevices("user-1")).resolves.toEqual(rows);
|
||||
expect(db.trustedDevice.findMany).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
where: expect.objectContaining({ userId: "user-1", revokedAt: null }),
|
||||
orderBy: { lastUsedAt: "desc" },
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("treats a database failure during the trust lookup as not-trusted", async () => {
|
||||
const request = await rememberAndGetRequest("user-1");
|
||||
findUnique.mockRejectedValue(new Error("db unavailable"));
|
||||
await expect(isTrustedDevice(request, "user-1")).resolves.toBe(false);
|
||||
});
|
||||
|
||||
it("revokes a single device scoped to the owner", async () => {
|
||||
updateMany.mockResolvedValue({ count: 1 } as never);
|
||||
await expect(revokeTrustedDevice({ userId: "user-1", deviceId: "td-1" })).resolves.toBe(true);
|
||||
|
||||
Reference in new issue
Block a user