@@ -283,8 +283,6 @@ def test_success_extended_attribute_key(self, mock_requests, mock_find_group):
283
283
temp_var = list (iterGroupResponse )
284
284
285
285
self .assertIn ('additionalTest' , temp_var [0 ]['source_attributes' ])
286
- self .assertEqual (temp_var [0 ]['source_attributes' ]['additionalTest' ], 'TestValue1234' )
287
-
288
286
289
287
@mock .patch ('user_sync.connector.directory_okta.OktaDirectoryConnector.find_group' )
290
288
@mock .patch ('okta.framework.ApiClient.requests' )
@@ -311,3 +309,79 @@ def test_success_extended_attribute_value(self, mock_requests, mock_find_group):
311
309
temp_var = list (iterGroupResponse )
312
310
313
311
self .assertEqual (temp_var [0 ]['source_attributes' ]['additionalTest' ], 'TestValue1234' )
312
+
313
+ @mock .patch ('user_sync.connector.directory_okta.OktaDirectoryConnector.find_group' )
314
+ @mock .patch ('okta.framework.ApiClient.requests' )
315
+ def test_non_existence_extended_attribute_key (self , mock_requests , mock_find_group ):
316
+ # This test the extended_attribute feature
317
+ # user object should contain badattribute eventhough it does not exist in Okta User Profile
318
+
319
+ mock_requests .get .return_value = self .mock_response (200 , [{"id" : "00u9s60df0cO5cU3Y0h7" ,
320
+ "profile" : {
"login" :
"[email protected] " ,
321
+ "mobilePhone" : None ,
322
+
323
+ "secondEmail" : None , "firstName" : "Test" ,
324
+ "lastName" : "User" ,
325
+ "countryCode" : "US" ,
326
+ "additionalTest" : "TestValue1234" }}])
327
+ mockID = mock .Mock ()
328
+ mockID .id = "TestGroup1"
329
+ mock_find_group .return_value = mockID
330
+
331
+ directory = self .directory
332
+ directory .options = {'source_filters' : {}, 'all_users_filter' : None , 'group_filter_format' : '{group}' }
333
+ extended_attributes = ['firstName' , 'lastName' , 'login' , 'email' , 'countryCode' , 'badattribute' ]
334
+ iterGroupResponse = directory .iter_group_members ("testGroup" , extended_attributes )
335
+ temp_var = list (iterGroupResponse )
336
+
337
+ self .assertIn ('badattribute' , temp_var [0 ]['source_attributes' ])
338
+
339
+ @mock .patch ('user_sync.connector.directory_okta.OktaDirectoryConnector.find_group' )
340
+ @mock .patch ('okta.framework.ApiClient.requests' )
341
+ def test_non_existence_extended_attribute_value (self , mock_requests , mock_find_group ):
342
+ # This test the extended_attribute feature
343
+ # user object should contain badattribute key eventhough it does not exist in Okta User Profile
344
+
345
+ mock_requests .get .return_value = self .mock_response (200 , [{"id" : "00u9s60df0cO5cU3Y0h7" ,
346
+ "profile" : {
"login" :
"[email protected] " ,
347
+ "mobilePhone" : None ,
348
+
349
+ "secondEmail" : None , "firstName" : "Test" ,
350
+ "lastName" : "User" ,
351
+ "countryCode" : "US" ,
352
+ "additionalTest" : "TestValue1234" }}])
353
+ mockID = mock .Mock ()
354
+ mockID .id = "TestGroup1"
355
+ mock_find_group .return_value = mockID
356
+
357
+ directory = self .directory
358
+ directory .options = {'source_filters' : {}, 'all_users_filter' : None , 'group_filter_format' : '{group}' }
359
+ extended_attributes = ['firstName' , 'lastName' , 'login' , 'email' , 'countryCode' , 'badattribute' ]
360
+ iterGroupResponse = directory .iter_group_members ("testGroup" , extended_attributes )
361
+ temp_var = list (iterGroupResponse )
362
+ self .assertEqual (temp_var [0 ]['source_attributes' ]['badattribute' ], None )
363
+
364
+ @mock .patch ('user_sync.connector.directory_okta.OktaDirectoryConnector.find_group' )
365
+ @mock .patch ('okta.framework.ApiClient.requests' )
366
+ def test_invalid_missing_profile_user (self , mock_requests , mock_find_group ):
367
+ # This test the extended_attribute feature
368
+ # user object should contain badattribute value of None eventhough it does not exist in Okta User Profile
369
+
370
+ mock_requests .get .return_value = self .mock_response (200 , [{"id" : "00u9s60df0cO5cU3Y0h7" ,
371
+ "profile" : {
"login" :
"[email protected] " ,
372
+ "mobilePhone" : None ,
373
+
374
+ "secondEmail" : None , "firstName" : "Test" ,
375
+ "lastName" : None ,
376
+ "countryCode" : "US" ,
377
+ "additionalTest" : "TestValue1234" }}])
378
+ mockID = mock .Mock ()
379
+ mockID .id = "TestGroup1"
380
+ mock_find_group .return_value = mockID
381
+
382
+ directory = self .directory
383
+ directory .options = {'source_filters' : {}, 'all_users_filter' : None , 'group_filter_format' : '{group}' }
384
+ extended_attributes = ['firstName' , 'lastName' , 'login' , 'email' , 'countryCode' , 'badattribute' ]
385
+ iterGroupResponse = directory .iter_group_members ("testGroup" , extended_attributes )
386
+ temp_var = list (iterGroupResponse )
387
+ self .assertEqual (temp_var [0 ]['source_attributes' ]['badattribute' ], None )
0 commit comments