mirror of
https://github.com/hanzoai/calendar.git
synced 2026-10-30 14:46:43 +00:00
* feat: add OAuth client developer settings page with approval workflow - Add new developer OAuth page at /settings/developer/oAuth for users to submit OAuth client requests - Transform admin OAuth page into management dashboard for reviewing/approving submissions - Add OAuthClientApprovalStatus enum (PENDING, APPROVED, REJECTED) to track submission status - Add userId and createdAt fields to OAuthClient model for tracking submissions - Create email notifications for admin (new submission) and user (approval) - Add sidebar navigation link in developer section below API keys - Add comprehensive translations for new UI strings - Create OAuthClientRepository for data access following repository pattern Co-Authored-By: [email protected] <[email protected]> * fix: re-export generateSecret for backward compatibility Co-Authored-By: [email protected] <[email protected]> * feat: make logo mandatory and list items clickable for OAuth clients Co-Authored-By: [email protected] <[email protected]> * fix: add missing translation keys and remove client secret from details dialog Co-Authored-By: [email protected] <[email protected]> * fix: address cubic AI reviewer comments - Remove duplicate 'there' JSON key in common.json - Add select clause to findByUserId to avoid exposing clientSecret - Add @@index([userId]) to OAuthClient model for query performance - Update migration to include the index Co-Authored-By: [email protected] <[email protected]> * fix: address PR review comments - fix indentation and use useCopy hook Co-Authored-By: [email protected] <[email protected]> * fix: change react-dom/server import to fix Turbopack compatibility Co-Authored-By: [email protected] <[email protected]> * Revert "fix: change react-dom/server import to fix Turbopack compatibility" This reverts commit c3e0b709c2d88fd221143cb4ce9cd25bb8c94277. * fix: use email service pattern for OAuth client notifications Co-Authored-By: [email protected] <[email protected]> * fix: add try-catch around email sending to handle Turbopack react-dom/server issue Co-Authored-By: [email protected] <[email protected]> * Revert "fix: add try-catch around email sending to handle Turbopack react-dom/server issue" This reverts commit fc9d47cd773505ebc5ee2696718aad4a8a98be77. * fix: improve OAuth client UI with skeleton loaders and smaller dialog styling - Replace 'Loading...' text with proper skeleton loaders in both developer and admin OAuth client views - Make client_id and copy button smaller in dialogs using size='sm' and text-sm styling - Add 'client_id' translation key to common.json for proper i18n Co-Authored-By: [email protected] <[email protected]> * fix: improve skeleton loader to match actual OAuth client list structure - Remove divide-y from container and use conditional border-b on rows - Match the exact structure from oauth-clients-view.tsx L126-160 - Use proper spacing for text elements (mt-1 instead of space-y-2) Co-Authored-By: [email protected] <[email protected]> * fix skeleton * rename the selected oauth client dialog * fix: address PR feedback - admin auth, dropdown styling, sidebar label - Add defense-in-depth admin authorization check in updateClientStatus handler - Fix broken dropdown menu by using DropdownItem with StartIcon prop - Fix sidebar menu label from 'oAuth' to 'oauth_clients' to match developer view Co-Authored-By: [email protected] <[email protected]> * update common.json * feat: show client secret in approval email for confidential OAuth clients - Add regenerateSecret method to OAuthClientRepository - Regenerate secret when admin approves a PENDING confidential client - Include client secret in approval notification email - Add one-time warning message about storing the secret securely - Only regenerate on first approval (not re-approvals) Co-Authored-By: [email protected] <[email protected]> * feat: add Website URL field, fix logo styling, show client secret after approval - Add Website URL field to OAuth client forms (admin and developer views) - Fix Upload Logo section styling by wrapping in Label div with proper gap - Display client secret in dialog after admin approves a confidential OAuth client - Add websiteUrl field to Prisma schema with migration - Update tRPC handlers and repository to support websiteUrl - Add translation keys for new UI elements Co-Authored-By: [email protected] <[email protected]> * fix: move clientSecret variable declaration outside if block for proper scoping Co-Authored-By: [email protected] <[email protected]> * refactor: dont expose client secret in emails * refactor: dont regenerate secret upon status change * refactor: reuse existing hash function * refactor: rename admin/oAuth to admin/oauth page * refactor: deduplicate oauth repositories * refactor: remove withGlobalPrisma from oauth repository * refactor: developer oauth page * refactor: oauth status by default accepted * refactor: request oauth status when creating * refactor ux * fix: address Cubic AI code review feedback - Add purpose field to plain text email body for accessibility - Convert NewOAuthClientButton to inline JSX to avoid React anti-pattern - Trigger re-approval when redirectUri changes for security - Add e.preventDefault() for Space key to prevent page scroll - Change default approvalStatus to PENDING for defense-in-depth - Use oauth_clients translation key for consistency - Add meaningful alt text to Avatar for accessibility - Remove onClick from DialogClose to prevent double-run close effects - Return NOT_FOUND for non-owner delete to prevent resource enumeration Co-Authored-By: unknown <> * common.json file * refactor: delete all prisma migrations * refactor: have just 1 prisma migration * revert: some devin changes * fix: typecheck * test: owner OAuth crud * test: admin OAuth approval / rejection * fix: address Cubic AI review feedback (confidence 9/10 issues) - schema.prisma: Remove @default("") from purpose field to make it required - schema.prisma: Use UTC-aware timezone expression for createdAt default - OAuthClientFormFields.tsx: Localize redirect URI placeholder using t() - common.json: Add redirect_uri_placeholder translation key Co-Authored-By: unknown <> * cubic changes * refactor: dont log sensitive info and rethrow error * cubic feedback * refactor: make oauth client purpose optional * refactor: admin/oauth not allowed if not logged in * refactor: admin view skeleton * refactor: rename state * refactor: get rid of redundant mapping * refactor: remove redundant handler * refactor: remove redundant handler * refactor: re-usable new oauth client button * refactor: dialogs * refactor: modals * refactor: handler names, dialog, skeleton * fix: purpose being null * refactor: rename handler and delete old oauth admin page * fix: purpose in submission * refactor: handler names * refactor: rename * refactor: update handler * refactor: rename approvalStatus -> status * refactor: simplify modal * refactor: name * dont require repproval if redirectUri changes * fix: remove integration sync index creation * refactor: require re-approval if redirectUri updated * fix: flaky e2e test * fix: flaky e2e test * fix: flaky e2e test * fix: remove duplicate common.json keys * refactor: replace [email protected] with SUPPORT_MAIL_ADDRESS * refactor: generate client secret on handler level * fix: authorization code only available to approved clients * refactor: cubic review dont display exclamation * refactor: cubic review website_url in common json * fix: dont default in ui to approved status * refactor: optiona logo in schema create handler * fix: tests * fix: tests * fix: /authorize redirect if client not approved or show error * test: authorize page with invalid client id * refactor: dont allow refreshing tokens unless approved client * fix: flaky e2e test * fix: flaky e2e test * fix: flaky e2e test * fix: flaky e2e test * fix: flaky e2e test * fix: flaky e2e test * chore: warn that pending client is not usable * fix: approve and reject buttons * fix: /authorize show error if client not approved * refactor: info message about editing oauth client and status * change info alert to warning * try to fix ci test * debug: failing e2e test * fix: improve session propagation in oauth-client-admin E2E test - Add navigateToAdminOAuthPage helper that waits for listClients API call - If the API call doesn't arrive (session issue), reload page to force session refresh - This fixes the CI flakiness where admin page wasn't loading due to session not having ADMIN role Co-Authored-By: [email protected] <[email protected]> * fix: register waitForResponse before navigating in E2E test - Register the listClients waitForResponse promise BEFORE page.goto() - This ensures the response isn't missed during page load - Also register the promise before reload in the catch block Co-Authored-By: [email protected] <[email protected]> * fix: rename oAuth folder to oauth for case-sensitive filesystems The admin OAuth page route was at /settings/admin/oAuth (capital A) but the code references /settings/admin/oauth (lowercase). This caused 404 errors on case-sensitive filesystems (Linux). Also improved the E2E test navigation helper to retry with delays if the admin page doesn't load immediately, handling session propagation timing. Co-Authored-By: [email protected] <[email protected]> * test style --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: [email protected] <[email protected]> Co-authored-by: Lauris Skraucis <[email protected]> Co-authored-by: supalarry <[email protected]> Co-authored-by: cubic-dev-ai[bot] <1082092+cubic-dev-ai[bot]@users.noreply.github.com> Co-authored-by: CarinaWolli <[email protected]> Co-authored-by: [email protected] <[email protected]> Co-authored-by: Morgan <[email protected]>
491 lines
12 KiB
TypeScript
491 lines
12 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
import type { TFunction } from "i18next";
|
|
|
|
import type { PrismaClient } from "@calcom/prisma";
|
|
import { OAuthClientStatus, UserPermissionRole } from "@calcom/prisma/enums";
|
|
|
|
import { updateClientHandler } from "./updateClient.handler";
|
|
|
|
const mocks = vi.hoisted(() => {
|
|
return {
|
|
findByClientId: vi.fn(),
|
|
findByClientIdIncludeUser: vi.fn(),
|
|
sendOAuthClientApprovedNotification: vi.fn(),
|
|
sendOAuthClientRejectedNotification: vi.fn(),
|
|
getTranslation: vi.fn(),
|
|
};
|
|
});
|
|
|
|
const CLIENT_ID = "client_123";
|
|
const OWNER_USER_ID = 42;
|
|
|
|
const USER_EMAIL = "[email protected]";
|
|
const USER_NAME = "Admin Example";
|
|
|
|
const CLIENT_NAME = "My Client";
|
|
const CLIENT_PURPOSE = "My purpose";
|
|
const REDIRECT_URI = "https://example.com/callback";
|
|
|
|
const REJECTION_REASON_TRIMMED = "we dont support your usecase";
|
|
const REJECTION_REASON_RAW = " we dont support your usecase ";
|
|
|
|
vi.mock("@calcom/features/oauth/repositories/OAuthClientRepository", () => ({
|
|
OAuthClientRepository: class {
|
|
constructor() {}
|
|
findByClientId = mocks.findByClientId;
|
|
findByClientIdIncludeUser = mocks.findByClientIdIncludeUser;
|
|
},
|
|
}));
|
|
|
|
vi.mock("@calcom/emails/oauth-email-service", () => ({
|
|
sendOAuthClientApprovedNotification: mocks.sendOAuthClientApprovedNotification,
|
|
sendOAuthClientRejectedNotification: mocks.sendOAuthClientRejectedNotification,
|
|
}));
|
|
|
|
vi.mock("@calcom/lib/server/i18n", () => ({
|
|
getTranslation: mocks.getTranslation,
|
|
}));
|
|
|
|
describe("updateClientHandler", () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
it("updates status to APPROVED (admin) and sends approved notification email with expected parameters", async () => {
|
|
const t = ((key: string, vars?: Record<string, unknown>) => {
|
|
if (key === "oauth_client_approved_email_subject") {
|
|
return `OAuth Client Approved: ${String(vars?.clientName ?? "")}`;
|
|
}
|
|
return key;
|
|
}) as unknown as TFunction;
|
|
|
|
mocks.getTranslation.mockResolvedValue(t);
|
|
|
|
mocks.findByClientIdIncludeUser.mockResolvedValue({
|
|
clientId: CLIENT_ID,
|
|
userId: OWNER_USER_ID,
|
|
name: CLIENT_NAME,
|
|
purpose: CLIENT_PURPOSE,
|
|
redirectUri: REDIRECT_URI,
|
|
websiteUrl: null,
|
|
logo: null,
|
|
status: "PENDING",
|
|
user: {
|
|
email: USER_EMAIL,
|
|
name: USER_NAME,
|
|
},
|
|
});
|
|
|
|
const prismaUpdate = vi.fn().mockResolvedValue({
|
|
clientId: CLIENT_ID,
|
|
name: CLIENT_NAME,
|
|
purpose: CLIENT_PURPOSE,
|
|
status: "APPROVED",
|
|
redirectUri: REDIRECT_URI,
|
|
websiteUrl: null,
|
|
logo: null,
|
|
rejectionReason: null,
|
|
});
|
|
|
|
const ctx = {
|
|
user: {
|
|
id: 1,
|
|
role: UserPermissionRole.ADMIN,
|
|
},
|
|
prisma: {
|
|
oAuthClient: {
|
|
update: prismaUpdate,
|
|
},
|
|
} as unknown as PrismaClient,
|
|
};
|
|
|
|
const input = {
|
|
clientId: CLIENT_ID,
|
|
status: OAuthClientStatus.APPROVED,
|
|
};
|
|
|
|
const result = await updateClientHandler({ ctx, input });
|
|
|
|
expect(prismaUpdate).toHaveBeenCalledWith(
|
|
expect.objectContaining({
|
|
where: { clientId: input.clientId },
|
|
data: {
|
|
status: "APPROVED",
|
|
rejectionReason: null,
|
|
},
|
|
})
|
|
);
|
|
|
|
expect(mocks.getTranslation).toHaveBeenCalledWith("en", "common");
|
|
|
|
expect(mocks.sendOAuthClientApprovedNotification).toHaveBeenCalledWith({
|
|
t,
|
|
userEmail: USER_EMAIL,
|
|
userName: USER_NAME,
|
|
clientName: CLIENT_NAME,
|
|
clientId: CLIENT_ID,
|
|
});
|
|
|
|
expect(result).toEqual({
|
|
clientId: CLIENT_ID,
|
|
name: CLIENT_NAME,
|
|
purpose: CLIENT_PURPOSE,
|
|
status: "APPROVED",
|
|
redirectUri: REDIRECT_URI,
|
|
websiteUrl: null,
|
|
logo: null,
|
|
rejectionReason: null,
|
|
});
|
|
});
|
|
|
|
it("updates status to REJECTED (admin) and sends rejected notification email with trimmed rejection reason", async () => {
|
|
const t = ((key: string, vars?: Record<string, unknown>) => {
|
|
if (key === "oauth_client_rejected_email_subject") {
|
|
return `OAuth Client Rejected: ${String(vars?.clientName ?? "")}`;
|
|
}
|
|
return key;
|
|
}) as unknown as TFunction;
|
|
|
|
mocks.getTranslation.mockResolvedValue(t);
|
|
|
|
mocks.findByClientIdIncludeUser.mockResolvedValue({
|
|
clientId: CLIENT_ID,
|
|
userId: OWNER_USER_ID,
|
|
name: CLIENT_NAME,
|
|
purpose: CLIENT_PURPOSE,
|
|
redirectUri: REDIRECT_URI,
|
|
websiteUrl: null,
|
|
logo: null,
|
|
status: "PENDING",
|
|
user: {
|
|
email: USER_EMAIL,
|
|
name: USER_NAME,
|
|
},
|
|
});
|
|
|
|
const prismaUpdate = vi.fn().mockResolvedValue({
|
|
clientId: CLIENT_ID,
|
|
name: CLIENT_NAME,
|
|
purpose: CLIENT_PURPOSE,
|
|
status: "REJECTED",
|
|
redirectUri: REDIRECT_URI,
|
|
websiteUrl: null,
|
|
logo: null,
|
|
rejectionReason: REJECTION_REASON_TRIMMED,
|
|
});
|
|
|
|
const ctx = {
|
|
user: {
|
|
id: 1,
|
|
role: UserPermissionRole.ADMIN,
|
|
},
|
|
prisma: {
|
|
oAuthClient: {
|
|
update: prismaUpdate,
|
|
},
|
|
} as unknown as PrismaClient,
|
|
};
|
|
|
|
const input = {
|
|
clientId: CLIENT_ID,
|
|
status: OAuthClientStatus.REJECTED,
|
|
rejectionReason: REJECTION_REASON_RAW,
|
|
};
|
|
|
|
await updateClientHandler({ ctx, input });
|
|
|
|
expect(prismaUpdate).toHaveBeenCalledWith(
|
|
expect.objectContaining({
|
|
where: { clientId: input.clientId },
|
|
data: {
|
|
status: "REJECTED",
|
|
rejectionReason: REJECTION_REASON_TRIMMED,
|
|
},
|
|
})
|
|
);
|
|
|
|
expect(mocks.getTranslation).toHaveBeenCalledWith("en", "common");
|
|
|
|
expect(mocks.sendOAuthClientRejectedNotification).toHaveBeenCalledWith({
|
|
t,
|
|
userEmail: USER_EMAIL,
|
|
userName: USER_NAME,
|
|
clientName: CLIENT_NAME,
|
|
clientId: CLIENT_ID,
|
|
rejectionReason: REJECTION_REASON_TRIMMED,
|
|
});
|
|
});
|
|
|
|
it("throws FORBIDDEN when a non-admin attempts to set rejectionReason", async () => {
|
|
mocks.findByClientIdIncludeUser.mockResolvedValue({
|
|
clientId: CLIENT_ID,
|
|
userId: OWNER_USER_ID,
|
|
name: CLIENT_NAME,
|
|
purpose: CLIENT_PURPOSE,
|
|
redirectUri: REDIRECT_URI,
|
|
websiteUrl: null,
|
|
logo: null,
|
|
status: "PENDING",
|
|
user: null,
|
|
});
|
|
|
|
const ctx = {
|
|
user: {
|
|
id: 2,
|
|
role: UserPermissionRole.USER,
|
|
},
|
|
prisma: {
|
|
oAuthClient: {
|
|
update: vi.fn(),
|
|
},
|
|
} as unknown as PrismaClient,
|
|
};
|
|
|
|
const input = {
|
|
clientId: CLIENT_ID,
|
|
rejectionReason: "nope",
|
|
};
|
|
|
|
await expect(updateClientHandler({ ctx, input })).rejects.toMatchObject({
|
|
code: "FORBIDDEN",
|
|
message: "Only admins can set a rejection reason",
|
|
});
|
|
});
|
|
|
|
it("throws BAD_REQUEST when rejecting without a non-empty rejectionReason", async () => {
|
|
mocks.findByClientIdIncludeUser.mockResolvedValue({
|
|
clientId: CLIENT_ID,
|
|
userId: OWNER_USER_ID,
|
|
name: CLIENT_NAME,
|
|
purpose: CLIENT_PURPOSE,
|
|
redirectUri: REDIRECT_URI,
|
|
websiteUrl: null,
|
|
logo: null,
|
|
status: "PENDING",
|
|
user: null,
|
|
});
|
|
|
|
const ctx = {
|
|
user: {
|
|
id: 1,
|
|
role: UserPermissionRole.ADMIN,
|
|
},
|
|
prisma: {
|
|
oAuthClient: {
|
|
update: vi.fn(),
|
|
},
|
|
} as unknown as PrismaClient,
|
|
};
|
|
|
|
await expect(
|
|
updateClientHandler({
|
|
ctx,
|
|
input: {
|
|
clientId: CLIENT_ID,
|
|
status: OAuthClientStatus.REJECTED,
|
|
rejectionReason: " ",
|
|
},
|
|
})
|
|
).rejects.toMatchObject({
|
|
code: "BAD_REQUEST",
|
|
message: "Rejection reason is required",
|
|
});
|
|
});
|
|
|
|
it("throws FORBIDDEN when a non-admin attempts to update status", async () => {
|
|
mocks.findByClientIdIncludeUser.mockResolvedValue({
|
|
clientId: CLIENT_ID,
|
|
userId: OWNER_USER_ID,
|
|
name: CLIENT_NAME,
|
|
purpose: CLIENT_PURPOSE,
|
|
redirectUri: REDIRECT_URI,
|
|
websiteUrl: null,
|
|
logo: null,
|
|
status: "PENDING",
|
|
user: null,
|
|
});
|
|
|
|
const ctx = {
|
|
user: {
|
|
id: 2,
|
|
role: UserPermissionRole.USER,
|
|
},
|
|
prisma: {
|
|
oAuthClient: {
|
|
update: vi.fn(),
|
|
},
|
|
} as unknown as PrismaClient,
|
|
};
|
|
|
|
await expect(
|
|
updateClientHandler({
|
|
ctx,
|
|
input: {
|
|
clientId: CLIENT_ID,
|
|
status: OAuthClientStatus.APPROVED,
|
|
},
|
|
})
|
|
).rejects.toMatchObject({
|
|
code: "FORBIDDEN",
|
|
message: "Only admins can update OAuth client status",
|
|
});
|
|
});
|
|
|
|
it("throws FORBIDDEN when a non-owner, non-admin attempts to update client fields", async () => {
|
|
mocks.findByClientIdIncludeUser.mockResolvedValue({
|
|
clientId: CLIENT_ID,
|
|
userId: OWNER_USER_ID,
|
|
name: CLIENT_NAME,
|
|
purpose: CLIENT_PURPOSE,
|
|
redirectUri: REDIRECT_URI,
|
|
websiteUrl: null,
|
|
logo: null,
|
|
status: "PENDING",
|
|
user: null,
|
|
});
|
|
|
|
const ctx = {
|
|
user: {
|
|
id: 999,
|
|
role: UserPermissionRole.USER,
|
|
},
|
|
prisma: {
|
|
oAuthClient: {
|
|
update: vi.fn(),
|
|
},
|
|
} as unknown as PrismaClient,
|
|
};
|
|
|
|
await expect(
|
|
updateClientHandler({
|
|
ctx,
|
|
input: {
|
|
clientId: CLIENT_ID,
|
|
name: "New Name",
|
|
},
|
|
})
|
|
).rejects.toMatchObject({
|
|
code: "FORBIDDEN",
|
|
message: "You do not have permission to update this OAuth client",
|
|
});
|
|
});
|
|
|
|
it("sets status to PENDING when an owner edits a previously approved client (reapproval flow)", async () => {
|
|
mocks.findByClientIdIncludeUser.mockResolvedValue({
|
|
clientId: CLIENT_ID,
|
|
userId: OWNER_USER_ID,
|
|
name: CLIENT_NAME,
|
|
purpose: CLIENT_PURPOSE,
|
|
redirectUri: REDIRECT_URI,
|
|
websiteUrl: null,
|
|
logo: null,
|
|
status: "APPROVED",
|
|
user: null,
|
|
});
|
|
|
|
const prismaUpdate = vi.fn().mockResolvedValue({
|
|
clientId: CLIENT_ID,
|
|
name: "My Client v2",
|
|
purpose: CLIENT_PURPOSE,
|
|
status: "PENDING",
|
|
redirectUri: REDIRECT_URI,
|
|
websiteUrl: null,
|
|
logo: null,
|
|
rejectionReason: null,
|
|
});
|
|
|
|
const ctx = {
|
|
user: {
|
|
id: 42,
|
|
role: UserPermissionRole.USER,
|
|
},
|
|
prisma: {
|
|
oAuthClient: {
|
|
update: prismaUpdate,
|
|
},
|
|
} as unknown as PrismaClient,
|
|
};
|
|
|
|
await updateClientHandler({
|
|
ctx,
|
|
input: {
|
|
clientId: CLIENT_ID,
|
|
name: "My Client v2",
|
|
},
|
|
});
|
|
|
|
expect(prismaUpdate).toHaveBeenCalledWith(
|
|
expect.objectContaining({
|
|
where: { clientId: CLIENT_ID },
|
|
data: {
|
|
name: "My Client v2",
|
|
status: "PENDING",
|
|
rejectionReason: null,
|
|
},
|
|
})
|
|
);
|
|
|
|
expect(mocks.sendOAuthClientApprovedNotification).not.toHaveBeenCalled();
|
|
expect(mocks.sendOAuthClientRejectedNotification).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("sets status to PENDING when an owner updates redirectUri (reapproval flow)", async () => {
|
|
mocks.findByClientIdIncludeUser.mockResolvedValue({
|
|
clientId: CLIENT_ID,
|
|
userId: OWNER_USER_ID,
|
|
name: CLIENT_NAME,
|
|
purpose: CLIENT_PURPOSE,
|
|
redirectUri: REDIRECT_URI,
|
|
websiteUrl: null,
|
|
logo: null,
|
|
status: "APPROVED",
|
|
user: null,
|
|
});
|
|
|
|
const updatedRedirectUri = "https://example.com/new-callback";
|
|
|
|
const prismaUpdate = vi.fn().mockResolvedValue({
|
|
clientId: CLIENT_ID,
|
|
name: CLIENT_NAME,
|
|
purpose: CLIENT_PURPOSE,
|
|
status: "PENDING",
|
|
redirectUri: updatedRedirectUri,
|
|
websiteUrl: null,
|
|
logo: null,
|
|
rejectionReason: null,
|
|
});
|
|
|
|
const ctx = {
|
|
user: {
|
|
id: OWNER_USER_ID,
|
|
role: UserPermissionRole.USER,
|
|
},
|
|
prisma: {
|
|
oAuthClient: {
|
|
update: prismaUpdate,
|
|
},
|
|
} as unknown as PrismaClient,
|
|
};
|
|
|
|
await updateClientHandler({
|
|
ctx,
|
|
input: {
|
|
clientId: CLIENT_ID,
|
|
redirectUri: updatedRedirectUri,
|
|
},
|
|
});
|
|
|
|
expect(prismaUpdate).toHaveBeenCalledWith(
|
|
expect.objectContaining({
|
|
where: { clientId: CLIENT_ID },
|
|
data: {
|
|
redirectUri: updatedRedirectUri,
|
|
status: "PENDING",
|
|
rejectionReason: null,
|
|
},
|
|
})
|
|
);
|
|
});
|
|
});
|