Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
test(alerts): cover the alerts API against Postgres instead of a faked DAL
Calvinb7eeb00551dc
diff --git a/backend/e2e-test/routes/v1/alerts.spec.ts b/backend/e2e-test/routes/v1/alerts.spec.tsnew file mode 100644index 0000000000..718acde1be--- /dev/null+++ b/backend/e2e-test/routes/v1/alerts.spec.ts@@ -0,0 +1,129 @@+import { OrgMembershipRole, ProjectMembershipRole } from "@app/db/schemas";++import { createAlert, deleteAlert, getAlert, listAlerts, updateAlert } from "../../testUtils/alerts";+import { createIsolatedOrgAndProject } from "../../testUtils/fixtures";+import { addIdentityToProject, createIdentityActor } from "../../testUtils/identities";+import { addUserMembership, createUser, deleteUsers } from "../../testUtils/users";++const RESOURCE_TYPE = "identity.authentication";+const EVENT_TYPE = "identity.authentication.expiry";++describe("Alerts API", () => {+ let orgId: string;+ let projectId: string;+ let authToken: string;+ let cleanup: () => Promise<void>;+ let recipient: { userId: string; username: string };+ let identityId: string;++ beforeEach(async () => {+ ({ orgId, projectId, authToken, cleanup } = await createIsolatedOrgAndProject("alerts"));+ recipient = await createUser("alert-recipient");+ await addUserMembership({ userId: recipient.userId, orgId, role: OrgMembershipRole.Member });+ await addUserMembership({ userId: recipient.userId, orgId, projectId, role: ProjectMembershipRole.Member });+ ({ identityId } = await createIdentityActor({ orgId, authToken }));+ await addIdentityToProject({ projectId, identityId, role: ProjectMembershipRole.Admin, authToken });+ });++ afterEach(async () => {+ await cleanup();+ await deleteUsers([recipient.userId]);+ });++ const emailChannel = () => ({+ name: "Email",+ channelType: "email",+ config: {},+ recipients: [{ principalType: "user", principalId: recipient.userId }]+ });+ const webhookChannel = { name: "Webhook", channelType: "webhook", config: { url: "https://example.com/hook" } };++ const identityAlert = (opts: { name: string; projectId?: string; channels?: Record<string, unknown>[] }) => ({+ name: opts.name,+ resourceType: RESOURCE_TYPE,+ resourceId: identityId,+ eventType: EVENT_TYPE,+ condition: { alertBefore: "30d" },+ ...(opts.projectId ? { projectId: opts.projectId } : {}),+ channels: opts.channels ?? [emailChannel()]+ });++ test("an org listing returns only org-level alerts, and a project listing only that project's", async () => {+ const orgAlert = await createAlert({ body: identityAlert({ name: "org-level" }), authToken });+ const projectAlert = await createAlert({ body: identityAlert({ name: "project-level", projectId }), authToken });++ const orgListing = await listAlerts({ resourceType: RESOURCE_TYPE, authToken });+ expect(orgListing.map((alert) => alert.id)).toEqual([orgAlert.id]);++ const projectListing = await listAlerts({ resourceType: RESOURCE_TYPE, projectId, authToken });+ expect(projectListing.map((alert) => alert.id)).toEqual([projectAlert.id]);+ });++ // The API cannot show a channel that no alert references, so the channel rows are read directly.+ test("updating channels keeps the ones referenced, removes the rest, and adds new ones", async () => {+ const alert = await createAlert({+ body: identityAlert({ name: "reconcile", channels: [emailChannel(), webhookChannel] }),+ authToken+ });+ const email = alert.channels.find((channel) => channel.channelType === "email")!;+ const webhook = alert.channels.find((channel) => channel.channelType === "webhook")!;++ const updated = await updateAlert({+ alertId: alert.id,+ authToken,+ body: {+ channels: [+ { id: email.id, name: "Renamed email", channelType: "email" },+ { name: "Slack", channelType: "slack", config: { webhookUrl: "https://hooks.slack.com/services/T0/B0/x" } }+ ]+ }+ });++ expect(updated.channels.map((channel) => channel.channelType).sort()).toEqual(["email", "slack"]);+ const keptEmail = updated.channels.find((channel) => channel.channelType === "email")!;+ expect(keptEmail).toMatchObject({ id: email.id, name: "Renamed email" });+ expect(keptEmail.recipients).toEqual([{ principalType: "user", principalId: recipient.userId }]);+ expect(await testDb("alert_channels").where({ id: webhook.id })).toHaveLength(0);+ });++ test("updating with another alert's channel id is refused", async () => {+ const first = await createAlert({ body: identityAlert({ name: "first" }), authToken });+ const second = await createAlert({ body: identityAlert({ name: "second", projectId }), authToken });++ const res = await updateAlert({+ alertId: first.id,+ authToken,+ body: { channels: [{ id: second.channels[0].id, name: "Stolen", channelType: "email" }] }+ }).raw();++ expect(res.statusCode).toBe(400);+ expect(res.json().message).toBe(`Channel '${second.channels[0].id}' does not belong to this alert`);+ expect((await getAlert({ alertId: second.id, authToken })).channels.map((channel) => channel.id)).toEqual([+ second.channels[0].id+ ]);+ });++ // As above, the channel and recipient rows of a deleted alert are only visible in the database.+ test("deleting an alert removes its channels and their recipients", async () => {+ const alert = await createAlert({+ body: identityAlert({ name: "delete", channels: [emailChannel(), webhookChannel] }),+ authToken+ });+ const channelIds = alert.channels.map((channel) => channel.id);++ await deleteAlert({ alertId: alert.id, authToken });++ expect((await getAlert({ alertId: alert.id, authToken }).raw()).statusCode).toBe(404);+ expect(await testDb("alert_channels").whereIn("id", channelIds)).toHaveLength(0);+ expect(await testDb("alert_channel_recipients").whereIn("channelId", channelIds)).toHaveLength(0);+ });++ test("two concurrent creates of the same alert leave one, and the other gets a readable error", async () => {+ const body = identityAlert({ name: "concurrent" });+ const results = await Promise.all([createAlert({ body, authToken }).raw(), createAlert({ body, authToken }).raw()]);++ expect(results.map((res) => res.statusCode).sort()).toEqual([200, 400]);+ expect(results.find((res) => res.statusCode === 400)?.json().message).toMatch(/already exists/);+ expect(await listAlerts({ resourceType: RESOURCE_TYPE, resourceId: identityId, authToken })).toHaveLength(1);+ });+});diff --git a/backend/e2e-test/testUtils/alerts.ts b/backend/e2e-test/testUtils/alerts.tsindex 53369f3e85..cca63b15db 100644--- a/backend/e2e-test/testUtils/alerts.ts+++ b/backend/e2e-test/testUtils/alerts.ts@@ -1,8 +1,11 @@+import { LightMyRequestResponse } from "fastify";+import { request } from "./request";type TAlertRecord = {id: string;name: string;+ projectId: string | null;channels: {id: string;name: string;@@ -12,13 +15,43 @@ type TAlertRecord = {}[];};-export const listAlerts = (dto: { resourceType: string; projectId: string; resourceId: string; authToken: string }) =>+const parseAlert = (res: LightMyRequestResponse) => {+ expect(res.statusCode).toBe(200);+ return res.json<{ alert: TAlertRecord }>().alert;+};++export const createAlert = (dto: { body: Record<string, unknown>; authToken: string }) =>+ request(+ {+ method: "POST",+ url: "/api/v1/alerts",+ headers: { authorization: `Bearer ${dto.authToken}` },+ body: dto.body+ },+ parseAlert+ );++export const getAlert = (dto: { alertId: string; authToken: string }) =>+ request(+ {+ method: "GET",+ url: `/api/v1/alerts/${dto.alertId}`,+ headers: { authorization: `Bearer ${dto.authToken}` }+ },+ parseAlert+ );++export const listAlerts = (dto: { resourceType: string; projectId?: string; resourceId?: string; authToken: string }) =>request({method: "GET",url: "/api/v1/alerts",headers: { authorization: `Bearer ${dto.authToken}` },- query: { resourceType: dto.resourceType, projectId: dto.projectId, resourceId: dto.resourceId }+ query: {+ resourceType: dto.resourceType,+ ...(dto.projectId ? { projectId: dto.projectId } : {}),+ ...(dto.resourceId ? { resourceId: dto.resourceId } : {})+ }},(res) => {expect(res.statusCode).toBe(200);@@ -34,8 +67,17 @@ export const updateAlert = (dto: { alertId: string; body: Record<string, unknownheaders: { authorization: `Bearer ${dto.authToken}` },body: dto.body},+ parseAlert+ );++export const deleteAlert = (dto: { alertId: string; authToken: string }) =>+ request(+ {+ method: "DELETE",+ url: `/api/v1/alerts/${dto.alertId}`,+ headers: { authorization: `Bearer ${dto.authToken}` }+ },(res) => {expect(res.statusCode).toBe(200);- return res.json<{ alert: TAlertRecord }>().alert;});diff --git a/backend/src/services/alert/alert-recipient-resolver.ts b/backend/src/services/alert/alert-recipient-resolver.tsindex 7ac4dee7c7..3ef64a6aa3 100644--- a/backend/src/services/alert/alert-recipient-resolver.ts+++ b/backend/src/services/alert/alert-recipient-resolver.ts@@ -65,7 +65,7 @@ export const alertRecipientResolverFactory = ({recipient.principalType === AlertPrincipalType.PROJECT_MEMBERS && recipient.principalId === scope.projectId));- const projectMemberIds: string[] = [];+ const projectMemberIds = new Set<string>();if (wantsProjectMembers && scope.projectId) {// Direct members and members through a project group, so "everyone in the project" matches who// the scope check below lets through.@@ -74,7 +74,7 @@ export const alertRecipientResolverFactory = ({groupProjectDAL.findAllProjectGroupMembers(scope.projectId)]);[...directMembers, ...projectGroupMembers].forEach((member) => {- projectMemberIds.push(member.user.id);+ projectMemberIds.add(member.user.id);allUserIds.add(member.user.id);});}diff --git a/backend/src/services/alert/alert-service.test.ts b/backend/src/services/alert/alert-service.test.tsindex 7d01baaf0b..dcb9bf3d6e 100644--- a/backend/src/services/alert/alert-service.test.ts+++ b/backend/src/services/alert/alert-service.test.ts@@ -28,9 +28,6 @@ const buildService = (opts?: {resourceScopeThrows?: boolean;duplicateExists?: boolean;createError?: Error;- // Runs right after a find() has taken its snapshot, to stand in for a concurrent transaction- // committing between two statements of ours.- afterFindAlerts?: (alerts: Map<string, Record<string, unknown>>) => void;}) => {const permissionCalls: TAlertPermissionInput[] = [];const provider: IResourceAlertProvider = {@@ -66,7 +63,6 @@ const buildService = (opts?: {const alerts = new Map<string, Record<string, unknown>>();const channels = new Map<string, TChannelRow>(); // channelId -> rowconst memberships = new Map<string, string[]>(); // alertId -> channelIds- const findFilters: Array<Record<string, unknown>> = [];const createTxs: unknown[] = [];let transactionsOpened = 0;let channelSeq = 0;@@ -106,12 +102,6 @@ const buildService = (opts?: {return row;},findActiveById: async (id: string) => alerts.get(id),- findActiveByScope: async (filter: Record<string, unknown>) => {- findFilters.push(filter);- return [...alerts.values()].filter((row) =>- Object.entries(filter).every(([key, value]) => value === undefined || row[key] === value)- );- },findScopedDuplicate: async () => (opts?.duplicateExists ? { id: "dup" } : undefined),updateById: async (id: string, data: Record<string, unknown>) => {// Mirror knex, which throws "Empty .update() call detected!" on an empty patch.@@ -120,17 +110,7 @@ const buildService = (opts?: {return alerts.get(id);},deleteById: async (id: string) => alerts.delete(id),- find: async (filter: Record<string, unknown>) => {- findFilters.push(filter);- const rows = [...alerts.values()].filter((row) => matches(row, filter));- opts?.afterFindAlerts?.(alerts);- return rows;- },- update: async (filter: Record<string, unknown>, data: Record<string, unknown>) => {- const updated = [...alerts.values()].filter((row) => matches(row, filter));- updated.forEach((row) => alerts.set(row.id as string, { ...row, ...data }));- return updated;- },+ find: async (filter: Record<string, unknown>) => [...alerts.values()].filter((row) => matches(row, filter)),delete: async (filter: Record<string, unknown>) => {const removed = [...alerts.values()].filter((row) => matches(row, filter));removed.forEach((row) => alerts.delete(row.id as string));@@ -231,8 +211,6 @@ const buildService = (opts?: {permissionCalls,alerts,memberships,- channels,- findFilters,createTxs,transactionsOpened: () => transactionsOpened};@@ -383,74 +361,6 @@ describe("alert service", () => {);});- const listBase = {- resourceType: RESOURCE_TYPE,- resourceId: null,- eventType: "test.resource.expiration",- condition: null,- enabled: true,- orgId: "org-1",- createdAt: new Date(),- updatedAt: new Date()- };-- test("org-scoped list returns only org-level alerts, never other projects'", async () => {- const { service, alerts, findFilters } = buildService();- alerts.set("org-alert", { id: "org-alert", name: "org", projectId: null, ...listBase });- alerts.set("proj-alert", { id: "proj-alert", name: "proj", projectId: "proj-x", ...listBase });-- const result = await service.listAlerts({ resourceType: RESOURCE_TYPE, ...actor });-- expect(result.map((a) => a.id)).toEqual(["org-alert"]);- expect(findFilters[0]).toMatchObject({ projectId: null });- });-- test("project-scoped list filters to the requested project", async () => {- const { service, alerts, findFilters } = buildService();- alerts.set("org-alert", { id: "org-alert", name: "org", projectId: null, ...listBase });- alerts.set("proj-alert", { id: "proj-alert", name: "proj", projectId: "proj-x", ...listBase });-- const result = await service.listAlerts({ resourceType: RESOURCE_TYPE, projectId: "proj-x", ...actor });-- expect(result.map((a) => a.id)).toEqual(["proj-alert"]);- expect(findFilters[0]).toMatchObject({ projectId: "proj-x" });- });-- test("update reconciles channels: keeps the referenced ones, deletes the rest, adds new", async () => {- const { service, memberships } = buildService();- const created = await service.createAlert(validCreate);- expect(memberships.get("alert-1")).toHaveLength(2);-- const keep = created.channels.find((c) => c.channelType === AlertChannelType.WEBHOOK)!;- const updated = await service.updateAlert({- alertId: "alert-1",- channels: [- { id: keep.id, name: keep.name, channelType: AlertChannelType.WEBHOOK },- { name: "new-slack", channelType: AlertChannelType.SLACK }- ],- ...actor- });-- expect(updated.channels.map((c) => c.channelType).sort()).toEqual([- AlertChannelType.SLACK,- AlertChannelType.WEBHOOK- ]);- expect(memberships.get("alert-1")).toContain(keep.id);- expect(memberships.get("alert-1")).toHaveLength(2);- });-- test("update rejects a channel id that does not belong to the alert", async () => {- const { service } = buildService();- await service.createAlert(validCreate);- await expect(- service.updateAlert({- alertId: "alert-1",- channels: [{ id: "ch-foreign", name: "x", channelType: AlertChannelType.WEBHOOK }],- ...actor- })- ).rejects.toThrow(/does not belong to this alert/);- });-test("update rejects an empty channel list", async () => {const { service } = buildService();await service.createAlert(validCreate);@@ -459,233 +369,13 @@ describe("alert service", () => {);});- test("deletes an alert and its owned channels after checking Delete permission", async () => {- const { service, permissionCalls, alerts, channels } = buildService();+ test("checks Delete permission before deleting an alert", async () => {+ const { service, permissionCalls } = buildService();await service.createAlert(validCreate);- expect(channels.size).toBe(2);-- const result = await service.deleteAlert({ alertId: "alert-1", ...actor });-- expect(result.id).toBe("alert-1");- expect(permissionCalls.some((c) => c.action === "delete")).toBe(true);- expect(alerts.size).toBe(0);- // Same reaping as deleteAlertsForResource: no channel is left dangling.- expect(channels.size).toBe(0);- });- test("deleteAlertsForResource reaps a resource's alerts and their owned channels", async () => {- const { service, alerts, channels, memberships } = buildService();- await service.createAlert({ ...validCreate, resourceId: "ident-1" });- expect(alerts.size).toBe(1);- expect(channels.size).toBe(2);+ await service.deleteAlert({ alertId: "alert-1", ...actor });- const deleted = await service.deleteAlertsForResource({- orgId: "org-1",- resourceType: RESOURCE_TYPE,- resourceId: "ident-1"- });-- expect(deleted).toBe(1);- expect(alerts.size).toBe(0);- // The alert's two inline channels are removed too, not left dangling.- expect(channels.size).toBe(0);- expect(memberships.get("alert-1") ?? []).toHaveLength(0);- });-- test("deleteAlertsForResource narrowed to a project spares the resource's org-scoped alerts", async () => {- const { service, alerts } = buildService();- await service.createAlert({ ...validCreate, resourceId: "ident-1" });- // A second alert on the same identity, this one bound to a project. Inserted directly because- // the fake create() always mints "alert-1".- alerts.set("alert-2", {- id: "alert-2",- orgId: "org-1",- projectId: "proj-1",- resourceType: RESOURCE_TYPE,- resourceId: "ident-1",- eventType: "test.resource.expiration"- });-- // The identity only left proj-1, so its org-scoped alert must survive.- const deleted = await service.deleteAlertsForResource({- orgId: "org-1",- projectId: "proj-1",- resourceType: RESOURCE_TYPE,- resourceId: "ident-1"- });-- expect(deleted).toBe(1);- expect([...alerts.keys()]).toEqual(["alert-1"]);- });-- test("deleteAlertsForResource is a no-op when nothing matches", async () => {- const { service, alerts } = buildService();- await service.createAlert({ ...validCreate, resourceId: "ident-1" });-- const deleted = await service.deleteAlertsForResource({- orgId: "org-1",- resourceType: RESOURCE_TYPE,- resourceId: "ident-other"- });-- expect(deleted).toBe(0);- expect(alerts.size).toBe(1);- });-- test("deleteAlertsForResource leaves the resource's alerts in other orgs alone", async () => {- const { service, alerts } = buildService();- await service.createAlert({ ...validCreate, resourceId: "ident-1" });- // The same identity watched from a second org it was invited into. Inserted directly because- // the fake create() always mints "alert-1".- alerts.set("alert-2", {- id: "alert-2",- orgId: "org-2",- projectId: null,- resourceType: RESOURCE_TYPE,- resourceId: "ident-1",- eventType: "test.resource.expiration"- });-- const deleted = await service.deleteAlertsForResource({- orgId: "org-1",- resourceType: RESOURCE_TYPE,- resourceId: "ident-1"- });-- expect(deleted).toBe(1);- expect([...alerts.keys()]).toEqual(["alert-2"]);- });-- test("deleteAlertsForDeletedResource reaps the resource's alerts in every org and project", async () => {- const { service, alerts, channels } = buildService();- await service.createAlert({ ...validCreate, resourceId: "ident-1" });- expect(channels.size).toBe(2);- // A root-org identity can be invited into a child org and watched from there, so a hard delete- // has to reach alerts outside the org that owns the identity.- alerts.set("alert-2", {- id: "alert-2",- orgId: "org-2",- projectId: null,- resourceType: RESOURCE_TYPE,- resourceId: "ident-1",- eventType: "test.resource.expiration"- });- alerts.set("alert-3", {- id: "alert-3",- orgId: "org-2",- projectId: "proj-1",- resourceType: RESOURCE_TYPE,- resourceId: "ident-1",- eventType: "test.resource.expiration"- });-- const deleted = await service.deleteAlertsForDeletedResource({- resourceType: RESOURCE_TYPE,- resourceId: "ident-1"- });-- expect(deleted).toBe(3);- expect(alerts.size).toBe(0);- expect(channels.size).toBe(0);- });-- test("deleteAlertsForDeletedResource reaps an alert created between the find and the delete", async () => {- let raced = false;- const { service, alerts, channels } = buildService({- afterFindAlerts: (rows) => {- if (raced) return;- raced = true;- // Another transaction created an alert on the same resource and committed after our find took- // its snapshot. Reaping by the ids the find returned would leave this row dangling, so the- // delete has to run off the resource filter instead.- rows.set("alert-race", {- id: "alert-race",- orgId: "org-1",- projectId: null,- resourceType: RESOURCE_TYPE,- resourceId: "ident-1",- eventType: "test.resource.expiration"- });- }- });- await service.createAlert({ ...validCreate, resourceId: "ident-1" });-- const deleted = await service.deleteAlertsForDeletedResource({- resourceType: RESOURCE_TYPE,- resourceId: "ident-1"- });-- expect(raced).toBe(true);- expect(deleted).toBe(2);- expect(alerts.size).toBe(0);- expect(channels.size).toBe(0);- });-- test("deleteAlertsForResource reaps an alert created in scope between the find and the delete", async () => {- let raced = false;- const { service, alerts } = buildService({- afterFindAlerts: (rows) => {- if (raced) return;- raced = true;- rows.set("alert-race", {- id: "alert-race",- orgId: "org-1",- projectId: "proj-1",- resourceType: RESOURCE_TYPE,- resourceId: "ident-1",- eventType: "test.resource.expiration"- });- // Out of the reaped scope, so it must survive even though it races the same way.- rows.set("alert-other-project", {- id: "alert-other-project",- orgId: "org-1",- projectId: "proj-2",- resourceType: RESOURCE_TYPE,- resourceId: "ident-1",- eventType: "test.resource.expiration"- });- }- });- await service.createAlert({ ...validCreate, resourceId: "ident-1" });-- const deleted = await service.deleteAlertsForResource({- orgId: "org-1",- projectId: "proj-1",- resourceType: RESOURCE_TYPE,- resourceId: "ident-1"- });-- expect(deleted).toBe(1);- expect([...alerts.keys()].sort()).toEqual(["alert-1", "alert-other-project"]);- });-- test("deleteAlertsForDeletedResource spares other resources and other resource types", async () => {- const { service, alerts } = buildService();- await service.createAlert({ ...validCreate, resourceId: "ident-1" });- alerts.set("other-resource", {- id: "other-resource",- orgId: "org-2",- projectId: null,- resourceType: RESOURCE_TYPE,- resourceId: "ident-2",- eventType: "test.resource.expiration"- });- alerts.set("other-type", {- id: "other-type",- orgId: "org-2",- projectId: null,- resourceType: "other.resource",- resourceId: "ident-1",- eventType: "other.resource.expiration"- });-- const deleted = await service.deleteAlertsForDeletedResource({- resourceType: RESOURCE_TYPE,- resourceId: "ident-1"- });-- expect(deleted).toBe(1);- expect([...alerts.keys()]).toEqual(["other-resource", "other-type"]);+ expect(permissionCalls.map((call) => call.action)).toContain("delete");});});@@ -740,41 +430,6 @@ describe("alert service internal entry points", () => {expect(updated.enabled).toBe(false);});- test("findAlertsForResources returns each resource's alert with its channels", async () => {- const { service } = buildService();- await service.createAlertInternal(internalCreate);-- const found = await service.findAlertsForResources({- resourceType: RESOURCE_TYPE,- resourceIds: ["resource-1", "resource-2"]- });-- expect(found.map((a) => a.resourceId)).toEqual(["resource-1"]);- expect(found[0].channels).toHaveLength(1);- });-- test("findAlertsForResources with no ids reads nothing", async () => {- const { service, findFilters } = buildService();- expect(await service.findAlertsForResources({ resourceType: RESOURCE_TYPE, resourceIds: [] })).toEqual([]);- expect(findFilters).toHaveLength(0);- });-- test("deleteAlertsForDeletedResources reaps every listed resource and its channels", async () => {- const { service, alerts, channels } = buildService();- await service.createAlertInternal(internalCreate);- alerts.set("alert-2", { id: "alert-2", orgId: "org-1", resourceType: RESOURCE_TYPE, resourceId: "resource-2" });- alerts.set("alert-3", { id: "alert-3", orgId: "org-1", resourceType: RESOURCE_TYPE, resourceId: "resource-3" });-- const deleted = await service.deleteAlertsForDeletedResources({- resourceType: RESOURCE_TYPE,- resourceIds: ["resource-1", "resource-2"]- });-- expect(deleted).toBe(2);- expect([...alerts.keys()]).toEqual(["alert-3"]);- expect(channels.size).toBe(0);- });-test("a concurrent duplicate create surfaces as a readable error, not a 500", async () => {const { service } = buildService({createError: new DatabaseError({ error: { code: DatabaseErrorCode.UniqueViolation }, name: "Create" })@@ -783,16 +438,4 @@ describe("alert service internal entry points", () => {"An alert for this resource and event already exists");});-- test("repointAlertsForResource moves a resource's alerts to its new id", async () => {- const { service, alerts } = buildService();- const created = await service.createAlertInternal(internalCreate);-- await service.repointAlertsForResource(- { resourceType: RESOURCE_TYPE, fromResourceId: "resource-1", toResourceId: "resource-9" },- {} as never- );-- expect(alerts.get(created.id)).toMatchObject({ resourceId: "resource-9" });- });});