Skip to content

Commit c1ef51d

Browse files
committed
Fix #268 and fix #269: bugs/enhancements related to --strategy push
* Move all push-based group removals to come before group adds, and update the tests to expect that order. * Make sure we do secondary group adds when creating while syncing; so now it works the same for primaries and secondaries.
1 parent 51de7e2 commit c1ef51d

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

tests/rules_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,21 +155,21 @@ def mock_load_users_and_groups(groups=None, extended_attributes=None, all_users=
155155
user = everybody[0]
156156
commands = tests.helper.create_umapi_commands(user)
157157
commands.add_user(self.create_user_attributes_for_commands(user, rule_options['update_user_info']))
158-
commands.add_groups(set([primary_group_11]))
159158
commands.remove_groups(set([primary_group_21]))
159+
commands.add_groups(set([primary_group_11]))
160160
expected_primary_commands_list.append(commands)
161161

162162
user = everybody[1]
163163
commands = tests.helper.create_umapi_commands(user)
164164
commands.add_user(self.create_user_attributes_for_commands(user, rule_options['update_user_info']))
165-
commands.add_groups(set([primary_group_21]))
166165
commands.remove_groups(set([primary_group_11]))
166+
commands.add_groups(set([primary_group_21]))
167167
expected_primary_commands_list.append(commands)
168168

169169
user = everybody[2]
170170
commands = tests.helper.create_umapi_commands(user)
171-
commands.add_user(self.create_user_attributes_for_commands(user, rule_options['update_user_info']))
172171
commands.remove_groups(set([primary_group_11, primary_group_21]))
172+
commands.add_user(self.create_user_attributes_for_commands(user, rule_options['update_user_info']))
173173
expected_primary_commands_list.append(commands)
174174

175175
expected_secondary_commands_list = []

user_sync/rules.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -647,10 +647,10 @@ def add_umapi_user(self, user_key, groups_to_add, umapi_connectors):
647647
self.action_summary['adobe_users_created'] += 1
648648
primary_commands.add_user(attributes)
649649
if manage_groups:
650-
primary_commands.add_groups(groups_to_add)
651650
if doing_push:
652651
groups_to_remove = self.get_umapi_info(PRIMARY_UMAPI_NAME).get_mapped_groups() - groups_to_add
653652
primary_commands.remove_groups(groups_to_remove)
653+
primary_commands.add_groups(groups_to_add)
654654
umapi_connectors.get_primary_connector().send_commands(primary_commands)
655655
# add the user to secondaries, maybe with groups
656656
attributes['option'] = 'ignoreIfAlreadyExists' # can only update in the owning org
@@ -662,10 +662,11 @@ def add_umapi_user(self, user_key, groups_to_add, umapi_connectors):
662662
self.logger.info('Adding directory user to %s with user key: %s', umapi_name, user_key)
663663
secondary_commands = self.create_commands_from_directory_user(directory_user, identity_type)
664664
secondary_commands.add_user(attributes)
665-
if manage_groups and doing_push:
665+
if manage_groups:
666+
if doing_push:
667+
groups_to_remove = secondary_umapi_info.get_mapped_groups() - groups_to_add
668+
secondary_commands.remove_groups(groups_to_remove)
666669
secondary_commands.add_groups(groups_to_add)
667-
groups_to_remove = secondary_umapi_info.get_mapped_groups() - groups_to_add
668-
secondary_commands.remove_groups(groups_to_remove)
669670
umapi_connector.send_commands(secondary_commands)
670671

671672
def update_umapi_user(self, umapi_info, user_key, umapi_connector,

0 commit comments

Comments
 (0)