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
@@ -10,13 +10,21 @@ import {
|
||||
type LegacyLoginUserReaderClient,
|
||||
type LegacyUserWithoutPasswordReaderClient,
|
||||
} from "./users.server.js";
|
||||
import { getRlsExecutionContext } from "./rls-context.server.js";
|
||||
|
||||
describe("findLegacyAuthUserById", () => {
|
||||
it("fetches only the legacy auth user fields by id", async () => {
|
||||
const findUnique = vi.fn().mockResolvedValue({
|
||||
id: "user_123",
|
||||
email: "user@example.com",
|
||||
passwordHash: "should-not-leak",
|
||||
const findUnique = vi.fn().mockImplementation(async () => {
|
||||
expect(getRlsExecutionContext()?.userId).toBe("user_123");
|
||||
return {
|
||||
id: "user_123",
|
||||
email: "user@example.com",
|
||||
totpEnabledAt: null,
|
||||
pendingDeletion: false,
|
||||
pseudonymized: false,
|
||||
active: true,
|
||||
passwordHash: "should-not-leak",
|
||||
};
|
||||
});
|
||||
const client = {
|
||||
user: { findUnique },
|
||||
@@ -25,10 +33,21 @@ describe("findLegacyAuthUserById", () => {
|
||||
await expect(findLegacyAuthUserById("user_123", client)).resolves.toEqual({
|
||||
id: "user_123",
|
||||
email: "user@example.com",
|
||||
totpEnabledAt: null,
|
||||
pendingDeletion: false,
|
||||
pseudonymized: false,
|
||||
active: true,
|
||||
});
|
||||
expect(findUnique).toHaveBeenCalledWith({
|
||||
where: { id: "user_123" },
|
||||
select: { id: true, email: true },
|
||||
select: {
|
||||
id: true,
|
||||
email: true,
|
||||
totpEnabledAt: true,
|
||||
pendingDeletion: true,
|
||||
pseudonymized: true,
|
||||
active: true,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -43,13 +62,22 @@ describe("findLegacyAuthUserById", () => {
|
||||
});
|
||||
|
||||
it("fetches only the legacy login user fields by email", async () => {
|
||||
const findUnique = vi.fn().mockResolvedValue({
|
||||
id: "user_123",
|
||||
email: "user@example.com",
|
||||
passwordHash: "hash",
|
||||
firstName: "should-not-leak",
|
||||
const findUnique = vi.fn().mockImplementation(async () => {
|
||||
expect(getRlsExecutionContext()?.userId).toBe("user_123");
|
||||
return {
|
||||
id: "user_123",
|
||||
email: "user@example.com",
|
||||
passwordHash: "hash",
|
||||
totpEnabledAt: new Date("2026-07-12T00:00:00.000Z"),
|
||||
pendingDeletion: false,
|
||||
pseudonymized: false,
|
||||
active: true,
|
||||
firstName: "should-not-leak",
|
||||
};
|
||||
});
|
||||
const queryRaw = vi.fn().mockResolvedValue([{ tenant_id: null, resource_id: "user_123", user_id: "user_123" }]);
|
||||
const client = {
|
||||
$queryRaw: queryRaw,
|
||||
user: { findUnique },
|
||||
} as unknown as LegacyLoginUserReaderClient;
|
||||
|
||||
@@ -57,21 +85,36 @@ describe("findLegacyAuthUserById", () => {
|
||||
id: "user_123",
|
||||
email: "user@example.com",
|
||||
passwordHash: "hash",
|
||||
totpEnabledAt: new Date("2026-07-12T00:00:00.000Z"),
|
||||
pendingDeletion: false,
|
||||
pseudonymized: false,
|
||||
active: true,
|
||||
});
|
||||
expect(findUnique).toHaveBeenCalledWith({
|
||||
where: { email: "user@example.com" },
|
||||
select: { id: true, email: true, passwordHash: true },
|
||||
where: { id: "user_123" },
|
||||
select: {
|
||||
id: true,
|
||||
email: true,
|
||||
passwordHash: true,
|
||||
totpEnabledAt: true,
|
||||
pendingDeletion: true,
|
||||
pseudonymized: true,
|
||||
active: true,
|
||||
},
|
||||
});
|
||||
expect(queryRaw).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it("returns null when the login user does not exist", async () => {
|
||||
const client: LegacyLoginUserReaderClient = {
|
||||
const client = {
|
||||
$queryRaw: vi.fn().mockResolvedValue([]),
|
||||
user: {
|
||||
findUnique: vi.fn().mockResolvedValue(null),
|
||||
},
|
||||
};
|
||||
} as unknown as LegacyLoginUserReaderClient;
|
||||
|
||||
await expect(findLegacyLoginUserByEmail("missing@example.com", client)).resolves.toBeNull();
|
||||
expect(client.user.findUnique).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("fetches the legacy user fields required by API bearer auth", async () => {
|
||||
@@ -89,10 +132,11 @@ describe("findLegacyAuthUserById", () => {
|
||||
};
|
||||
const findUnique = vi.fn().mockResolvedValue(user);
|
||||
const client = {
|
||||
adminUser: { findUnique: vi.fn().mockResolvedValue(null) },
|
||||
user: { findUnique },
|
||||
} as unknown as LegacyUserWithoutPasswordReaderClient;
|
||||
|
||||
await expect(findLegacyUserWithoutPasswordById("user_123", client)).resolves.toBe(user);
|
||||
await expect(findLegacyUserWithoutPasswordById("user_123", client)).resolves.toEqual(user);
|
||||
expect(findUnique).toHaveBeenCalledWith({
|
||||
where: { id: "user_123" },
|
||||
select: {
|
||||
@@ -102,7 +146,6 @@ describe("findLegacyAuthUserById", () => {
|
||||
lastName: true,
|
||||
avatar: true,
|
||||
phone: true,
|
||||
admin: true,
|
||||
defaultTenantId: true,
|
||||
createdAt: true,
|
||||
locale: true,
|
||||
@@ -113,6 +156,9 @@ describe("findLegacyAuthUserById", () => {
|
||||
|
||||
it("returns null when no legacy user id is provided", async () => {
|
||||
const client: LegacyUserWithoutPasswordReaderClient = {
|
||||
adminUser: {
|
||||
findUnique: vi.fn(),
|
||||
},
|
||||
user: {
|
||||
findUnique: vi.fn(),
|
||||
},
|
||||
@@ -123,7 +169,10 @@ describe("findLegacyAuthUserById", () => {
|
||||
});
|
||||
|
||||
it("records legacy login logs", async () => {
|
||||
const create = vi.fn().mockResolvedValue({});
|
||||
const create = vi.fn().mockImplementation(async () => {
|
||||
expect(getRlsExecutionContext()?.userId).toBe("user_123");
|
||||
return {};
|
||||
});
|
||||
const client: LegacyLoginLogWriterClient = {
|
||||
log: { create },
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user