@@ -367,10 +367,17 @@ def test_get_or_create_user_exists(user_utils, requests_mock, mock_manage_api_ke
367367 request_headers = {"apikey" : mock_manage_api_key ["apikey" ]},
368368 json = {"id" : user_id },
369369 status_code = 201 ,
370- additional_matcher = lambda req : additional_matcher (req , json = {"id " : user_id }, cert = PEM_PATH )
370+ additional_matcher = lambda req : additional_matcher (req , json = {"personid " : user_id }, cert = PEM_PATH )
371371 )
372372
373- assert user_utils .get_or_create_user ({"id" : user_id }) == {"id" : user_id , "displayName" : user_id }
373+ # Use correct payload structure based on version
374+ from packaging .version import Version
375+ if Version (user_utils .mas_version ) >= Version ('9.1' ):
376+ payload = {"personid" : user_id }
377+ else :
378+ payload = {"id" : user_id }
379+
380+ assert user_utils .get_or_create_user (payload ) == {"id" : user_id , "displayName" : user_id }
374381 assert get .call_count == 1
375382 assert post_core .call_count == 0
376383 assert post_manage .call_count == 0
@@ -395,10 +402,17 @@ def test_get_or_create_user_notfound(user_utils, requests_mock, mock_manage_api_
395402 request_headers = {"apikey" : mock_manage_api_key ["apikey" ]},
396403 json = {"id" : user_id , "displayName" : user_id },
397404 status_code = 201 ,
398- additional_matcher = lambda req : additional_matcher (req , json = {"id " : user_id }, cert = PEM_PATH )
405+ additional_matcher = lambda req : additional_matcher (req , json = {"personid " : user_id }, cert = PEM_PATH )
399406 )
400407
401- assert user_utils .get_or_create_user ({"id" : user_id }) == {"id" : user_id , "displayName" : user_id }
408+ # Use correct payload structure based on version
409+ from packaging .version import Version
410+ if Version (user_utils .mas_version ) >= Version ('9.1' ):
411+ payload = {"personid" : user_id }
412+ else :
413+ payload = {"id" : user_id }
414+
415+ assert user_utils .get_or_create_user (payload ) == {"id" : user_id , "displayName" : user_id }
402416 assert get .call_count == 1
403417 # Check that the correct endpoint was called based on version
404418 if user_utils .mas_version >= '9.1' :
@@ -428,11 +442,18 @@ def test_get_or_create_user_error(user_utils, requests_mock, mock_manage_api_key
428442 request_headers = {"apikey" : mock_manage_api_key ["apikey" ]},
429443 json = {"error" : "unknown" },
430444 status_code = 500 ,
431- additional_matcher = lambda req : additional_matcher (req , json = {"id " : user_id }, cert = PEM_PATH )
445+ additional_matcher = lambda req : additional_matcher (req , json = {"personid " : user_id }, cert = PEM_PATH )
432446 )
433447
448+ # Use correct payload structure based on version
449+ from packaging .version import Version
450+ if Version (user_utils .mas_version ) >= Version ('9.1' ):
451+ payload = {"personid" : user_id }
452+ else :
453+ payload = {"id" : user_id }
454+
434455 with pytest .raises (Exception ):
435- user_utils .get_or_create_user ({ "id" : user_id } )
456+ user_utils .get_or_create_user (payload )
436457 assert get .call_count == 1
437458 # Check that the correct endpoint was called based on version
438459 if user_utils .mas_version >= '9.1' :
0 commit comments