Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions platform/mellanox/mlnx-platform-api/tests/test_bmc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#
# Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES.
# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES
# Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -80,14 +81,21 @@ def test_bmc_get_version(self, mock_get_firmware_version):
@mock.patch('sonic_py_common.device_info.get_bmc_data', \
mock.MagicMock(return_value={'bmc_addr': '169.254.0.1'}))
@mock.patch('sonic_platform.bmc.BMC._get_tpm_password', mock.MagicMock(return_value=''))
@mock.patch('sonic_platform_base.redfish_client.RedfishClient.redfish_api_set_min_password_length')
@mock.patch('sonic_platform_base.redfish_client.RedfishClient.redfish_api_change_login_password')
def test_bmc_reset_password(self, mock_change_password):
@mock.patch('sonic_platform_base.redfish_client.RedfishClient.redfish_api_get_min_password_length')
def test_bmc_reset_password(self, mock_get_min_length, mock_change_password, mock_set_min_length):
"""Test reset_password method with successful password reset"""
mock_change_password.return_value = (RedfishClient.ERR_CODE_OK, 'Password changed successfully')
mock_get_min_length.return_value = (RedfishClient.ERR_CODE_OK, 12)
mock_set_min_length.return_value = (RedfishClient.ERR_CODE_OK, '')
mock_change_password.return_value = (RedfishClient.ERR_CODE_OK, '')
bmc = BMC.get_instance()
ret, msg = bmc.reset_root_password()
assert ret == RedfishClient.ERR_CODE_OK
assert msg == 'Password changed successfully'
assert msg == ''
mock_get_min_length.assert_called_once()
mock_set_min_length.assert_any_call(8)
mock_set_min_length.assert_any_call(12)
mock_change_password.assert_called_once_with('testpass', BMCBase.ROOT_ACCOUNT)

@mock.patch('sonic_py_common.device_info.get_bmc_build_config', \
Expand Down
Loading