Skip to content

Commit 8630435

Browse files
committed
Merge remote-tracking branch 'origin/v2' into v2
2 parents b3bef69 + abab686 commit 8630435

File tree

6 files changed

+47
-0
lines changed

6 files changed

+47
-0
lines changed

examples/config files - basic/connector-adobe-console.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ integration:
3434
# NOTE: Credentials can be stored securely with these options
3535
# secure_client_id_key: my_client_id
3636
# secure_client_secret_key: my_client_secret
37+
#
3738
# See https://adobe-apiplatform.github.io/user-sync.py/en/user-manual/sync_from_console.html#credential-security

examples/config files - basic/user-sync-config.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ adobe_users:
1818
connectors:
1919
umapi: "connector-umapi.yml"
2020

21+
# Enable or disable user attributes to be updated when `--update-user-info` or `update_user_info` is enabled
22+
# `username` updates are disabled by default
23+
update_attributes:
24+
- firstname
25+
- lastname
26+
- email
27+
# - username
28+
2129
# --- Directory Users Options
2230
# Governs directory-side behavior and configuration related to the identity source
2331
# See https://adobe-apiplatform.github.io/user-sync.py/en/user-manual/configuring_user_sync_tool.html#directory_users-config

tests/fixture/user-sync-config.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ adobe_users:
55
exclude_users: null
66
connectors:
77
umapi: connector-umapi.yml
8+
update_attributes:
9+
- firstname
10+
- lastname
11+
- email
812
directory_users:
913
user_identity_type: federatedID
1014
default_country_code: US

tests/test_config.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,27 @@ def test_max_adobe_percentage(cleanup, default_args, modify_root_config, cf_load
5858
UMAPIConfigLoader(default_args).get_engine_options()
5959

6060

61+
def test_update_attributes(cleanup, default_args, test_resources, modify_root_config, cf_loader):
62+
config = cf_loader.load_root_config(test_resources['umapi_root_config'])
63+
assert 'adobe_users' in config and 'update_attributes' in config['adobe_users']
64+
assert 'firstname' in config['adobe_users']['update_attributes']
65+
assert 'lastname' in config['adobe_users']['update_attributes']
66+
assert 'email' in config['adobe_users']['update_attributes']
67+
assert 'username' not in config['adobe_users']['update_attributes']
68+
69+
reset_rule_options()
70+
options = UMAPIConfigLoader(default_args).get_engine_options()
71+
assert 'update_attributes' in options
72+
assert 'firstname' in options['update_attributes']
73+
assert 'lastname' in options['update_attributes']
74+
assert 'email' in options['update_attributes']
75+
76+
root_config_file = modify_root_config(['adobe_users', 'update_attributes'], ['firstname', 'lastname', 'foo'])
77+
config = cf_loader.load_root_config(root_config_file)
78+
reset_rule_options()
79+
with pytest.raises(AssertionException):
80+
UMAPIConfigLoader(default_args).get_engine_options()
81+
6182
def test_additional_groups_config(cleanup, default_args, modify_root_config, cf_loader):
6283
addl_groups = [
6384
{

user_sync/config/user_sync.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,15 @@ def get_engine_options(self):
518518
exclude_groups.append(group.get_group_name())
519519
options['exclude_groups'] = exclude_groups
520520

521+
update_attributes = adobe_config.get_list('update_attributes', True)
522+
valid_attributes = ['firstname', 'lastname', 'email', 'username']
523+
if update_attributes is not None:
524+
update_attributes = [attr.lower() for attr in update_attributes]
525+
for attr in update_attributes:
526+
if attr not in valid_attributes:
527+
raise AssertionException(f"'{attr}' is not a valid attribute for user updates")
528+
options['update_attributes'] = update_attributes
529+
521530
# get the limits
522531
limits_config = self.main_config.get_dict_config('limits')
523532
max_missing = limits_config.get_value('max_adobe_only_users', (int, str), False)

user_sync/engine/umapi.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class RuleProcessor(object):
5757
'stray_list_input_path': None,
5858
'stray_list_output_path': None,
5959
'test_mode': False,
60+
'update_attributes': ['firstname', 'lastname', 'email'],
6061
'update_user_info': False,
6162
'username_filter_regex': None,
6263
}
@@ -1078,6 +1079,9 @@ def get_user_attribute_difference(self, directory_user, umapi_user):
10781079
else:
10791080
diff = value != umapi_value
10801081
if diff:
1082+
if key not in self.options['update_attributes']:
1083+
self.logger.warn(f"'{key}' has changed for user '{self.get_umapi_user_key(umapi_user)}', but that attribute isn't configured for updating")
1084+
continue
10811085
differences[key] = value
10821086
return differences
10831087

0 commit comments

Comments
 (0)