blob: e9085fa38d361528e6171e427f61829bbd31f19e [file] [log] [blame]
Vijay53a00552020-01-08 04:24:47 -06001*** Settings ***
Vijaye6fa8552020-01-14 04:44:36 -06002
Vijay53a00552020-01-08 04:24:47 -06003Documentation Test Redfish SessionService.
4
5Resource ../../lib/resource.robot
6Resource ../../lib/bmc_redfish_resource.robot
Vijayff2c0bc2020-02-03 00:05:45 -06007Resource ../../lib/bmc_redfish_utils.robot
Vijay53a00552020-01-08 04:24:47 -06008Resource ../../lib/openbmc_ffdc.robot
9
Vijaye6fa8552020-01-14 04:44:36 -060010Suite Setup Suite Setup Execution
Vijay39373152020-02-14 08:08:20 -060011Suite Teardown Suite Teardown Execution
Vijay53a00552020-01-08 04:24:47 -060012Test Setup Printn
13Test Teardown FFDC On Test Case Fail
14
Vijay39373152020-02-14 08:08:20 -060015
Vijayff2c0bc2020-02-03 00:05:45 -060016*** Variables ***
Vijay39373152020-02-14 08:08:20 -060017
Vijayff2c0bc2020-02-03 00:05:45 -060018@{ADMIN} admin_user TestPwd123
19@{OPERATOR} operator_user TestPwd123
Rahul Maheshwarib0753972022-08-29 05:04:47 -050020# User-driven input parameter to skip operator user.
21# -v SKIP_OPERATOR_USER:1 to skip from CLI.
22${SKIP_OPERATOR_USER} ${0}
Vijay53a00552020-01-08 04:24:47 -060023
Vijay39373152020-02-14 08:08:20 -060024
Vijay53a00552020-01-08 04:24:47 -060025*** Test Cases ***
26
Vijaye6fa8552020-01-14 04:44:36 -060027Create Session And Verify Response Code Using Different Credentials
28 [Documentation] Create session and verify response code using different credentials.
George Keishing0c8100f2022-01-13 00:24:57 -060029 [Tags] Create_Session_And_Verify_Response_Code_Using_Different_Credentials
Vijaye6fa8552020-01-14 04:44:36 -060030 [Template] Create Session And Verify Response Code
Vijay53a00552020-01-08 04:24:47 -060031
Vijaye6fa8552020-01-14 04:44:36 -060032 # username password valid_status_code
33 ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${HTTP_CREATED}
Vijayff2c0bc2020-02-03 00:05:45 -060034 r00t ${OPENBMC_PASSWORD} ${HTTP_UNAUTHORIZED}
35 ${OPENBMC_USERNAME} password ${HTTP_UNAUTHORIZED}
36 r00t password ${HTTP_UNAUTHORIZED}
Vijaye6fa8552020-01-14 04:44:36 -060037 admin_user TestPwd123 ${HTTP_CREATED}
Rahul Maheshwaribb79b9d2022-11-11 05:48:36 -060038
39
40Create Session And Verify Response Code Using Operator Credentials
41 [Documentation] Create session and verify response code using operator credentials.
42 [Tags] Create_Session_And_Verify_Response_Code_Using_Operator_Credentials
43 [Template] Create Session And Verify Response Code
44
45 # username password valid_status_code
Vijaye6fa8552020-01-14 04:44:36 -060046 operator_user TestPwd123 ${HTTP_CREATED}
Vijay53a00552020-01-08 04:24:47 -060047
48
David Wangd511f5d2021-02-26 16:19:20 +080049Set Session Timeout And Verify Response Code
50 [Documentation] Set Session Timeout And Verify Response Code.
51 [Tags] Set_Session_Timeout_And_Verify_Response_Code
52 [Template] Set Session Timeout And Verify
nagarjunb22917d2e32022-04-20 09:57:29 +053053 [Teardown] Set Session Timeout And Verify ${Default_Timeout_Value} ${HTTP_OK}
David Wangd511f5d2021-02-26 16:19:20 +080054
George Keishing96143832021-03-23 07:55:08 -050055 # The minimum & maximum allowed values for session timeout are 30
David Wangd511f5d2021-02-26 16:19:20 +080056 # seconds and 86400 seconds respectively as per the session service
57 # schema mentioned at
58 # https://redfish.dmtf.org/schemas/v1/SessionService.v1_1_7.json
59
60 # value valid_status_code
61 ${25} ${HTTP_BAD_REQUEST}
62 ${30} ${HTTP_OK}
63 ${3600} ${HTTP_OK}
64 ${86400} ${HTTP_OK}
65 ${86500} ${HTTP_BAD_REQUEST}
66
67
nagarjunb22917d2e32022-04-20 09:57:29 +053068Set Session Timeout And Verify Session After Timeout
69 [Documentation] Set timeout for session service and verify session is deleted after timeout.
70 [Tags] Set_Session_Timeout_And_Verify_Session_After_Timeout
71 [Teardown] Set Session Timeout And Verify ${Default_Timeout_Value} ${HTTP_OK}
72 [Template] Set Session Timeout And Verify Session Deleted After Timeout
73
74 #timeout Value
75 ${30}
76 ${300}
77
78
79Verify Session Login And Logout For Newly Created User
80 [Documentation] Verify able to login and logout using the session created for new user.
81 [Tags] Verify_Session_Login_And_Logout_For_Newly_Created_User
82 [Teardown] Redfish.Login
83
84 # Logout already created redfish session.
85 Redfish.Logout
86 Redfish.Login ${ADMIN}[0] ${ADMIN}[1]
87 ${systems}= Redfish.Get Properties /redfish/v1/Systems
88 Rprint Vars systems
89 Redfish.Logout
90 ${systems}= Redfish.Get /redfish/v1/Systems
91 ... valid_status_codes=[${HTTP_UNAUTHORIZED}]
92
93
Vijay53a00552020-01-08 04:24:47 -060094Verify SessionService Defaults
95 [Documentation] Verify SessionService default property values.
96 [Tags] Verify_SessionService_Defaults
97
98 ${session_service}= Redfish.Get Properties /redfish/v1/SessionService
99 Rprint Vars session_service
100
Vijay53a00552020-01-08 04:24:47 -0600101 Valid Value session_service['@odata.id'] ['/redfish/v1/SessionService/']
102 Valid Value session_service['Description'] ['Session Service']
103 Valid Value session_service['Id'] ['SessionService']
104 Valid Value session_service['Name'] ['Session Service']
105 Valid Value session_service['ServiceEnabled'] [True]
nagarjunb22917d2e32022-04-20 09:57:29 +0530106 Valid Value session_service['SessionTimeout'] [${Default_Timeout_Value}]
Vijay53a00552020-01-08 04:24:47 -0600107 Valid Value session_service['Sessions']['@odata.id'] ['/redfish/v1/SessionService/Sessions']
108
109
110Verify Sessions Defaults
111 [Documentation] Verify Sessions default property values.
112 [Tags] Verify_Sessions_Defaults
113
114 ${sessions}= Redfish.Get Properties /redfish/v1/SessionService/Sessions
115 Rprint Vars sessions
116 ${sessions_count}= Get length ${sessions['Members']}
117
Vijay53a00552020-01-08 04:24:47 -0600118 Valid Value sessions['@odata.id'] ['/redfish/v1/SessionService/Sessions/']
119 Valid Value sessions['Description'] ['Session Collection']
120 Valid Value sessions['Name'] ['Session Collection']
121 Valid Value sessions['Members@odata.count'] [${sessions_count}]
122
123
124Verify Current Session Defaults
125 [Documentation] Verify Current session default property values.
126 [Tags] Verify_Current_Session_Defaults
127
128 ${session_location}= Redfish.Get Session Location
129 ${session_id}= Evaluate os.path.basename($session_location) modules=os
130 ${session_properties}= Redfish.Get Properties /redfish/v1/SessionService/Sessions/${session_id}
131 Rprint Vars session_location session_id session_properties
132
Vijay53a00552020-01-08 04:24:47 -0600133 Valid Value session_properties['@odata.id'] ['/redfish/v1/SessionService/Sessions/${session_id}']
134 Valid Value session_properties['Description'] ['Manager User Session']
135 Valid Value session_properties['Name'] ['User Session']
136 Valid Value session_properties['Id'] ['${session_id}']
137 Valid Value session_properties['UserName'] ['${OPENBMC_USERNAME}']
Vijay5b2f7792020-01-14 04:18:32 -0600138
139
140Verify Managers Defaults
141 [Documentation] Verify managers defaults.
142 [Tags] Verify_Managers_Defaults
143
144 ${managers}= Redfish.Get Properties /redfish/v1/Managers
145 Rprint Vars managers
146 ${managers_count}= Get Length ${managers['Members']}
147
Vijay5b2f7792020-01-14 04:18:32 -0600148 Valid Value managers['Name'] ['Manager Collection']
149 Valid Value managers['@odata.id'] ['/redfish/v1/Managers']
150 Valid Value managers['Members@odata.count'] [${managers_count}]
151
Vijayff2c0bc2020-02-03 00:05:45 -0600152 # Members can be one or more, hence checking in the list.
Vijay5b2f7792020-01-14 04:18:32 -0600153 Valid List managers['Members'] required_values=[{'@odata.id': '/redfish/v1/Managers/bmc'}]
154
155
156Verify Chassis Defaults
157 [Documentation] Verify chassis defaults.
158 [Tags] Verify_Chassis_Defaults
159
160 ${chassis}= Redfish.Get Properties /redfish/v1/Chassis
161 Rprint Vars chassis
162 ${chassis_count}= Get Length ${chassis['Members']}
163
Vijay5b2f7792020-01-14 04:18:32 -0600164 Valid Value chassis['Name'] ['Chassis Collection']
165 Valid Value chassis['@odata.id'] ['/redfish/v1/Chassis']
166 Valid Value chassis['Members@odata.count'] [${chassis_count}]
167 Valid Value chassis['Members@odata.count'] [${chassis_count}]
168
Vijayff2c0bc2020-02-03 00:05:45 -0600169 # Members can be one or more, hence checking in the list.
Vijay5b2f7792020-01-14 04:18:32 -0600170 Valid List chassis['Members']
Tony Lee2b975822021-04-01 11:15:00 +0800171 ... required_values=[{'@odata.id': '/redfish/v1/Chassis/${CHASSIS_ID}'}]
Vijay5b2f7792020-01-14 04:18:32 -0600172
173
174Verify Systems Defaults
175 [Documentation] Verify systems defaults.
176 [Tags] Verify_Systems_Defaults
177
178 ${systems}= Redfish.Get Properties /redfish/v1/Systems
179 Rprint Vars systems
180 ${systems_count}= Get Length ${systems['Members']}
Vijay5b2f7792020-01-14 04:18:32 -0600181 Valid Value systems['Name'] ['Computer System Collection']
182 Valid Value systems['@odata.id'] ['/redfish/v1/Systems']
183 Valid Value systems['Members@odata.count'] [${systems_count}]
184 Valid Value systems['Members@odata.count'] [${systems_count}]
Vijayff2c0bc2020-02-03 00:05:45 -0600185 # Members can be one or more, hence checking in the list.
Vijay5b2f7792020-01-14 04:18:32 -0600186 Valid List systems['Members'] required_values=[{'@odata.id': '/redfish/v1/Systems/system'}]
187
188
189Verify Session Persistency After BMC Reboot
190 [Documentation] Verify session persistency after BMC reboot.
191 [Tags] Verify_Session_Persistency_After_BMC_Reboot
192
Vijayff2c0bc2020-02-03 00:05:45 -0600193 # Note the current session location.
Vijay5b2f7792020-01-14 04:18:32 -0600194 ${session_location}= Redfish.Get Session Location
195
196 Redfish OBMC Reboot (off) stack_mode=normal
Vijay5b2f7792020-01-14 04:18:32 -0600197
Vijayff2c0bc2020-02-03 00:05:45 -0600198 # Check for session persistency after BMC reboot.
199 # sessions here will have list of all sessions location.
Vijay5b2f7792020-01-14 04:18:32 -0600200 ${sessions}= Redfish.Get Attribute /redfish/v1/SessionService/Sessions Members
201 ${payload}= Create Dictionary @odata.id=${session_location}
202
203 List Should Contain Value ${sessions} ${payload}
204
Vijaye6fa8552020-01-14 04:44:36 -0600205*** Keywords ***
206
207Create Session And Verify Response Code
208 [Documentation] Create session and verify response code.
209 [Arguments] ${username}=${OPENBMC_USERNAME} ${password}=${OPENBMC_PASSWORD}
210 ... ${valid_status_code}=${HTTP_CREATED}
211
212 # Description of argument(s):
213 # username The username to create a session.
214 # password The password to create a session.
Vijayff2c0bc2020-02-03 00:05:45 -0600215 # valid_status_code Expected response code, default is ${HTTP_CREATED}.
Vijaye6fa8552020-01-14 04:44:36 -0600216
217 ${resp}= Redfish.Post /redfish/v1/SessionService/Sessions
218 ... body={'UserName':'${username}', 'Password': '${password}'}
219 ... valid_status_codes=[${valid_status_code}]
220
221
David Wangd511f5d2021-02-26 16:19:20 +0800222Set Session Timeout And Verify
223 [Documentation] Set Session Timeout And Verify.
224 [Arguments] ${value}=3600 ${valid_status_code}=${HTTP_OK}
225
226 # Description of argument(s):
227 # value The value to patch session timeout.
228 # valid_status_code Expected response code, default is ${HTTP_OK}.
229
nagarjunb22917d2e32022-04-20 09:57:29 +0530230 Redfish.Login
David Wangd511f5d2021-02-26 16:19:20 +0800231 ${data}= Create Dictionary SessionTimeout=${value}
232 Redfish.Patch ${REDFISH_BASE_URI}SessionService
233 ... body=&{data}
234 ... valid_status_codes=[${valid_status_code}]
235
236 ${session_timeout}= Redfish.Get Attribute
237 ... ${REDFISH_BASE_URI}SessionService SessionTimeout
238
239 Run Keyword If ${valid_status_code}==${HTTP_OK}
240 ... Valid Value session_timeout [${value}]
241
242
nagarjunb22917d2e32022-04-20 09:57:29 +0530243Create Session And Check Session Timeout
244 [Documentation] Create session and check session timeout.
245 [Arguments] ${value}
246
247 # Description of argument(s):
248 # value timeout value in integer to be configured.
249
250 ${resp}= Redfish.Post /redfish/v1/SessionService/Sessions
251 ... body={'UserName':'${OPENBMC_USERNAME}', 'Password': '${OPENBMC_PASSWORD}'}
252 ... valid_status_codes=[${HTTP_CREATED}]
253 ${session_id}= Set Variable ${resp.dict['@odata.id']}
254 Sleep ${value}s
255
256 Redfish.Get ${REDFISH_SESSION} valid_status_codes=[${HTTP_UNAUTHORIZED}]
257 # Since sessions will deleted so logging again.
258 Redfish.login
259 ${session_list}= Redfish.Get Members List /redfish/v1/SessionService/Sessions
260
261 List Should Not Contain Value ${session_list} ${session_id}
262
263
264Set Session Timeout And Verify Session Deleted After Timeout
265 [Documentation] Set timeout for session service and verify session is deleted after timeout.
266 [Arguments] ${timeout_value}
267
268 # Description of argument(s):
269 # timeout_value timeout value in integer to be configured.
270
271 ${data}= Create Dictionary SessionTimeout=${timeout_value}
272 ${resp_patch}= Redfish.Patch /redfish/v1/SessionService
273 ... body=&{data} valid_status_codes=[${HTTP_OK}]
274 Create Session And Check Session Timeout ${timeout_value}
275
276
277Get Default Timeout Value
278 [Documentation] Get default session timeout value and set as a suite variable.
279
280 ${Default_Timeout_Value}= Redfish.Get Attribute /redfish/v1/SessionService SessionTimeout
281 Set Suite Variable ${Default_Timeout_Value}
282
283
Vijaye6fa8552020-01-14 04:44:36 -0600284Suite Setup Execution
285 [Documentation] Suite Setup Execution.
286
287 Redfish.Login
Rahul Maheshwarib0753972022-08-29 05:04:47 -0500288
289 # Skip operator user if SKIP_OPERATOR_USER is 1.
290 Run Keyword If
291 ... ${SKIP_OPERATOR_USER} == ${1}
292 ... Set Suite Variable &{USERS} Administrator=${ADMIN}
293 ... ELSE
294 ... Set Suite Variable &{USERS} Administrator=${ADMIN} Operator=${OPERATOR}
295
Vijayff2c0bc2020-02-03 00:05:45 -0600296 Create Users With Different Roles users=${USERS} force=${True}
nagarjunb22917d2e32022-04-20 09:57:29 +0530297 Get Default Timeout Value
Vijay39373152020-02-14 08:08:20 -0600298
299
300Suite Teardown Execution
301 [Documentation] Suite teardown execution.
302
303 Delete BMC Users Via Redfish users=${USERS}
nagarjunb22917d2e32022-04-20 09:57:29 +0530304 Run Keyword And Ignore Error Delete All Redfish Sessions
Vijay39373152020-02-14 08:08:20 -0600305 Redfish.Logout