Skip to content

Commit 0a5207d

Browse files
authored
Merge pull request #35 from adobe-apiplatform/revert-34-v1
Revert "merge v1 for v1.1 release"
2 parents a20f087 + 4e46d5c commit 0a5207d

File tree

13 files changed

+110
-322
lines changed

13 files changed

+110
-322
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ __pycache__/
99
# Distribution / packaging
1010
.Python
1111
env/
12-
/build/
12+
build/
1313
develop-eggs/
1414
dist/
1515
downloads/

RELEASE_NOTES.md

Lines changed: 0 additions & 34 deletions
This file was deleted.

examples/example.user-sync-config.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
dashboard:
22
# specifies the configurations for the Adobe Enterprise Dashboards.
33
# By default, it would look for dashboard-owning-config.yml and
4-
# dashboard-accessor-*-config.yml in the configuration path,
5-
# with the yml's identifying the owning organization and accessor organizations
4+
# dashboard-trustee-*-config.yml in the configuration path,
5+
# with the yml's identifying the owning organization and trustee organizations
66
# respectively.
77
#
88
# You can also specify the configurations under this section too,
9-
# with keys owning and accessors.
9+
# with keys owning and trustees.
1010
#
1111
# Examples:
1212
# owning: example.dashboard-config.yml
13-
# accessors:
13+
# trustees:
1414
# org1: example.dashboard-config.yml
1515

16-
# specifies the filename format for the accessor org configurations.
16+
# specifies the filename format for the trustee org configurations.
1717
# a filename that matches the format will have the organization name extracted
1818
# from the filename. Default is:
19-
# accessor_config_filename_format: "dashboard-accessor-{organization_name}-config.yml"
19+
# trustee_config_filename_format: "dashboard-trustee-{organization_name}-config.yml"
2020

2121
directory:
2222
# (optional) Default country code to use if directory doesn't provide one for a user [Must be two-letter ISO-3166 code - see https://en.wikipedia.org/wiki/ISO_3166-1]
@@ -45,7 +45,7 @@ directory:
4545
# dashboard_groups: a list of strings identifying the dashboard groups.
4646
#
4747
# a group in dashboard_groups can be qualified with, the first part being
48-
# the accessor organization name.
48+
# the trustee organization name.
4949
# e.g. org1::Default Acrobat Pro DC configuration
5050
#
5151
# examples:
@@ -66,10 +66,6 @@ directory:
6666
# Default is:
6767
# user_identity_type: enterpriseID
6868

69-
limits:
70-
max_deletions_per_run: 10 # if --remove-nonexistent-users is specified, this is the most users that will be removed. Others will be left for a later run. A critical message will be logged.
71-
max_missing_users: 200 # if more than this number of user accounts are not found in the directory, user sync will abort with an error and a critical message will be logged.
72-
7369
logging:
7470
# specifies whether you wish to generate a log file
7571
# 'True' or 'False'
Binary file not shown.
Binary file not shown.

tests/config_test.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ def test_get_directory_connector_options(self, mock_dict, mock_connector_conf):
5555
@mock.patch('user_sync.config.ConfigLoader.create_dashboard_options')
5656
@mock.patch('glob.glob1')
5757
@mock.patch('user_sync.config.ConfigLoader.parse_string')
58-
def test_get_dashboard_options_for_accessors(self, mock_parse, mock_glob, mock_create_dash, mock_get_dict):
58+
def test_get_dashboard_options_for_trustees(self, mock_parse, mock_glob, mock_create_dash, mock_get_dict):
5959
mock_create_dash.return_value = {'create_dash'}
6060
mock_glob.return_value = {''}
6161
mock_parse.return_value = {'organization_name': 'testOrgName'}
6262

63-
self.assertEquals(self.conf_load.get_dashboard_options_for_accessors(), {'testOrgName': set(['create_dash'])},
64-
'We return with accessor option in the expected format')
63+
self.assertEquals(self.conf_load.get_dashboard_options_for_trustees(), {'testOrgName': set(['create_dash'])},
64+
'We return with trustee option in the expected format')
6565
self.assertEquals(mock_create_dash.call_count, 1, 'create dashboard options was called')
6666

6767
def test_get_dict_from_sources_dict(self):
@@ -95,8 +95,6 @@ def test_get_rule_options(self, mock_id_type,mock_get_dict,mock_get_string):
9595
self.assertEquals(self.conf_load.get_rule_options(), {'username_filter_regex': None,
9696
'update_user_info': True,
9797
'manage_groups': True,
98-
'max_deletions_per_run': 1,
99-
'max_missing_users': 1,
10098
'new_account_type': 'new_acc',
10199
'directory_group_filter': None,
102100
'default_country_code': 'test',

tests/helper.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,4 @@ def create_action_manager():
8585

8686
class MockGetString():
8787
def get_string(self,test1,test2):
88-
return 'test'
89-
90-
def get_int(self,test1):
91-
return 1
88+
return 'test'

tests/rules_test.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ class RulesTest(unittest.TestCase):
3030

3131
def test_normal(self):
3232
owning_organization_name = user_sync.rules.OWNING_ORGANIZATION_NAME
33-
accessor_1_organization_name = "accessor1"
33+
trustee_1_organization_name = "trustee1"
3434
directory_group_1 = 'acrobat1'
3535
directory_group_2 = 'acrobat2'
3636
owning_group_11 = 'acrobat11'
3737
owning_group_12 = 'acrobat12'
3838
owning_group_21 = 'acrobat21'
3939
directory_groups = {
40-
directory_group_1: [user_sync.rules.Group(owning_group_11, owning_organization_name), user_sync.rules.Group('acrobat12', accessor_1_organization_name)],
40+
directory_group_1: [user_sync.rules.Group(owning_group_11, owning_organization_name), user_sync.rules.Group('acrobat12', trustee_1_organization_name)],
4141
directory_group_2: [user_sync.rules.Group(owning_group_21, owning_organization_name)]
4242
}
4343
all_users = [tests.helper.create_test_user([directory_group_1]),
@@ -61,11 +61,11 @@ def mock_load_users_and_groups(groups):
6161
owning_commands_list = []
6262
mock_owning_dashboard_connector = self.create_mock_dashboard_connector(owning_users, owning_commands_list)
6363

64-
accessor_commands_list = []
65-
mock_accessor_dashboard_connector = self.create_mock_dashboard_connector([], accessor_commands_list)
64+
trustee_commands_list = []
65+
mock_trustee_dashboard_connector = self.create_mock_dashboard_connector([], trustee_commands_list)
6666

6767
dashboard_connectors = user_sync.rules.DashboardConnectors(mock_owning_dashboard_connector, {
68-
accessor_1_organization_name: mock_accessor_dashboard_connector
68+
trustee_1_organization_name: mock_trustee_dashboard_connector
6969
})
7070

7171
rule_processor = user_sync.rules.RuleProcessor({})
@@ -92,18 +92,18 @@ def mock_load_users_and_groups(groups):
9292
commands.add_user(self.create_user_attributes_for_commands(user, rule_options['update_user_info']))
9393
expected_owning_commands_list.append(commands)
9494

95-
expected_accessor_commands_list = []
95+
expected_trustee_commands_list = []
9696
user = all_users[0]
9797
commands = tests.helper.create_dashboard_commands(user)
9898
commands.add_groups(set([owning_group_12]))
99-
expected_accessor_commands_list.append(commands)
99+
expected_trustee_commands_list.append(commands)
100100

101101
tests.helper.assert_equal_dashboard_commands_list(self, expected_owning_commands_list, owning_commands_list)
102-
tests.helper.assert_equal_dashboard_commands_list(self, expected_accessor_commands_list, accessor_commands_list)
102+
tests.helper.assert_equal_dashboard_commands_list(self, expected_trustee_commands_list, trustee_commands_list)
103103

104104
# default country code tests
105-
@mock.patch('logging.getLogger')
106-
def _do_country_code_test(self, mock_dashboard_commands, mock_connectors, identity_type, default_country_code, user_country_code, expected_country_code, mock_logger):
105+
106+
def _do_country_code_test(self, mock_dashboard_commands, mock_connectors, identity_type, default_country_code, user_country_code, expected_country_code):
107107
expected_result = {'lastname': 'User1', 'email': '[email protected]', 'firstname': '!Openldap CCE', 'option': 'updateIfAlreadyExists'}
108108
if (expected_country_code):
109109
expected_result['country'] = expected_country_code
@@ -121,11 +121,7 @@ def _do_country_code_test(self, mock_dashboard_commands, mock_connectors, identi
121121
'uid': '001'}
122122
}
123123
mock_rules.add_dashboard_user('[email protected]', mock_connectors)
124-
125-
if (identity_type == 'federatedID' and default_country_code == None and user_country_code == None):
126-
mock_rules.logger.error.assert_called_with('User %s cannot be added as it has a blank country code and no default has been specified.','[email protected]')
127-
else:
128-
mock_dashboard_commands.return_value.add_user.assert_called_with(expected_result)
124+
mock_dashboard_commands.return_value.add_user.assert_called_with(expected_result)
129125

130126
# federatedId
131127
@mock.patch('user_sync.rules.DashboardConnectors')

user_sync/app.py

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ def init_log(logging_config):
9292
builder = user_sync.config.OptionsBuilder(logging_config)
9393
builder.set_bool_value('log_to_file', False)
9494
builder.set_string_value('file_log_directory', 'logs')
95-
builder.set_string_value('file_log_level', 'info')
96-
builder.set_string_value('console_log_level', 'info')
95+
builder.set_string_value('file_log_level', 'debug')
96+
builder.set_string_value('console_log_level', None)
9797
options = builder.get_options()
9898

9999
level_lookup = {
@@ -105,18 +105,11 @@ def init_log(logging_config):
105105
}
106106

107107
console_log_level = level_lookup.get(options['console_log_level'])
108-
if (console_log_level == None):
109-
console_log_level = logging.INFO
110-
logger.log(logging.WARNING, 'Unknown console log level: %s setting to info' % options['console_log_level'])
111-
console_log_handler.setLevel(console_log_level)
112-
113-
108+
if (console_log_level != None):
109+
console_log_handler.setLevel(console_log_level)
110+
114111
if options['log_to_file'] == True:
115-
unknown_file_log_level = False
116-
file_log_level = level_lookup.get(options['file_log_level'])
117-
if (file_log_level == None):
118-
file_log_level = logging.INFO
119-
unknown_file_log_level = True
112+
file_log_level = level_lookup.get(options['file_log_level'], logging.NOTSET)
120113
file_log_directory = options['file_log_directory']
121114
if not os.path.exists(file_log_directory):
122115
os.makedirs(file_log_directory)
@@ -126,8 +119,6 @@ def init_log(logging_config):
126119
fileHandler.setLevel(file_log_level)
127120
fileHandler.setFormatter(logging.Formatter(LOG_STRING_FORMAT, LOG_DATE_FORMAT))
128121
logging.getLogger().addHandler(fileHandler)
129-
if (unknown_file_log_level == True):
130-
logger.log(logging.WARNING, 'Unknown file log level: %s setting to info' % options['file_log_level'])
131122

132123
def begin_work(config_loader):
133124
'''
@@ -136,7 +127,7 @@ def begin_work(config_loader):
136127

137128
directory_groups = config_loader.get_directory_groups()
138129
owning_dashboard_config = config_loader.get_dashboard_options_for_owning()
139-
accessor_dashboard_configs = config_loader.get_dashboard_options_for_accessors()
130+
trustee_dashboard_configs = config_loader.get_dashboard_options_for_trustees()
140131
rule_config = config_loader.get_rule_options()
141132

142133
referenced_organization_names = set()
@@ -145,10 +136,10 @@ def begin_work(config_loader):
145136
organization_name = group.organization_name
146137
if (organization_name != user_sync.rules.OWNING_ORGANIZATION_NAME):
147138
referenced_organization_names.add(organization_name)
148-
referenced_organization_names.difference_update(accessor_dashboard_configs.iterkeys())
139+
referenced_organization_names.difference_update(trustee_dashboard_configs.iterkeys())
149140

150141
if (len(referenced_organization_names) > 0):
151-
raise user_sync.error.AssertionException('dashboard_groups have references to unknown accessor dashboards: %s' % referenced_organization_names)
142+
raise user_sync.error.AssertionException('dashboard_groups have references to unknown trustee dashboards: %s' % referenced_organization_names)
152143

153144
directory_connector = None
154145
directory_connector_options = None
@@ -164,11 +155,11 @@ def begin_work(config_loader):
164155
directory_connector.initialize(directory_connector_options)
165156

166157
dashboard_owning_connector = user_sync.connector.dashboard.DashboardConnector("owning", owning_dashboard_config)
167-
dashboard_accessor_connectors = {}
168-
for accessor_organization_name, accessor_config in accessor_dashboard_configs.iteritems():
169-
dashboard_accessor_conector = user_sync.connector.dashboard.DashboardConnector("accessor.%s" % accessor_organization_name, accessor_config)
170-
dashboard_accessor_connectors[accessor_organization_name] = dashboard_accessor_conector
171-
dashboard_connectors = user_sync.rules.DashboardConnectors(dashboard_owning_connector, dashboard_accessor_connectors)
158+
dashboard_trustee_connectors = {}
159+
for trustee_organization_name, trustee_config in trustee_dashboard_configs.iteritems():
160+
dashboard_trustee_conector = user_sync.connector.dashboard.DashboardConnector("trustee.%s" % trustee_organization_name, trustee_config)
161+
dashboard_trustee_connectors[trustee_organization_name] = dashboard_trustee_conector
162+
dashboard_connectors = user_sync.rules.DashboardConnectors(dashboard_owning_connector, dashboard_trustee_connectors)
172163

173164
rule_processor = user_sync.rules.RuleProcessor(rule_config)
174165
if (len(directory_groups) == 0 and rule_processor.will_manage_groups()):
@@ -275,7 +266,7 @@ def main():
275266

276267
except user_sync.error.AssertionException as e:
277268
if (not e.is_reported()):
278-
logger.critical(e.message)
269+
logger.error(e.message)
279270
e.set_reported()
280271
except:
281272
try:

0 commit comments

Comments
 (0)