@@ -958,6 +958,10 @@ def test_resync_users(user_utils, requests_mock, mock_manage_api_key):
958958
959959
960960def test_check_user_sync (user_utils , requests_mock , mock_manage_api_key ):
961+ # Skip for version >= 9.1 as Manage API doesn't return applications field
962+ if Version (user_utils .mas_version ) >= Version ('9.1' ):
963+ pytest .skip ("check_user_sync not applicable for version >= 9.1 (Manage API doesn't return applications field)" )
964+
961965 user_id = "user1"
962966 application_id = "manage"
963967
@@ -991,29 +995,14 @@ def json_callback_core(request, context):
991995 def json_callback_manage (request , context ):
992996 nonlocal attempts
993997 # For version >= 9.1, each get_user call makes 2 requests
994- if attempts >= 4 :
995- state = "SUCCESS"
996- else :
997- state = "PENDING"
998998 attempts = attempts + 1
999999 resource_id = f"{ user_id } _resource_id"
1000+ # Manage API doesn't return applications field for version >= 9.1
10001001 return {
10011002 "member" : [{
10021003 "href" : f"api/os/masperuser/{ resource_id } " ,
10031004 "personid" : user_id ,
1004- "displayname" : user_id ,
1005- "applications" : {
1006- "other" : {
1007- "sync" : {
1008- "state" : "ERROR"
1009- }
1010- },
1011- application_id : {
1012- "sync" : {
1013- "state" : state
1014- }
1015- }
1016- }
1005+ "displayname" : user_id
10171006 }]
10181007 }
10191008
@@ -1041,6 +1030,10 @@ def json_callback_manage(request, context):
10411030
10421031
10431032def test_check_user_sync_timeout (user_utils , requests_mock , mock_manage_api_key ):
1033+ # Skip for version >= 9.1 as Manage API doesn't return applications field
1034+ if Version (user_utils .mas_version ) >= Version ('9.1' ):
1035+ pytest .skip ("check_user_sync not applicable for version >= 9.1 (Manage API doesn't return applications field)" )
1036+
10441037 user_id = "user1"
10451038 application_id = "manage"
10461039
@@ -1069,19 +1062,7 @@ def test_check_user_sync_timeout(user_utils, requests_mock, mock_manage_api_key)
10691062 "member" : [{
10701063 "href" : f"api/os/masperuser/{ resource_id } " ,
10711064 "personid" : user_id ,
1072- "displayname" : user_id ,
1073- "applications" : {
1074- "other" : {
1075- "sync" : {
1076- "state" : "ERROR"
1077- }
1078- },
1079- application_id : {
1080- "sync" : {
1081- "state" : "PENDING"
1082- }
1083- }
1084- }
1065+ "displayname" : user_id
10851066 }]
10861067 }
10871068 )
@@ -1099,6 +1080,10 @@ def test_check_user_sync_timeout(user_utils, requests_mock, mock_manage_api_key)
10991080
11001081
11011082def test_check_user_sync_appstate_notfound (user_utils , requests_mock , mock_manage_api_key ):
1083+ # Skip for version >= 9.1 as Manage API doesn't return applications field
1084+ if Version (user_utils .mas_version ) >= Version ('9.1' ):
1085+ pytest .skip ("check_user_sync not applicable for version >= 9.1 (Manage API doesn't return applications field)" )
1086+
11021087 user_id = "user1"
11031088 application_id = "manage"
11041089
@@ -1144,41 +1129,14 @@ def json_callback_core(request, context):
11441129 def json_callback_manage (request , context ):
11451130 nonlocal attempts
11461131 resource_id = f"{ user_id } _resource_id"
1147- if attempts >= 2 :
1148- ret = {
1149- "member" : [{
1150- "href" : f"api/os/masperuser/{ resource_id } " ,
1151- "personid" : user_id ,
1152- "displayname" : user_id ,
1153- "applications" : {
1154- "other" : {
1155- "sync" : {
1156- "state" : "ERROR"
1157- }
1158- },
1159- application_id : {
1160- "sync" : {
1161- "state" : "SUCCESS"
1162- }
1163- }
1164- }
1165- }]
1166- }
1167- else :
1168- ret = {
1169- "member" : [{
1170- "href" : f"api/os/masperuser/{ resource_id } " ,
1171- "personid" : user_id ,
1172- "displayname" : user_id ,
1173- "applications" : {
1174- "other" : {
1175- "sync" : {
1176- "state" : "ERROR"
1177- }
1178- },
1179- }
1180- }]
1181- }
1132+ # Manage API doesn't return applications field for version >= 9.1
1133+ ret = {
1134+ "member" : [{
1135+ "href" : f"api/os/masperuser/{ resource_id } " ,
1136+ "personid" : user_id ,
1137+ "displayname" : user_id
1138+ }]
1139+ }
11821140 attempts = attempts + 1
11831141 return ret
11841142
@@ -1215,6 +1173,10 @@ def json_callback_manage(request, context):
12151173
12161174
12171175def test_check_user_sync_appstate_transient_error (user_utils , requests_mock , mock_manage_api_key ):
1176+ # Skip for version >= 9.1 as Manage API doesn't return applications field
1177+ if Version (user_utils .mas_version ) >= Version ('9.1' ):
1178+ pytest .skip ("check_user_sync not applicable for version >= 9.1 (Manage API doesn't return applications field)" )
1179+
12181180 user_id = "user1"
12191181 application_id = "manage"
12201182
@@ -1255,36 +1217,14 @@ def json_callback_core(request, context):
12551217 def json_callback_manage (request , context ):
12561218 nonlocal attempts
12571219 resource_id = f"{ user_id } _resource_id"
1258- if attempts >= 2 :
1259- ret = {
1260- "member" : [{
1261- "href" : f"api/os/masperuser/{ resource_id } " ,
1262- "personid" : user_id ,
1263- "displayname" : user_id ,
1264- "applications" : {
1265- application_id : {
1266- "sync" : {
1267- "state" : "SUCCESS"
1268- }
1269- }
1270- }
1271- }]
1272- }
1273- else :
1274- ret = {
1275- "member" : [{
1276- "href" : f"api/os/masperuser/{ resource_id } " ,
1277- "personid" : user_id ,
1278- "displayname" : user_id ,
1279- "applications" : {
1280- application_id : {
1281- "sync" : {
1282- "state" : "ERROR"
1283- }
1284- }
1285- }
1286- }]
1287- }
1220+ # Manage API doesn't return applications field for version >= 9.1
1221+ ret = {
1222+ "member" : [{
1223+ "href" : f"api/os/masperuser/{ resource_id } " ,
1224+ "personid" : user_id ,
1225+ "displayname" : user_id
1226+ }]
1227+ }
12881228 attempts = attempts + 1
12891229 return ret
12901230
@@ -1352,14 +1292,7 @@ def test_check_user_sync_appstate_persistent_error(user_utils, requests_mock, mo
13521292 "member" : [{
13531293 "href" : f"api/os/masperuser/{ resource_id } " ,
13541294 "personid" : user_id ,
1355- "displayname" : user_id ,
1356- "applications" : {
1357- application_id : {
1358- "sync" : {
1359- "state" : "ERROR"
1360- }
1361- }
1362- }
1295+ "displayname" : user_id
13631296 }]
13641297 }
13651298 )
@@ -2289,12 +2222,16 @@ def test_create_initial_user_for_saas(
22892222 user_utils .await_mas_application_availability .assert_not_called ()
22902223 user_utils .set_user_application_permission .assert_not_called ()
22912224
2292- # check_user_sync is called for all versions
2293- user_utils .check_user_sync .assert_has_calls ([
2294- call (user_id , "manage" ),
2295- call (user_id , "iot" ),
2296- call (user_id , "facilities" )
2297- ])
2225+ # check_user_sync is only called for version < 9.1
2226+ # For version >= 9.1, Manage API doesn't return applications field, so sync check is not performed
2227+ if mas_version == '9.0' :
2228+ user_utils .check_user_sync .assert_has_calls ([
2229+ call (user_id , "manage" ),
2230+ call (user_id , "iot" ),
2231+ call (user_id , "facilities" )
2232+ ])
2233+ else : # 9.1
2234+ user_utils .check_user_sync .assert_not_called ()
22982235
22992236 if len (manage_security_groups ) > 0 :
23002237 user_utils .create_or_get_manage_api_key_for_user .assert_called_once_with ("MAXADMIN" , temporary = True )
0 commit comments