Skip to content

Test mode for Sign sync #621

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

Closed
wants to merge 8 commits into from
Closed
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
6 changes: 5 additions & 1 deletion examples/sign/connector-sign-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ sign_orgs:
key: "Sign API key"
# Sign account associated with admin_email value will be skipped
admin_email: "Admin user associated with key e.g. user@example.com"

# Test_mode presents post_sync output without performing any updates of users or user groups to the Sign Dashbaord
# sign_test_mode possible values are yes or no. (default no)
# sign_test_mode is independent of user_sync test mode.
# Post Sync option does not run if user_sync tool is in test mode
sign_test_mode: no
# User groups to sync to Adobe Sign
# Secondary orgs (as defined in user-sync-config.yml) can optionally be targeted
# NOTE: if targeting a group on a secondary org here, there MUST be at least one entitlement_group
Expand Down
2 changes: 1 addition & 1 deletion user_sync/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def begin_work(config_loader):
post_sync_manager = None
# get post-sync config unconditionally so we don't get an 'unused key' error
post_sync_config = config_loader.get_post_sync_options()
if rule_config['strategy'] == 'sync':
if rule_config['strategy'] == 'sync' and directory_connector_module_name is not None:
if post_sync_config:
post_sync_manager = PostSyncManager(post_sync_config, rule_config['test_mode'])
rule_config['extended_attributes'] |= post_sync_manager.get_directory_attributes()
Expand Down
2 changes: 2 additions & 0 deletions user_sync/post_sync/connectors/sign_sync/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def run(self, post_sync_data):
self.logger.info("Sign Sync disabled in test mode")
return
for org_name, sign_client in self.clients.items():
if sign_client.sign_test_mode:
self.logger.info("::SIGN TEST MODE::")
# create any new Sign groups
for new_group in set(self.user_groups[org_name]) - set(sign_client.sign_groups()):
self.logger.info("Creating new Sign group: {}".format(new_group))
Expand Down
14 changes: 10 additions & 4 deletions user_sync/post_sync/connectors/sign_sync/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def __init__(self, config):
self.host = config['host']
self.key = config['key']
self.admin_email = config['admin_email']
self.sign_test_mode = config['sign_test_mode'] if 'sign_test_mode' in config else False
self.console_org = config['console_org'] if 'console_org' in config else None
self.api_url = None
self.groups = None
Expand Down Expand Up @@ -137,12 +138,14 @@ def create_group(self, group):
:param group: str
:return:
"""
self.logger.debug("Creating {}".format(group))
if self.api_url is None or self.groups is None:
self._init()
res = requests.post(self.api_url + 'groups', headers=self.header_json(), data=json.dumps({'groupName': group}))
if res.status_code != 201:
raise AssertionException("Failed to create Sign group '{}' (reason: {})".format(group, res.reason))
self.groups[group] = res.json()['groupId']
if not self.sign_test_mode:
res = requests.post(self.api_url + 'groups', headers=self.header_json(), data=json.dumps({'groupName': group}))
if res.status_code != 201:
raise AssertionException("Failed to create Sign group '{}' (reason: {})".format(group, res.reason))
self.groups[group] = res.json()['groupId']

def update_user(self, user_id, data):
"""
Expand All @@ -154,6 +157,9 @@ def update_user(self, user_id, data):
if self.api_url is None or self.groups is None:
self._init()

if self.sign_test_mode:
return

res = requests.put(self.api_url + 'users/' + user_id, headers=self.header_json(), data=json.dumps(data))
if res.status_code != 200:
raise AssertionException("Failed to update user '{}' (reason: {})".format(user_id, res.reason))
Expand Down
2 changes: 1 addition & 1 deletion user_sync/post_sync/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def remove_umapi_user_groups(self, org_id, user_key):

def remove_umapi_user(self, org_id, user_key):
umapi_data = self.umapi_data.get(org_id)
if user_key not in umapi_data:
if umapi_data is None or user_key not in umapi_data:
return
del umapi_data[user_key]

Expand Down