Skip to content

Change trustee to accessor #23

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions examples/example.user-sync-config.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
dashboard:
# specifies the configurations for the Adobe Enterprise Dashboards.
# By default, it would look for dashboard-owning-config.yml and
# dashboard-trustee-*-config.yml in the configuration path,
# with the yml's identifying the owning organization and trustee organizations
# dashboard-accessor-*-config.yml in the configuration path,
# with the yml's identifying the owning organization and accessor organizations
# respectively.
#
# You can also specify the configurations under this section too,
# with keys owning and trustees.
# with keys owning and accessors.
#
# Examples:
# owning: example.dashboard-config.yml
# trustees:
# accessors:
# org1: example.dashboard-config.yml

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

directory:
# (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]
Expand Down Expand Up @@ -45,7 +45,7 @@ directory:
# dashboard_groups: a list of strings identifying the dashboard groups.
#
# a group in dashboard_groups can be qualified with, the first part being
# the trustee organization name.
# the accessor organization name.
# e.g. org1::Default Acrobat Pro DC configuration
#
# examples:
Expand Down
6 changes: 3 additions & 3 deletions tests/config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ def test_get_directory_connector_options(self, mock_dict, mock_connector_conf):
@mock.patch('user_sync.config.ConfigLoader.create_dashboard_options')
@mock.patch('glob.glob1')
@mock.patch('user_sync.config.ConfigLoader.parse_string')
def test_get_dashboard_options_for_trustees(self, mock_parse, mock_glob, mock_create_dash, mock_get_dict):
def test_get_dashboard_options_for_accessors(self, mock_parse, mock_glob, mock_create_dash, mock_get_dict):
mock_create_dash.return_value = {'create_dash'}
mock_glob.return_value = {''}
mock_parse.return_value = {'organization_name': 'testOrgName'}

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

def test_get_dict_from_sources_dict(self):
Expand Down
16 changes: 8 additions & 8 deletions tests/rules_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ class RulesTest(unittest.TestCase):

def test_normal(self):
owning_organization_name = user_sync.rules.OWNING_ORGANIZATION_NAME
trustee_1_organization_name = "trustee1"
accessor_1_organization_name = "accessor1"
directory_group_1 = 'acrobat1'
directory_group_2 = 'acrobat2'
owning_group_11 = 'acrobat11'
owning_group_12 = 'acrobat12'
owning_group_21 = 'acrobat21'
directory_groups = {
directory_group_1: [user_sync.rules.Group(owning_group_11, owning_organization_name), user_sync.rules.Group('acrobat12', trustee_1_organization_name)],
directory_group_1: [user_sync.rules.Group(owning_group_11, owning_organization_name), user_sync.rules.Group('acrobat12', accessor_1_organization_name)],
directory_group_2: [user_sync.rules.Group(owning_group_21, owning_organization_name)]
}
all_users = [tests.helper.create_test_user([directory_group_1]),
Expand All @@ -61,11 +61,11 @@ def mock_load_users_and_groups(groups):
owning_commands_list = []
mock_owning_dashboard_connector = self.create_mock_dashboard_connector(owning_users, owning_commands_list)

trustee_commands_list = []
mock_trustee_dashboard_connector = self.create_mock_dashboard_connector([], trustee_commands_list)
accessor_commands_list = []
mock_accessor_dashboard_connector = self.create_mock_dashboard_connector([], accessor_commands_list)

dashboard_connectors = user_sync.rules.DashboardConnectors(mock_owning_dashboard_connector, {
trustee_1_organization_name: mock_trustee_dashboard_connector
accessor_1_organization_name: mock_accessor_dashboard_connector
})

rule_processor = user_sync.rules.RuleProcessor({})
Expand All @@ -92,14 +92,14 @@ def mock_load_users_and_groups(groups):
commands.add_user(self.create_user_attributes_for_commands(user, rule_options['update_user_info']))
expected_owning_commands_list.append(commands)

expected_trustee_commands_list = []
expected_accessor_commands_list = []
user = all_users[0]
commands = tests.helper.create_dashboard_commands(user)
commands.add_groups(set([owning_group_12]))
expected_trustee_commands_list.append(commands)
expected_accessor_commands_list.append(commands)

tests.helper.assert_equal_dashboard_commands_list(self, expected_owning_commands_list, owning_commands_list)
tests.helper.assert_equal_dashboard_commands_list(self, expected_trustee_commands_list, trustee_commands_list)
tests.helper.assert_equal_dashboard_commands_list(self, expected_accessor_commands_list, accessor_commands_list)

# default country code tests

Expand Down
16 changes: 8 additions & 8 deletions user_sync/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def begin_work(config_loader):

directory_groups = config_loader.get_directory_groups()
owning_dashboard_config = config_loader.get_dashboard_options_for_owning()
trustee_dashboard_configs = config_loader.get_dashboard_options_for_trustees()
accessor_dashboard_configs = config_loader.get_dashboard_options_for_accessors()
rule_config = config_loader.get_rule_options()

referenced_organization_names = set()
Expand All @@ -136,10 +136,10 @@ def begin_work(config_loader):
organization_name = group.organization_name
if (organization_name != user_sync.rules.OWNING_ORGANIZATION_NAME):
referenced_organization_names.add(organization_name)
referenced_organization_names.difference_update(trustee_dashboard_configs.iterkeys())
referenced_organization_names.difference_update(accessor_dashboard_configs.iterkeys())

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

directory_connector = None
directory_connector_options = None
Expand All @@ -155,11 +155,11 @@ def begin_work(config_loader):
directory_connector.initialize(directory_connector_options)

dashboard_owning_connector = user_sync.connector.dashboard.DashboardConnector("owning", owning_dashboard_config)
dashboard_trustee_connectors = {}
for trustee_organization_name, trustee_config in trustee_dashboard_configs.iteritems():
dashboard_trustee_conector = user_sync.connector.dashboard.DashboardConnector("trustee.%s" % trustee_organization_name, trustee_config)
dashboard_trustee_connectors[trustee_organization_name] = dashboard_trustee_conector
dashboard_connectors = user_sync.rules.DashboardConnectors(dashboard_owning_connector, dashboard_trustee_connectors)
dashboard_accessor_connectors = {}
for accessor_organization_name, accessor_config in accessor_dashboard_configs.iteritems():
dashboard_accessor_conector = user_sync.connector.dashboard.DashboardConnector("accessor.%s" % accessor_organization_name, accessor_config)
dashboard_accessor_connectors[accessor_organization_name] = dashboard_accessor_conector
dashboard_connectors = user_sync.rules.DashboardConnectors(dashboard_owning_connector, dashboard_accessor_connectors)

rule_processor = user_sync.rules.RuleProcessor(rule_config)
if (len(directory_groups) == 0 and rule_processor.will_manage_groups()):
Expand Down
54 changes: 27 additions & 27 deletions user_sync/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
DEFAULT_CONFIG_DIRECTORY = ''
DEFAULT_MAIN_CONFIG_FILENAME = 'user-sync-config.yml'
DEFAULT_DASHBOARD_OWNING_CONFIG_FILENAME = 'dashboard-owning-config.yml'
DEFAULT_DASHBOARD_TRUSTEE_CONFIG_FILENAME_FORMAT = 'dashboard-trustee-{organization_name}-config.yml'
DEFAULT_DASHBOARD_ACCESSOR_CONFIG_FILENAME_FORMAT = 'dashboard-accessor-{organization_name}-config.yml'

GROUP_NAME_DELIMITER = '::'

Expand Down Expand Up @@ -100,44 +100,44 @@ def get_dashboard_options_for_owning(self):
})
return self.create_dashboard_options(owning_config_sources, 'owning_dashboard')

def get_dashboard_options_for_trustees(self):
def get_dashboard_options_for_accessors(self):
dashboard_config = self.main_config.get_dict_config('dashboard', True)

trustee_config_filename_format = None
accessor_config_filename_format = None
if (dashboard_config != None):
trustee_config_filename_format = dashboard_config.get_string('trustee_config_filename_format', True)
if (trustee_config_filename_format == None):
trustee_config_filename_format = DEFAULT_DASHBOARD_TRUSTEE_CONFIG_FILENAME_FORMAT
accessor_config_filename_format = dashboard_config.get_string('accessor_config_filename_format', True)
if (accessor_config_filename_format == None):
accessor_config_filename_format = DEFAULT_DASHBOARD_ACCESSOR_CONFIG_FILENAME_FORMAT

trustee_config_file_paths = {}
trustee_config_filename_wildcard = trustee_config_filename_format.format(**{'organization_name': '*'})
for file_path in glob.glob1(self.options.get('config_directory'), trustee_config_filename_wildcard):
parse_result = self.parse_string(trustee_config_filename_format, file_path)
accessor_config_file_paths = {}
accessor_config_filename_wildcard = accessor_config_filename_format.format(**{'organization_name': '*'})
for file_path in glob.glob1(self.options.get('config_directory'), accessor_config_filename_wildcard):
parse_result = self.parse_string(accessor_config_filename_format, file_path)
organization_name = parse_result.get('organization_name')
if (organization_name != None):
trustee_config_file_paths[organization_name] = file_path
accessor_config_file_paths[organization_name] = file_path

trustees_config = None
accessors_config = None
if (dashboard_config != None):
trustees_config = dashboard_config.get_dict_config('trustees', True)
accessors_config = dashboard_config.get_dict_config('accessors', True)

trustees_options = {}
organization_names = set(trustee_config_file_paths.iterkeys())
if (trustees_config != None):
organization_names.update(trustees_config.iter_keys())
accessors_options = {}
organization_names = set(accessor_config_file_paths.iterkeys())
if (accessors_config != None):
organization_names.update(accessors_config.iter_keys())
for organization_name in organization_names:
trustee_config = None
if (trustees_config != None):
trustee_config = trustees_config.get_list(organization_name, True)
trustee_config_sources = self.as_list(trustee_config)
trustee_config_file_path = trustee_config_file_paths.get(organization_name, None)
if (trustee_config_file_path != None):
trustee_config_sources.append(trustee_config_file_path)
trustee_config_sources.append({
accessor_config = None
if (accessors_config != None):
accessor_config = accessors_config.get_list(organization_name, True)
accessor_config_sources = self.as_list(accessor_config)
accessor_config_file_path = accessor_config_file_paths.get(organization_name, None)
if (accessor_config_file_path != None):
accessor_config_sources.append(accessor_config_file_path)
accessor_config_sources.append({
'test_mode': self.options['test_mode']
})
trustees_options[organization_name] = self.create_dashboard_options(trustee_config_sources, 'trustee_dashboard[%s]' % organization_name)
return trustees_options
accessors_options[organization_name] = self.create_dashboard_options(accessor_config_sources, 'accessor_dashboard[%s]' % organization_name)
return accessors_options

def get_directory_connector_module_name(self):
'''
Expand Down
Loading