1
+ import json
2
+ from unittest import mock
3
+
1
4
import pytest
5
+ from requests import Response
6
+
7
+ from user_sync .post_sync import PostSyncConnector
8
+ from user_sync .post_sync .connectors .sign_sync import SignClient , SignConnector
2
9
from user_sync .post_sync .manager import PostSyncData
3
10
4
11
@@ -51,3 +58,41 @@ def test_add_remove_groups(example_user):
51
58
delta_groups = example_user ['groups' ] | set (groups_add )
52
59
delta_groups -= set (groups_remove )
53
60
assert post_sync_data .umapi_data [None ][email_id ]['groups' ] == delta_groups
61
+
62
+
63
+ @mock .patch ('requests.get' )
64
+ @mock .patch ('user_sync.post_sync.connectors.sign_sync.client.SignClient._init' )
65
+ def test_update_sign_users (mock_client , mock_get , example_user ):
66
+ def mock_response (data ):
67
+ r = Response ()
68
+ r .status_code = 200
69
+ r ._content = json .dumps (data ).encode ()
70
+ return r
71
+ user_list = mock_response ({'userInfoList' : [{"userId" : "123" }]})
72
+ user_one = mock_response ({
'userStatus' :
'ACTIVE' ,
'email' :
'[email protected] ' })
73
+ mock_get .side_effect = [user_list , user_one ]
74
+ client_config = {
75
+ 'console_org' : None ,
76
+ 'host' : 'api.na2.echosignstage.com' ,
77
+ 'key' : 'allsortsofgibberish1234567890' ,
78
+ 'admin_email' :
'[email protected] '
79
+ }
80
+ sign_client = SignClient (client_config )
81
+ sign_client .api_url = "whatever"
82
+ connector_config = {
83
+ 'sign_orgs' : [client_config ],
84
+ 'entitlement_groups' : ['group1' ]
85
+ }
86
+ sign_connector = SignConnector (connector_config )
87
+ # set the email from the fixture example user to use an uppercase letter
88
+ example_user [
'email' ]
= '[email protected] '
89
+ # make a new dict indexed by the uppercase email to pass in to the update method from the sign connector
90
+ umapi_users = {example_user ['email' ]: example_user }
91
+
92
+ def should_sync_replacement (umapi_user , sign_user , org_name ):
93
+ assert sign_user is not None
94
+ # going to exit the update method early because this bug fix is only concerned with the email mismatch
95
+ # looking up the sign user from the umapi_users dict should return a sign user even if there is a casing mismatch
96
+ sign_connector .should_sync = should_sync_replacement
97
+ sign_connector .update_sign_users (umapi_users , sign_client , 'testOrg' )
98
+
0 commit comments