Skip to content

Commit 1b2139f

Browse files
committed
fix unit test failures
1 parent 5b6e597 commit 1b2139f

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

test/src/test_users.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -140,22 +140,22 @@ def mock_manage_api_key(requests_mock):
140140
user_id = "user1"
141141
apikey = {"userid": user_id, "apikey": "test-api-key-12345", "href": f"https://{MANAGE_API_URL}/maximo/api/os/mxapikey/theapikeyid"} # pragma: allowlist secret
142142

143-
# Also setup for MAXADMIN user
144-
maxadmin_apikey = {"userid": "MAXADMIN", "apikey": "maxadmin-api-key-67890", "href": f"https://{MANAGE_API_URL}/maximo/api/os/mxapikey/maxadminapikeyid"} # pragma: allowlist secret
143+
# Also setup for MXINTADM user
144+
mxintadm_apikey = {"userid": "MXINTADM", "apikey": "mxintadm-api-key-67890", "href": f"https://{MANAGE_API_URL}/maximo/api/os/mxapikey/mxintadmapikeyid"} # pragma: allowlist secret
145145

146-
def maxadmin_matcher(req):
147-
return req.json().get("userid") == "MAXADMIN" and req.verify == PEM_PATH and req.cert == PEM_PATH
146+
def mxintadm_matcher(req):
147+
return req.json().get("userid") == "MXINTADM" and req.verify == PEM_PATH and req.cert == PEM_PATH
148148

149149
def user1_matcher(req):
150150
return req.json().get("userid") == user_id and req.verify == PEM_PATH and req.cert == PEM_PATH
151151

152-
# Mock for MAXADMIN API key creation (returns 400 - key already exists)
152+
# Mock for MXINTADM API key creation (returns 400 - key already exists)
153153
requests_mock.post(
154154
f"{MANAGE_API_URL}/maximo/api/os/mxapiapikey?ccm=1&lean=1",
155155
request_headers={"content-type": "application/json"},
156156
json={"Error": {"reasonCode": "BMXAA10051E", "message": "Only one API key allowed per user"}},
157157
status_code=400,
158-
additional_matcher=maxadmin_matcher
158+
additional_matcher=mxintadm_matcher
159159
)
160160

161161
# Mock for user1 API key creation
@@ -176,16 +176,16 @@ def user1_matcher(req):
176176
additional_matcher=lambda req: additional_matcher(req, cert=PEM_PATH)
177177
)
178178

179-
# Mock for MAXADMIN API key retrieval (returns existing key)
179+
# Mock for MXINTADM API key retrieval (returns existing key)
180180
requests_mock.get(
181-
f"{MANAGE_API_URL}/maximo/api/os/mxapiapikey?ccm=1&lean=1&oslc.select=*&oslc.where=userid=\"MAXADMIN\"",
181+
f"{MANAGE_API_URL}/maximo/api/os/mxapiapikey?ccm=1&lean=1&oslc.select=*&oslc.where=userid=\"MXINTADM\"",
182182
request_headers={"accept": "application/json"},
183-
json={"member": [maxadmin_apikey]},
183+
json={"member": [mxintadm_apikey]},
184184
status_code=200,
185185
additional_matcher=lambda req: additional_matcher(req, cert=PEM_PATH)
186186
)
187187

188-
yield maxadmin_apikey
188+
yield mxintadm_apikey
189189

190190

191191
def test_admin_internal_ca_pem_file_path(user_utils, mock_named_temporary_file, mock_atexit):
@@ -2284,8 +2284,7 @@ def test_create_initial_user_for_saas(
22842284
user_utils.link_user_to_local_idp.assert_called_once_with(user_id, email_password=True, manage_api_key=manage_api_key, resource_id=resource_id)
22852285
else:
22862286
user_utils.link_user_to_local_idp.assert_called_once_with(user_id, email_password=True)
2287-
2288-
user_utils.add_user_to_workspace.assert_called_once_with(user_id, is_workspace_admin=is_workspace_admin)
2287+
user_utils.add_user_to_workspace.assert_called_once_with(user_id, is_workspace_admin=is_workspace_admin)
22892288

22902289
# For version < 9.1, await_mas_application_availability and set_user_application_permission are called
22912290
# For version >= 9.1, they are NOT called
@@ -2314,7 +2313,7 @@ def test_create_initial_user_for_saas(
23142313
# For version >= 9.1, API key is always created (needed for link_user_to_local_idp)
23152314
# For version < 9.1, API key is only created if there are manage_security_groups
23162315
if Version(mas_version) >= Version('9.1') or len(manage_security_groups) > 0:
2317-
user_utils.create_or_get_manage_api_key_for_user.assert_called_once_with("MAXADMIN", temporary=True)
2316+
user_utils.create_or_get_manage_api_key_for_user.assert_called_once_with("MXINTADM", temporary=True)
23182317
else:
23192318
user_utils.create_or_get_manage_api_key_for_user.assert_not_called()
23202319

0 commit comments

Comments
 (0)