Fix class exit and temp object update in security
Change-Id: I18a95529fc2e2b27d3429f86eade852963873cb7
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/lib/bmc_redfish.py b/lib/bmc_redfish.py
index ba1b7d7..6bb641c 100644
--- a/lib/bmc_redfish.py
+++ b/lib/bmc_redfish.py
@@ -20,6 +20,7 @@
class bmc_redfish(object):
ROBOT_LIBRARY_SCOPE = "GLOBAL"
+ ROBOT_EXIT_ON_FAILURE = True
def __init__(self, hostname, username, password, *args, **kwargs):
r"""
@@ -32,7 +33,6 @@
args/kwargs Additional parms which are passed directly
to the redfish_client function.
"""
-
self._base_url_ = "https://" + hostname
self._username_ = username
self._password_ = password
@@ -41,8 +41,8 @@
def __enter__(self):
return self
- def __exit__(self, exception_type, exception_value, traceback):
- self._robj_.logout()
+ def __del__(self):
+ del self._robj_
def login(self, *args, **kwargs):
r"""
diff --git a/redfish/service_root/test_service_root.robot b/redfish/service_root/test_service_root.robot
index 66a63a3..5957336 100644
--- a/redfish/service_root/test_service_root.robot
+++ b/redfish/service_root/test_service_root.robot
@@ -72,13 +72,6 @@
${resp}= redfish.List Request SessionService/Sessions
List Should Not Contain Value ${resp} ${resp_list[1]}
- # BadRequestError: Invalid session resource:
- # /redfish/v1/SessionService/Sessions/gAEabN5Q0t, return code: 401
-
- ${error_message}= Catenate SEPARATOR= BadRequestError: Invalid session resource:
- ... ${SPACE}${resp_list[1]}, return code: 401
- Run Keyword And Expect Error ${error_message} redfish.Logout
-
*** Keywords ***
diff --git a/redfish/service_root/test_service_root_security.robot b/redfish/service_root/test_service_root_security.robot
index be15bc4..5d0b217 100644
--- a/redfish/service_root/test_service_root_security.robot
+++ b/redfish/service_root/test_service_root_security.robot
@@ -46,3 +46,8 @@
${data}= Create Dictionary username=${username} password=${password}
Run Keyword And Expect Error ${expected_response} redfish.Login ${data}
+ # Update __init__ with default credentials.
+ # robot doesn't flush the object per suite if executed in sequence suites.
+ ${data}= Create Dictionary username=${OPENBMC_USERNAME} password=${OPENBMC_PASSWORD}
+ redfish.Login ${data}
+