-
Notifications
You must be signed in to change notification settings - Fork 274
[comp] Production Deploy #2332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
+517
−64
Merged
[comp] Production Deploy #2332
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2670554
chore: merge release v3.9.0 back to main [skip ci]
github-actions[bot] 67041ab
feat(people): add Agent Installed column and hide deactivated users b…
github-actions[bot] 4bbd2f0
refactor(people): rename Agent column to Device (#2333)
github-actions[bot] 5661cd6
fix(portal): show Company Forms section even when all tasks are compl…
Marfuen 37a9813
fix(vendors): validate vendor research URLs belong to correct domain …
github-actions[bot] 8c6865b
fix(vendors): extract root domain from subdomain vendor websites (#2337)
github-actions[bot] e3a9867
fix(integrations): filter GWS employee sync by organizational units (…
github-actions[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
90 changes: 90 additions & 0 deletions
90
apps/api/src/integration-platform/controllers/sync-ou-filter.spec.ts
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| import { filterUsersByOrgUnits } from './sync-ou-filter'; | ||
|
|
||
| interface TestUser { | ||
| primaryEmail: string; | ||
| orgUnitPath: string; | ||
| suspended?: boolean; | ||
| } | ||
|
|
||
| describe('filterUsersByOrgUnits', () => { | ||
| const users: TestUser[] = [ | ||
| { primaryEmail: 'alice@example.com', orgUnitPath: '/' }, | ||
| { primaryEmail: 'bob@example.com', orgUnitPath: '/Engineering' }, | ||
| { primaryEmail: 'carol@example.com', orgUnitPath: '/Engineering/Frontend' }, | ||
| { primaryEmail: 'dave@example.com', orgUnitPath: '/Marketing' }, | ||
| { primaryEmail: 'eve@example.com', orgUnitPath: '/HR' }, | ||
| { | ||
| primaryEmail: 'frank@example.com', | ||
| orgUnitPath: '/Unlisted', | ||
| suspended: true, | ||
| }, | ||
| ]; | ||
|
|
||
| it('returns all users when no target OUs specified', () => { | ||
| const result = filterUsersByOrgUnits(users, undefined); | ||
| expect(result).toEqual(users); | ||
| }); | ||
|
|
||
| it('returns all users when target OUs is an empty array', () => { | ||
| const result = filterUsersByOrgUnits(users, []); | ||
| expect(result).toEqual(users); | ||
| }); | ||
|
|
||
| it('filters users to only those in selected OUs', () => { | ||
| const result = filterUsersByOrgUnits(users, ['/Engineering']); | ||
| expect(result.map((u) => u.primaryEmail)).toEqual([ | ||
| 'bob@example.com', | ||
| 'carol@example.com', | ||
| ]); | ||
| }); | ||
|
|
||
| it('includes users in child OUs of selected OUs', () => { | ||
| const result = filterUsersByOrgUnits(users, ['/Engineering']); | ||
| expect(result.map((u) => u.primaryEmail)).toContain('carol@example.com'); | ||
| }); | ||
|
|
||
| it('exact match on OU path works', () => { | ||
| const result = filterUsersByOrgUnits(users, ['/Engineering/Frontend']); | ||
| expect(result.map((u) => u.primaryEmail)).toEqual(['carol@example.com']); | ||
| }); | ||
|
|
||
| it('supports multiple target OUs', () => { | ||
| const result = filterUsersByOrgUnits(users, ['/Engineering', '/Marketing']); | ||
| expect(result.map((u) => u.primaryEmail)).toEqual([ | ||
| 'bob@example.com', | ||
| 'carol@example.com', | ||
| 'dave@example.com', | ||
| ]); | ||
| }); | ||
|
|
||
| it('root OU includes all users', () => { | ||
| const result = filterUsersByOrgUnits(users, ['/']); | ||
| expect(result).toEqual(users); | ||
| }); | ||
|
|
||
| it('excludes users not in any selected OU', () => { | ||
| const result = filterUsersByOrgUnits(users, ['/Engineering']); | ||
| const emails = result.map((u) => u.primaryEmail); | ||
| expect(emails).not.toContain('alice@example.com'); | ||
| expect(emails).not.toContain('dave@example.com'); | ||
| expect(emails).not.toContain('eve@example.com'); | ||
| expect(emails).not.toContain('frank@example.com'); | ||
| }); | ||
|
|
||
| it('does not match partial OU path names', () => { | ||
| // /Eng should NOT match /Engineering | ||
| const result = filterUsersByOrgUnits(users, ['/Eng']); | ||
| expect(result).toEqual([]); | ||
| }); | ||
|
|
||
| it('preserves suspended user status through filtering', () => { | ||
| const result = filterUsersByOrgUnits(users, ['/Unlisted']); | ||
| expect(result).toEqual([ | ||
| { | ||
| primaryEmail: 'frank@example.com', | ||
| orgUnitPath: '/Unlisted', | ||
| suspended: true, | ||
| }, | ||
| ]); | ||
| }); | ||
| }); |
23 changes: 23 additions & 0 deletions
23
apps/api/src/integration-platform/controllers/sync-ou-filter.ts
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /** | ||
| * Filters users by organizational unit paths. | ||
| * Matches users whose orgUnitPath equals or is a child of any target OU. | ||
| * | ||
| * @param users - Array of objects with an orgUnitPath property | ||
| * @param targetOrgUnits - Array of OU paths to include (undefined/empty = all users) | ||
| * @returns Filtered array of users | ||
| */ | ||
| export function filterUsersByOrgUnits< | ||
| T extends { orgUnitPath?: string }, | ||
| >(users: T[], targetOrgUnits: string[] | undefined): T[] { | ||
| if (!targetOrgUnits || targetOrgUnits.length === 0) { | ||
| return users; | ||
| } | ||
|
|
||
| return users.filter((user) => { | ||
| const userOu = user.orgUnitPath ?? '/'; | ||
| return targetOrgUnits.some( | ||
| (ou) => | ||
| ou === '/' || userOu === ou || userOu.startsWith(`${ou}/`), | ||
| ); | ||
| }); | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.