chore: rename DWD to DelegationCredential (#19703)

* chore: rename DWD to DelegationCredential

* fixup! chore: rename DWD to DelegationCredential

* fixup! fixup! chore: rename DWD to DelegationCredential

* fixup! Merge branch 'main' into rename-domain-wide-delegation

* fixup! fixup! Merge branch 'main' into rename-domain-wide-delegation

* fixup! fixup! fixup! Merge branch 'main' into rename-domain-wide-delegation
This commit is contained in:
Morgan authored and GitHub committed 2025-03-04 09:45:39 -03:00
1 parent a39b5e47a7
commit 7a9ddf2194
167 files changed
+4232 -2356

No files matched your search

@@ -4,7 +4,7 @@ import {
Timezones,
TestData,
mockCalendar,
createDwdCredential,
createDelegationCredential,
createOrganization,
getOrganizer,
} from "../../utils/bookingScenario/bookingScenario";
@@ -20,8 +20,8 @@ import { setupAndTeardown } from "./setupAndTeardown";
describe("getSchedule", () => {
setupAndTeardown();
describe("Domain Wide Delegation", () => {
test("correctly identifies unavailable slots using DWD credentials", async () => {
describe("Delegation Credential", () => {
test("correctly identifies unavailable slots using DelegationCredential credentials", async () => {
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const { dateString: plus2DateString } = getDate({ dateIncrement: 2 });
@@ -50,13 +50,13 @@ describe("getSchedule", () => {
id: 101,
schedules: [TestData.schedules.IstWorkHours],
selectedCalendars: [TestData.selectedCalendars.google],
// User must be part of organization to be able to use that organization's DWD credential
// User must be part of organization to be able to use that organization's Delegation credential
teams: payloadToMakePartOfOrganization,
// No regular credentials provided
credentials: [],
});
await createDwdCredential(org.id);
await createDelegationCredential(org.id);
const googleCalendarMock = mockCalendar("googlecalendar", {
create: {
@@ -108,7 +108,7 @@ describe("getSchedule", () => {
});
});
test("fails to get schedule when user isn't part of the organization with DWD credential", async () => {
test("fails to get schedule when user isn't part of the organization with Delegation credential", async () => {
const { dateString: plus1DateString } = getDate({ dateIncrement: 1 });
const { dateString: plus2DateString } = getDate({ dateIncrement: 2 });
@@ -147,8 +147,8 @@ describe("getSchedule", () => {
credentials: [],
});
// Create DWD credential for the org user isn't part of
await createDwdCredential(org.id);
// Create Delegation credential for the org user isn't part of
await createDelegationCredential(org.id);
const googleCalendarMock = mockCalendar("googlecalendar", {
create: {
@@ -196,7 +196,7 @@ describe("getSchedule", () => {
expectNoAttemptToGetAvailability(googleCalendarMock);
// All slots would be available as no DWD credentials are available
// All slots would be available as no DelegationCredential credentials are available
expect(scheduleForDayWithAGoogleCalendarBooking).toHaveTimeSlots(
expectedSlotsForSchedule.IstWorkHours.interval["1hr"].allPossibleSlotsStartingAt430,
{
@@ -2309,7 +2309,7 @@ export const getDefaultBookingFields = ({
] as Fields;
};
export const createDwdCredential = async (orgId: number, type: "google" | "office365" = "google") => {
export const createDelegationCredential = async (orgId: number, type: "google" | "office365" = "google") => {
if (type === "google") {
const encryptedServiceAccountKey = {
type: "service_account",
@@ -2349,7 +2349,7 @@ export const createDwdCredential = async (orgId: number, type: "google" | "offic
auth_provider_x509_cert_url: "AUTH_PROVIDER_X509_CERT_URL",
};
const dwd = await prismock.domainWideDelegation.create({
const delegationCredential = await prismock.delegationCredential.create({
data: {
workspacePlatform: {
connect: {
@@ -2368,7 +2368,7 @@ export const createDwdCredential = async (orgId: number, type: "google" | "offic
},
});
return { ...dwd, serviceAccountKey: decryptedServiceAccountKey };
return { ...delegationCredential, serviceAccountKey: decryptedServiceAccountKey };
} else if (type === "office365") {
const encryptedServiceAccountKey = {
client_id: "CLIENT_ID",
@@ -2392,7 +2392,7 @@ export const createDwdCredential = async (orgId: number, type: "google" | "offic
tenant_id: "TENANT_ID",
};
const dwd = await prismock.domainWideDelegation.create({
const delegationCredential = await prismock.delegationCredential.create({
data: {
workspacePlatform: {
connect: {
@@ -2411,13 +2411,13 @@ export const createDwdCredential = async (orgId: number, type: "google" | "offic
},
});
return { ...dwd, serviceAccountKey: decryptedServiceAccountKey };
return { ...delegationCredential, serviceAccountKey: decryptedServiceAccountKey };
}
throw new Error(`Unsupported type: ${type}`);
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const buildDwdCredential = ({ serviceAccountKey }: { serviceAccountKey: any }) => {
export const buildDelegationCredential = ({ serviceAccountKey }: { serviceAccountKey: any }) => {
return {
id: -1,
key: {