@@ -783,7 +783,7 @@ def mocked_testbot(self, testbot, mocked_user_profile):
783
783
config ['SENDER_EMAIL_OVERRIDE' ] = None
784
784
testbot .bot .sender .userid = 'XXX'
785
785
testbot .bot .find_user_profile = MagicMock (return_value = mocked_user_profile )
786
- return inject_config (testbot , config )
786
+ return inject_config (testbot , config , account_email = alternative_email )
787
787
788
788
def test_alternative_email (self , mocked_testbot ):
789
789
mocked_testbot .push_message ("access to Xxx" )
@@ -801,7 +801,7 @@ class Test_override_email(ErrBotExtraTestSettings):
801
801
def mocked_testbot (self , testbot ):
802
802
config = create_config ()
803
803
config ['SENDER_EMAIL_OVERRIDE' ] = self .override_email
804
- return inject_config (testbot , config )
804
+ return inject_config (testbot , config , account_email = self . override_email )
805
805
806
806
def test_override_email (self , mocked_testbot ):
807
807
mocked_testbot .push_message ("access to Xxx" )
@@ -822,7 +822,7 @@ def mocked_testbot(self, testbot):
822
822
config ['SENDER_EMAIL_OVERRIDE' ] = None
823
823
config ['SENDER_NICK_OVERRIDE' ] = None
824
824
config ['EMAIL_SUBADDRESS' ] = self .email_subaddress
825
- return inject_config (testbot , config , admins = [f'@{ account_name } ' ])
825
+ return inject_config (testbot , config , admins = [f'@{ account_name } ' ], account_email = self . account_name_with_subaddress )
826
826
827
827
def test_email_subaddress (self , mocked_testbot ):
828
828
mocked_testbot ._bot .callback_message = MagicMock (side_effect = callback_message_fn (
@@ -1150,7 +1150,7 @@ def test_dont_delete_account_grant_when_flag_is_disabled(self, mocked_testbot):
1150
1150
1151
1151
# pylint: disable=dangerous-default-value
1152
1152
def inject_config (testbot , config , admins = ["gbin@localhost" ], tags = {}, resources_by_role = [], account_grant_exists = False ,
1153
- resources = [], account_tags = {}):
1153
+ resources = [], account_tags = {}, account_email = account_name ):
1154
1154
accessbot = testbot .bot .plugin_manager .plugins ['AccessBot' ]
1155
1155
accessbot .config = config
1156
1156
# The default implementation is not compatible with the backend identifier.
@@ -1159,8 +1159,9 @@ def inject_config(testbot, config, admins=["gbin@localhost"], tags={}, resources
1159
1159
accessbot .get_admins = MagicMock (return_value = admins )
1160
1160
accessbot .get_api_access_key = MagicMock (return_value = "api-access_key" )
1161
1161
accessbot .get_api_secret_key = MagicMock (return_value = "c2VjcmV0LWtleQ==" ) # valid base64 string
1162
- accessbot .get_sdm_service = MagicMock (
1163
- return_value = create_sdm_service_mock (tags , resources_by_role , account_grant_exists , resources , account_tags ))
1162
+ accessbot .get_sdm_service = MagicMock (return_value = create_sdm_service_mock (
1163
+ tags , resources_by_role , account_grant_exists , resources , account_tags , account_email = account_email
1164
+ ))
1164
1165
accessbot .get_resource_grant_helper = MagicMock (return_value = create_resource_grant_helper (accessbot ))
1165
1166
accessbot .get_approve_helper = MagicMock (return_value = create_approve_helper (accessbot ))
1166
1167
testbot ._bot .init_access_form_bot = MagicMock (return_value = None )
@@ -1174,13 +1175,13 @@ def create_resource_grant_helper(accessbot):
1174
1175
def create_approve_helper (accessbot ):
1175
1176
return ApproveHelper (accessbot )
1176
1177
1177
- def create_sdm_service_mock (tags , resources_by_role , account_grant_exists , resources , account_tags ):
1178
+ def create_sdm_service_mock (tags , resources_by_role , account_grant_exists , resources , account_tags , account_email = account_name ):
1178
1179
mock = MagicMock ()
1179
1180
if len (resources ) > 0 :
1180
1181
mock .get_resource_by_name = MagicMock (side_effect = raise_no_resource_found )
1181
1182
else :
1182
1183
mock .get_resource_by_name = MagicMock (return_value = create_resource_mock (tags ))
1183
- mock .get_account_by_email = MagicMock (return_value = create_account_mock (account_tags = account_tags ))
1184
+ mock .get_account_by_email = MagicMock (return_value = create_account_mock (account_tags = account_tags , account_email = account_email ))
1184
1185
mock .grant_temporary_access = MagicMock ()
1185
1186
mock .get_all_resources_by_role = MagicMock (return_value = resources_by_role )
1186
1187
mock .account_grant_exists = MagicMock (return_value = account_grant_exists )
0 commit comments