@@ -1047,6 +1047,45 @@ def test_search_all(self):
10471047 timeout = DEFAULT_TIMEOUT_SECONDS ,
10481048 )
10491049
1050+ # Test success flow with tenant_role_ids and tenant_role_names
1051+ with patch ("requests.post" ) as mock_post :
1052+ network_resp = mock .Mock ()
1053+ network_resp .ok = True
1054+ network_resp .json .return_value = json .loads (
1055+ """{"users": [{"id": "u1"}, {"id": "u2"}]}"""
1056+ )
1057+ mock_post .return_value = network_resp
1058+ resp = self .client .mgmt .user .search_all (
1059+ tenant_role_ids = {"tenant1" : ["roleA" , "roleB" ]},
1060+ tenant_role_names = {"tenant2" : ["admin" , "user" ]},
1061+ )
1062+ users = resp ["users" ]
1063+ self .assertEqual (len (users ), 2 )
1064+ self .assertEqual (users [0 ]["id" ], "u1" )
1065+ self .assertEqual (users [1 ]["id" ], "u2" )
1066+ mock_post .assert_called_with (
1067+ f"{ common .DEFAULT_BASE_URL } { MgmtV1 .users_search_path } " ,
1068+ headers = {
1069+ ** common .default_headers ,
1070+ "Authorization" : f"Bearer { self .dummy_project_id } :{ self .dummy_management_key } " ,
1071+ "x-descope-project-id" : self .dummy_project_id ,
1072+ },
1073+ params = None ,
1074+ json = {
1075+ "tenantIds" : [],
1076+ "roleNames" : [],
1077+ "limit" : 0 ,
1078+ "page" : 0 ,
1079+ "testUsersOnly" : False ,
1080+ "withTestUser" : False ,
1081+ "tenantRoleIds" : {"tenant1" : {"values" : ["roleA" , "roleB" ]}},
1082+ "tenantRoleNames" : {"tenant2" : {"values" : ["admin" , "user" ]}},
1083+ },
1084+ allow_redirects = False ,
1085+ verify = True ,
1086+ timeout = DEFAULT_TIMEOUT_SECONDS ,
1087+ )
1088+
10501089 def test_search_all_test_users (self ):
10511090 # Test failed flows
10521091 with patch ("requests.post" ) as mock_post :
@@ -1254,6 +1293,45 @@ def test_search_all_test_users(self):
12541293 timeout = DEFAULT_TIMEOUT_SECONDS ,
12551294 )
12561295
1296+ # Test success flow with tenant_role_ids and tenant_role_names
1297+ with patch ("requests.post" ) as mock_post :
1298+ network_resp = mock .Mock ()
1299+ network_resp .ok = True
1300+ network_resp .json .return_value = json .loads (
1301+ """{"users": [{"id": "u1"}, {"id": "u2"}]}"""
1302+ )
1303+ mock_post .return_value = network_resp
1304+ resp = self .client .mgmt .user .search_all_test_users (
1305+ tenant_role_ids = {"tenant1" : ["roleA" , "roleB" ]},
1306+ tenant_role_names = {"tenant2" : ["admin" , "user" ]},
1307+ )
1308+ users = resp ["users" ]
1309+ self .assertEqual (len (users ), 2 )
1310+ self .assertEqual (users [0 ]["id" ], "u1" )
1311+ self .assertEqual (users [1 ]["id" ], "u2" )
1312+ mock_post .assert_called_with (
1313+ f"{ common .DEFAULT_BASE_URL } { MgmtV1 .test_users_search_path } " ,
1314+ headers = {
1315+ ** common .default_headers ,
1316+ "Authorization" : f"Bearer { self .dummy_project_id } :{ self .dummy_management_key } " ,
1317+ "x-descope-project-id" : self .dummy_project_id ,
1318+ },
1319+ params = None ,
1320+ json = {
1321+ "tenantIds" : [],
1322+ "roleNames" : [],
1323+ "limit" : 0 ,
1324+ "page" : 0 ,
1325+ "testUsersOnly" : True ,
1326+ "withTestUser" : True ,
1327+ "tenantRoleIds" : {"tenant1" : {"values" : ["roleA" , "roleB" ]}},
1328+ "tenantRoleNames" : {"tenant2" : {"values" : ["admin" , "user" ]}},
1329+ },
1330+ allow_redirects = False ,
1331+ verify = True ,
1332+ timeout = DEFAULT_TIMEOUT_SECONDS ,
1333+ )
1334+
12571335 def test_get_provider_token (self ):
12581336 # Test failed flows
12591337 with patch ("requests.get" ) as mock_post :
0 commit comments