BMC redfish update and new test suite for security
Changes:
- Update bmc redfish to allow user to update credentials.
- Added test suite test_service_root_security.robot.
Added Test Case:
- Login To BMCweb With Invalid Credentials
Change-Id: Ia7e8cd6f3cab381ad41f34b6f502e3f92521f692
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/lib/bmc_redfish.py b/lib/bmc_redfish.py
index 0619ca5..ba1b7d7 100644
--- a/lib/bmc_redfish.py
+++ b/lib/bmc_redfish.py
@@ -37,14 +37,6 @@
self._username_ = username
self._password_ = password
self._default_prefix_ = "/redfish/v1"
- self._robj_ = \
- redfish.redfish_client(base_url=self._base_url_,
- username=self._username_,
- password=self._password_,
- default_prefix=self._default_prefix_,
- *args, **kwargs)
- self._robj_.login(auth=redfish.AuthMethod.SESSION)
- self._session_location_ = self._robj_.get_session_location()
def __enter__(self):
return self
@@ -60,8 +52,20 @@
args/kwargs These are passed directly to the corresponding
RestClientBase method.
"""
- self._robj_.__init__(self._base_url_, self._username_, self._password_)
+
+ for arg in args:
+ hostname = self._base_url_.strip("https://")
+ # Class object constructor reinitialized.
+ self.__init__(hostname=hostname,
+ username=arg['username'],
+ password=arg['password'])
+
+ self._robj_ = redfish.redfish_client(base_url=self._base_url_,
+ username=self._username_,
+ password=self._password_,
+ default_prefix=self._default_prefix_)
self._robj_.login(auth=redfish.AuthMethod.SESSION)
+ self._session_location_ = self._robj_.get_session_location()
def get(self, resource_path, *args, **kwargs):
r"""
diff --git a/redfish/service_root/test_service_root_security.robot b/redfish/service_root/test_service_root_security.robot
new file mode 100644
index 0000000..7b2bf28
--- /dev/null
+++ b/redfish/service_root/test_service_root_security.robot
@@ -0,0 +1,33 @@
+*** Settings ***
+Resource ../../lib/resource.txt
+Resource ../../lib/bmc_redfish_resource.robot
+
+*** Test Cases ***
+
+Login To BMCweb With Invalid Credentials
+ [Documentation] Login to BMC web using invalid credential.
+ [Tags] Login_To_BMCweb_With_Invalid_Credentials
+ [Template] Login And Verify Redfish Response
+
+ # Expect status Username Password
+ InvalidCredentialsError* ${OPENBMC_USERNAME} deadpassword
+ InvalidCredentialsError* groot ${OPENBMC_PASSWORD}
+ InvalidCredentialsError* ${EMPTY} ${OPENBMC_PASSWORD}
+ InvalidCredentialsError* ${OPENBMC_USERNAME} ${EMPTY}
+ InvalidCredentialsError* ${EMPTY} ${EMPTY}
+
+
+*** Keywords ***
+
+Login And Verify Redfish Response
+ [Documentation] Login and verify redfish response.
+ [Arguments] ${expected_response} ${username} ${password}
+
+ # Description of arguments:
+ # expected_response Expected REST status.
+ # username The username to be used to connect to the server.
+ # password The password to be used to connect to the server.
+
+ ${data}= Create Dictionary username=${username} password=${password}
+ Run Keyword And Expect Error ${expected_response} redfish.Login ${data}
+