Create multiple session and verify
Changes:
- Added set session key function in lib.
- Added get session info function in lib utils.
- Added test case to create 50 session and verify.
Tested: On Master
Change-Id: Iaf740c83d77fb1da7be65903872219e21b53c79e
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/lib/bmc_redfish.py b/lib/bmc_redfish.py
index 92001c9..d0f22a3 100644
--- a/lib/bmc_redfish.py
+++ b/lib/bmc_redfish.py
@@ -64,8 +64,27 @@
password=self._password_,
default_prefix=self._default_prefix_)
self._robj_.login(auth=redfish.AuthMethod.SESSION)
+ self._session_key_ = self._robj_.get_session_key()
self._session_location_ = self._robj_.get_session_location()
+ def set_session_key(self, session_key):
+ r"""
+ Update the session key instance.
+
+ session_key Redfish valid session key.
+ """
+ self._robj_.set_session_key(session_key)
+
+ def set_session_location(self, session_location):
+ r"""
+ Update the session location instance.
+
+ session_location Redfish valid session location.
+ Example:
+ /redfish/v1/SessionService/Sessions/j04tD83QQn
+ """
+ self._robj_.set_session_location(session_location)
+
def get(self, resource_path, *args, **kwargs):
r"""
Perform a GET request and return response.
diff --git a/lib/bmc_redfish_utils.py b/lib/bmc_redfish_utils.py
index 832da44..daa09e1 100644
--- a/lib/bmc_redfish_utils.py
+++ b/lib/bmc_redfish_utils.py
@@ -17,6 +17,21 @@
# Obtain a reference to the global redfish object.
self._redfish_ = BuiltIn().get_library_instance('redfish')
+ def get_redfish_session_info(self):
+ r"""
+ Returns redfish sessions info dictionary.
+
+ {
+ 'key': 'yLXotJnrh5nDhXj5lLiH' ,
+ 'location': '/redfish/v1/SessionService/Sessions/nblYY4wlz0'
+ }
+ """
+ session_dict = {
+ "key": self._redfish_._session_key_,
+ "location": self._redfish_._session_location_
+ }
+ return session_dict
+
def get_attribute(self, resource_path, attribute):
r"""
Get resource attribute.
diff --git a/redfish/service_root/test_service_root_security.robot b/redfish/service_root/test_service_root_security.robot
index c001fb7..cab493d 100644
--- a/redfish/service_root/test_service_root_security.robot
+++ b/redfish/service_root/test_service_root_security.robot
@@ -5,6 +5,10 @@
Test Teardown FFDC On Test Case Fail
+*** Variables ***
+
+${LOGIN_SESSION_COUNT} ${50}
+
*** Test Cases ***
Redfish Login With Invalid Credentials
@@ -50,6 +54,33 @@
... data=${data} headers=${headers}
+Create Multiple Login Sessions And Verify
+ [Documentation] Create 50 login instances and verify.
+ [Tags] Create_Multiple_Login_Sessions_And_Verify
+ [Teardown] Multiple Session Cleanup
+
+ redfish.Login
+ # Example:
+ # {
+ # 'key': 'L0XEsZAXpNdF147jJaOD',
+ # 'location': '/redfish/v1/SessionService/Sessions/qWn2JOJSOs'
+ # }
+ ${saved_session_info}= Get Redfish Session Info
+
+ # Sessions book keeping for cleanup once done.
+ ${session_list}= Create List
+ Set Test Variable ${session_list}
+
+ Repeat Keyword ${LOGIN_SESSION_COUNT} times Create New Login Session
+
+ # Update the redfish session object with the first login key and location
+ # and verify if it is still working.
+ redfish.Set Session Key ${saved_session_info["key"]}
+ redfish.Set Session Location ${saved_session_info["location"]}
+ ${resp}= redfish.Get ${saved_session_info["location"]}
+ Should Be Equal As Strings ${resp.status} ${HTTP_OK}
+
+
*** Keywords ***
Login And Verify Redfish Response
@@ -63,3 +94,25 @@
${data}= Create Dictionary username=${username} password=${password}
Run Keyword And Expect Error ${expected_response} redfish.Login ${data}
+
+
+Create New Login Session
+ [Documentation] Multiple login session keys.
+
+ redfish.Login
+ ${session_info}= Get Redfish Session Info
+
+ # Append the session location to the list.
+ # ['/redfish/v1/SessionService/Sessions/uDzihgDecs',
+ # '/redfish/v1/SessionService/Sessions/PaHF5brPPd']
+ Append To List ${session_list} ${session_info["location"]}
+
+
+Multiple Session Cleanup
+ [Documentation] Do the teardown for multiple sessions.
+
+ FFDC On Test Case Fail
+
+ :FOR ${item} IN @{session_list}
+ \ redfish.Delete ${item}
+