fix: ensure default calendars domain (#27645)
* fix: ensure default calendars delegation credential domain * fix: ensure default calendars delegation credential domain
This commit is contained in:
+2
-2
@@ -139,7 +139,7 @@ describe("Organizations Delegation Credentials Endpoints", () => {
|
||||
data: {
|
||||
workspacePlatformId: workspacePlatform.id,
|
||||
organizationId: org.id,
|
||||
domain: "@test-domain.com",
|
||||
domain: "test-domain.com",
|
||||
serviceAccountKey: encryptedServiceAccountKey,
|
||||
enabled: false,
|
||||
},
|
||||
@@ -194,7 +194,7 @@ describe("Organizations Delegation Credentials Endpoints", () => {
|
||||
expect(responseBody.status).toEqual(SUCCESS_STATUS);
|
||||
expect(responseBody.data.enabled).toEqual(true);
|
||||
|
||||
expect(ensureDefaultCalendarsSpy).toHaveBeenCalledWith(org.id, "@test-domain.com");
|
||||
expect(ensureDefaultCalendarsSpy).toHaveBeenCalledWith(org.id, "test-domain.com");
|
||||
});
|
||||
|
||||
it("should not call ensureDefaultCalendars when disabling delegation credentials", async () => {
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ export class OrganizationsDelegationCredentialRepository {
|
||||
},
|
||||
where: {
|
||||
organizationId: orgId,
|
||||
user: { email: { endsWith: domain } },
|
||||
user: { email: { endsWith: `@${domain}`, mode: "insensitive" } },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
+2
-2
@@ -172,7 +172,7 @@ describe("OrganizationsDelegationCredentialService", () => {
|
||||
|
||||
await service.ensureDefaultCalendarsForUser(orgId, userId, userEmail);
|
||||
|
||||
expect(mockRepository.findEnabledByOrgIdAndDomain).toHaveBeenCalledWith(orgId, "@example.com");
|
||||
expect(mockRepository.findEnabledByOrgIdAndDomain).toHaveBeenCalledWith(orgId, "example.com");
|
||||
expect(mockQueue.add).toHaveBeenCalledWith(
|
||||
DEFAULT_CALENDARS_JOB,
|
||||
{ userId },
|
||||
@@ -198,7 +198,7 @@ describe("OrganizationsDelegationCredentialService", () => {
|
||||
|
||||
await service.ensureDefaultCalendarsForUser(orgId, userId, userEmail);
|
||||
|
||||
expect(mockRepository.findEnabledByOrgIdAndDomain).toHaveBeenCalledWith(orgId, "@example.com");
|
||||
expect(mockRepository.findEnabledByOrgIdAndDomain).toHaveBeenCalledWith(orgId, "example.com");
|
||||
expect(mockQueue.add).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
||||
+1
-1
@@ -174,7 +174,7 @@ export class OrganizationsDelegationCredentialService {
|
||||
this.logger.warn(`Invalid email format for user ${userId}: missing domain`);
|
||||
return;
|
||||
}
|
||||
const emailDomain = `@${emailParts[1]}`;
|
||||
const emailDomain = emailParts[1];
|
||||
|
||||
const delegationCredential =
|
||||
await this.organizationsDelegationCredentialRepository.findEnabledByOrgIdAndDomain(
|
||||
|
||||
Reference in New Issue
Block a user