Key Error exception during login
Changes:
- Add exception handling for Key error.
A session creation error usually causes this
exception due to invalid and empty credentials.
Raise a custom exception to handle gracefully
such an exception during login failure.
- Add back the removed test case failing in QEMU_CI
Tested:
- Tested on CI infrastructure, Jenkins, and
local setup environment
Change-Id: I55d43ae6c62dd88faa700d895683e58c9279e6bc
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/lib/bmc_redfish.py b/lib/bmc_redfish.py
index 236ff44..8ee31b6 100644
--- a/lib/bmc_redfish.py
+++ b/lib/bmc_redfish.py
@@ -123,6 +123,16 @@
BuiltIn().log_to_console(str(except_value))
e_message = "Unexpected exception."
BuiltIn().log_to_console(e_message)
+ except KeyError:
+ except_type, except_value, except_traceback = sys.exc_info()
+ BuiltIn().log_to_console(str(except_type))
+ BuiltIn().log_to_console(str(except_value))
+ e_message = "Login failed, something went wrong during request. "
+ e_message += "Error usually due to SessionCreationError or "
+ e_message += "InvalidCredentialsError resulting in failure"
+ BuiltIn().log_to_console(e_message)
+ # Custom BaseException error message from KeyError exception.
+ raise KeyError("SessionCreationError or InvalidCredentialsError")
def logout(self):
if MTLS_ENABLED == "True":
diff --git a/test_lists/QEMU_CI b/test_lists/QEMU_CI
index 9548cde..3c3f838 100644
--- a/test_lists/QEMU_CI
+++ b/test_lists/QEMU_CI
@@ -9,6 +9,7 @@
--include Redfish_Login_Via_SessionService
--include Redfish_Login_Using_Invalid_Token
--include Delete_Redfish_Session_Using_Valid_Login
+--include Redfish_Login_With_Invalid_Credentials
--include Verify_Update_Service_Enabled
--include Verify_Redfish_Software_Inventory_Collection
--include Redfish_Software_Inventory_Status_Check