Skip to content

Commit a9665ad

Browse files
committed
fix umapi engine tests
1 parent 651d211 commit a9665ad

File tree

2 files changed

+40
-35
lines changed

2 files changed

+40
-35
lines changed

tests/test_umapi_engine.py

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ def iter_users(self):
6565
def test_is_umapi_user_excluded(rule_processor):
6666
in_primary_org = True
6767
rule_processor.exclude_identity_types = ['adobeID']
68-
user_key = 'adobeID,[email protected],'
68+
user_key = 'adobeID,[email protected],,'
6969
current_groups = {'default acrobat pro dc configuration', 'one', '_admin_group a'}
7070
assert rule_processor.is_umapi_user_excluded(in_primary_org, user_key, current_groups)
7171

72-
user_key = 'federatedID,[email protected],'
72+
user_key = 'federatedID,[email protected],,'
7373
rule_processor.exclude_groups = {'one'}
7474
assert rule_processor.is_umapi_user_excluded(in_primary_org, user_key, current_groups)
7575

76-
user_key = 'federatedID,[email protected],'
76+
user_key = 'federatedID,[email protected],,'
7777
rule_processor.exclude_groups = set()
7878
compiled_expression = re.compile(r'\A' + "[email protected]" + r'\Z', re.IGNORECASE)
7979
rule_processor.exclude_users = {compiled_expression}
@@ -265,33 +265,33 @@ def test_get_user_attribute_difference(rule_processor, mock_dir_user, mock_umapi
265265

266266
def test_get_directory_user_key(rule_processor):
267267
mock_directory_user_dict = {
268-
'email': 'exampledirectory@exmaple.com',
269-
'username': 'exampledirectory@example.com',
268+
'email': 'email@example.com',
269+
'username': 'username@example.com',
270270
'domain': 'example.com',
271271
'identity_type': 'federatedID'
272272
}
273273
actual_result = rule_processor.get_directory_user_key(mock_directory_user_dict)
274-
assert actual_result == 'federatedID,exampledirectory@example.com,'
274+
assert actual_result == 'federatedID,username@example.com,,[email protected]'
275275

276276

277277
def test_get_umapi_user_key(rule_processor):
278278
mock_umapi_user_dict = {
279-
'email': '7of9@exmaple.com',
280-
'username': '7of9@example.com',
279+
'email': 'email@example.com',
280+
'username': 'username@example.com',
281281
'domain': 'example.com',
282282
'type': 'federatedID'
283283
}
284284

285285
actual_result = rule_processor.get_umapi_user_key(mock_umapi_user_dict)
286-
assert actual_result == 'federatedID,7of9@example.com,'
286+
assert actual_result == 'federatedID,username@example.com,,[email protected]'
287287

288288

289289
def test_get_user_key(rule_processor):
290-
key = rule_processor.get_user_key("federatedID", "wriker@example.com", "wriker@example.com", "example.com")
291-
assert key == 'federatedID,wriker@example.com,'
290+
key = rule_processor.get_user_key("federatedID", "username@example.com", "example.com", "email@example.com")
291+
assert key == 'federatedID,username@example.com,,[email protected]'
292292

293-
key = rule_processor.get_user_key("federatedID", "wriker", "example.com")
294-
assert key == 'federatedID,wriker,example.com'
293+
key = rule_processor.get_user_key("federatedID", "username", "example.com", "email@example.com")
294+
assert key == 'federatedID,username,example.com,email@example.com'
295295

296296
assert not rule_processor.get_user_key(None, "[email protected]", "[email protected]", "example.com")
297297
assert not rule_processor.get_user_key("federatedID", None, "[email protected]")
@@ -335,26 +335,30 @@ def test_read_stray_key_map(csv_reader, rule_processor):
335335
csv_mock_data = [
336336
{
337337
'type': 'adobeID',
338-
'username': '[email protected]',
339-
'domain': 'example.com'},
338+
'email': '[email protected]',
339+
'domain': 'example.com'
340+
},
340341
{
341342
'type': 'federatedID',
342-
'username': '[email protected]',
343-
'domain': 'example.com'},
343+
'email': '[email protected]',
344+
'domain': 'example.com'
345+
},
344346
{
345347
'type': 'enterpriseID',
346-
'username': '[email protected]',
347-
'domain': 'example.com'}
348+
'email': '[email protected]',
349+
'domain': 'example.com'
350+
},
348351
]
349352

350353
csv_reader.return_value = csv_mock_data
351354
rule_processor.read_stray_key_map('')
352355
actual_value = rule_processor.stray_key_map
353356
expected_value = {
354357
None: {
355-
'federatedID,[email protected],': None,
356-
'enterpriseID,[email protected],': None,
357-
'adobeID,[email protected],': None}
358+
359+
'federatedID,[email protected],,[email protected]': None,
360+
'enterpriseID,[email protected],,[email protected]': None,
361+
}
358362
}
359363

360364
assert expected_value == actual_value
@@ -363,15 +367,15 @@ def test_read_stray_key_map(csv_reader, rule_processor):
363367
csv_mock_data = [
364368
{
365369
'type': 'adobeID',
366-
'username': 'remo@sample.com',
370+
'email': 'remove@example.com',
367371
'domain': 'sample.com',
368372
'umapi': 'secondary'},
369373
{
370374
'type': 'federatedID',
371-
'username': '[email protected]'},
375+
'email': '[email protected]'},
372376
{
373377
'type': 'enterpriseID',
374-
'username': '[email protected]',
378+
'email': '[email protected]',
375379
'domain': 'example.com'}
376380

377381
]
@@ -380,12 +384,13 @@ def test_read_stray_key_map(csv_reader, rule_processor):
380384
actual_value = rule_processor.stray_key_map
381385
expected_value = {
382386
'secondary': {
383-
'adobeID,remo@sample.com,': None
387+
'adobeID,remove@example.com,,[email protected]': None
384388
},
385389
None: {
386-
'federatedID,[email protected],': None,
387-
'enterpriseID,[email protected],': None,
388-
'adobeID,[email protected],': None}
390+
'federatedID,[email protected],,[email protected]': None,
391+
'enterpriseID,[email protected],,[email protected]': None,
392+
393+
}
389394
}
390395
assert expected_value == actual_value
391396

@@ -396,18 +401,18 @@ def test_write_stray_key_map(rule_processor, tmpdir):
396401
rule_processor.stray_list_output_path = tmp_file
397402
rule_processor.stray_key_map = {
398403
'secondary': {
399-
'adobeID,[email protected],': set(),
400-
'enterpriseID,[email protected],': set(), },
404+
405+
'enterpriseID,[email protected],,[email protected]': set(), },
401406
None: {
402-
'enterpriseID,[email protected],': set(),
403-
'federatedID,[email protected],': set()
407+
'enterpriseID,[email protected],,[email protected]': set(),
408+
'federatedID,[email protected],,[email protected]': set()
404409
}}
405410

406411
rule_processor.write_stray_key_map()
407412
with open(tmp_file, 'r') as our_file:
408413
reader = csv.reader(our_file)
409414
actual = list(reader)
410-
expected = [['type', 'username', 'domain', 'umapi'],
415+
expected = [['type', 'email', 'domain', 'umapi'],
411416
['adobeID', '[email protected]', '', 'secondary'],
412417
['enterpriseID', '[email protected]', '', 'secondary'],
413418
['enterpriseID', '[email protected]', '', ''],

user_sync/engine/umapi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ def read_stray_key_map(self, file_path, delimiter=None):
11451145

11461146
if email is None:
11471147
if user is not None:
1148-
self.logger.warn("Please specify user email address for user '%s', action may fail otherwise", user)
1148+
self.logger.warning("Please specify user email address for user '%s', action may fail otherwise", user)
11491149
else:
11501150
self.logger.warn("Username or email address must be specified for record: %s", row)
11511151
continue

0 commit comments

Comments
 (0)