-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Enhance SCIM user attribute handling and sync process
- Introduced a new PR_TODO.md file to track ongoing tasks and fixes. - Updated `getAttributesFromScimPayload` to accept a directoryId and ignore core user attributes during syncing. - Modified `handleUserEvents` to pass directoryId when syncing custom attributes. - Improved attribute creation logic to handle unique options and added support for optional isGroup property in attribute options. - Added utility function `getOptionsWithValidContains` to ensure valid sub-options in attribute options. - Updated tests to reflect changes in attribute handling and ensure proper functionality. This commit addresses issues with user attribute syncing and enhances the overall attribute management process.
- Loading branch information
1 parent
63013d4
commit 6f65630
Showing
8 changed files
with
135 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,14 +3,15 @@ import { describe, expect, it } from "vitest"; | |
|
||
import getAttributesFromScimPayload from "../getAttributesFromScimPayload"; | ||
|
||
const directoryId = "xxx-xxx-xxx-xxx"; | ||
describe("getAttributesFromScimPayload", () => { | ||
it("should return empty object for unsupported events", () => { | ||
const event = { | ||
event: "user.deleted", | ||
data: { raw: { schemas: [] } }, | ||
} as DirectorySyncEvent; | ||
|
||
const result = getAttributesFromScimPayload(event); | ||
const result = getAttributesFromScimPayload({ event, directoryId }); | ||
expect(result).toEqual({}); | ||
}); | ||
|
||
|
@@ -28,7 +29,7 @@ describe("getAttributesFromScimPayload", () => { | |
}, | ||
} as DirectorySyncEvent; | ||
|
||
const result = getAttributesFromScimPayload(event); | ||
const result = getAttributesFromScimPayload({ event, directoryId }); | ||
expect(result).toEqual({ | ||
department: "Engineering", | ||
title: "Software Engineer", | ||
|
@@ -48,7 +49,7 @@ describe("getAttributesFromScimPayload", () => { | |
}, | ||
} as DirectorySyncEvent; | ||
|
||
const result = getAttributesFromScimPayload(event); | ||
const result = getAttributesFromScimPayload({ event, directoryId }); | ||
expect(result).toEqual({ | ||
skills: ["JavaScript", "TypeScript", "React"], | ||
}); | ||
|
@@ -68,7 +69,7 @@ describe("getAttributesFromScimPayload", () => { | |
}, | ||
} as DirectorySyncEvent; | ||
|
||
const result = getAttributesFromScimPayload(event); | ||
const result = getAttributesFromScimPayload({ event, directoryId }); | ||
expect(result).toEqual({ | ||
department: "Engineering", | ||
}); | ||
|
@@ -87,7 +88,7 @@ describe("getAttributesFromScimPayload", () => { | |
}, | ||
} as DirectorySyncEvent; | ||
|
||
const result = getAttributesFromScimPayload(event); | ||
const result = getAttributesFromScimPayload({ event, directoryId }); | ||
expect(result).toEqual({}); | ||
}); | ||
|
||
|
@@ -108,7 +109,7 @@ describe("getAttributesFromScimPayload", () => { | |
}, | ||
} as DirectorySyncEvent; | ||
|
||
const result = getAttributesFromScimPayload(event); | ||
const result = getAttributesFromScimPayload({ event, directoryId }); | ||
expect(result).toEqual({ | ||
department: "Engineering", | ||
location: "Remote", | ||
|
@@ -128,13 +129,13 @@ describe("getAttributesFromScimPayload", () => { | |
}, | ||
} as DirectorySyncEvent; | ||
|
||
const result = getAttributesFromScimPayload(event); | ||
const result = getAttributesFromScimPayload({ event, directoryId }); | ||
expect(result).toEqual({ | ||
department: "Engineering", | ||
}); | ||
}); | ||
|
||
it("should extract from core namespace as well.", () => { | ||
it("should extract from core namespace as well ignoring the core attributes as defined in the SCIM spec.", () => { | ||
const event = { | ||
event: "user.created", | ||
data: { | ||
|
@@ -152,13 +153,14 @@ describe("getAttributesFromScimPayload", () => { | |
}, | ||
} as DirectorySyncEvent; | ||
|
||
const result = getAttributesFromScimPayload(event); | ||
const result = getAttributesFromScimPayload({ event, directoryId }); | ||
expect(result).toEqual({ | ||
userName: "[email protected]", | ||
displayName: "Kush", | ||
territory: "XANAM", | ||
externalId: "00ulb1kpy4EMATtuS5d7", | ||
groups: [], | ||
// Core Attributes won't be there - It avoids unnecessary warnings about attributes not defined in cal.com | ||
// userName: "[email protected]", | ||
// displayName: "Kush", | ||
// externalId: "00ulb1kpy4EMATtuS5d7", | ||
// groups: [], | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.