-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SALTO-6633: group assignment validator (#6532)
- Loading branch information
1 parent
420dca9
commit 5abe927
Showing
5 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
packages/okta-adapter/src/change_validators/everyone_group_assignments.ts
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright 2024 Salto Labs Ltd. | ||
* Licensed under the Salto Terms of Use (the "License"); | ||
* You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.salto.io/terms-of-use | ||
* | ||
* CERTAIN THIRD PARTY SOFTWARE MAY BE CONTAINED IN PORTIONS OF THE SOFTWARE. See NOTICE FILE AT https://github.com/salto-io/salto/blob/main/NOTICES | ||
*/ | ||
import { ChangeValidator, getChangeData, isInstanceChange, isModificationChange } from '@salto-io/adapter-api' | ||
import { GROUP_MEMBERSHIP_TYPE_NAME } from '../constants' | ||
|
||
/** | ||
* Assignments to the "Everyone" group are managed by Okta and cannot be modified. | ||
*/ | ||
export const everyoneGroupAssignments: ChangeValidator = async changes => | ||
changes | ||
.filter(isInstanceChange) | ||
.filter(isModificationChange) | ||
.map(getChangeData) | ||
.filter(instance => instance.elemID.typeName === GROUP_MEMBERSHIP_TYPE_NAME) | ||
.filter(instance => instance.elemID.name === 'Everyone') | ||
.map(instance => ({ | ||
elemID: instance.elemID, | ||
severity: 'Error', | ||
message: 'Assignment to the "Everyone" group are managed by Okta.', | ||
detailedMessage: | ||
'Group assignments to the "Everyone" group are managed by Okta. Any users added in this deployment will be auto assigned to this group.', | ||
})) |
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
31 changes: 31 additions & 0 deletions
31
packages/okta-adapter/test/change_validators/everyone_group_assignments.test.ts
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright 2024 Salto Labs Ltd. | ||
* Licensed under the Salto Terms of Use (the "License"); | ||
* You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.salto.io/terms-of-use | ||
* | ||
* CERTAIN THIRD PARTY SOFTWARE MAY BE CONTAINED IN PORTIONS OF THE SOFTWARE. See NOTICE FILE AT https://github.com/salto-io/salto/blob/main/NOTICES | ||
*/ | ||
import { toChange, ObjectType, ElemID, InstanceElement } from '@salto-io/adapter-api' | ||
import { everyoneGroupAssignments } from '../../src/change_validators/everyone_group_assignments' | ||
import { OKTA, GROUP_MEMBERSHIP_TYPE_NAME } from '../../src/constants' | ||
|
||
describe('everyoneGroupAssignments', () => { | ||
const groupMembersType = new ObjectType({ elemID: new ElemID(OKTA, GROUP_MEMBERSHIP_TYPE_NAME) }) | ||
const everyoneGroup = new InstanceElement('Everyone', groupMembersType, { members: ['a', 'b', 'c'] }) | ||
const otherGroup = new InstanceElement('Other', groupMembersType, { members: ['a'] }) | ||
|
||
it('should return an error when modifying the Everyone group members instance', async () => { | ||
expect(await everyoneGroupAssignments([toChange({ before: everyoneGroup, after: everyoneGroup })])).toEqual([ | ||
{ | ||
elemID: everyoneGroup.elemID, | ||
severity: 'Error', | ||
message: 'Assignment to the "Everyone" group are managed by Okta.', | ||
detailedMessage: | ||
'Group assignments to the "Everyone" group are managed by Okta. Any users added in this deployment will be auto assigned to this group.', | ||
}, | ||
]) | ||
}) | ||
it('should not return an error when modifying a different group members instance', async () => { | ||
expect(await everyoneGroupAssignments([toChange({ before: otherGroup, after: otherGroup })])).toEqual([]) | ||
}) | ||
}) |