blob: 0bde4f9f2a6a6f93f0983c0ea43b4613f0657a3a [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
Vijayff2c0bc2020-02-03 00:05:45 -06005Resource ../../lib/bmc_redfish_utils.robot
Vijay53a00552020-01-08 04:24:47 -06006Resource ../../lib/openbmc_ffdc.robot
7
Vijaye6fa8552020-01-14 04:44:36 -06008Suite Setup Suite Setup Execution
Vijay39373152020-02-14 08:08:20 -06009Suite Teardown Suite Teardown Execution
Vijay53a00552020-01-08 04:24:47 -060010Test Setup Printn
11Test Teardown FFDC On Test Case Fail
12
Vijay39373152020-02-14 08:08:20 -060013
Vijayff2c0bc2020-02-03 00:05:45 -060014*** Variables ***
Vijay39373152020-02-14 08:08:20 -060015
Vijayff2c0bc2020-02-03 00:05:45 -060016@{ADMIN} admin_user TestPwd123
17@{OPERATOR} operator_user TestPwd123
Rahul Maheshwarib0753972022-08-29 05:04:47 -050018# User-driven input parameter to skip operator user.
19# -v SKIP_OPERATOR_USER:1 to skip from CLI.
20${SKIP_OPERATOR_USER} ${0}
Yi Hu02d32762024-03-07 14:34:34 -080021${REDFISH_DELETE_SESSIONS} ${0}
Vijay53a00552020-01-08 04:24:47 -060022
Vijay39373152020-02-14 08:08:20 -060023
Vijay53a00552020-01-08 04:24:47 -060024*** Test Cases ***
25
Vijaye6fa8552020-01-14 04:44:36 -060026Create Session And Verify Response Code Using Different Credentials
27 [Documentation] Create session and verify response code using different credentials.
George Keishing0c8100f2022-01-13 00:24:57 -060028 [Tags] Create_Session_And_Verify_Response_Code_Using_Different_Credentials
Vijaye6fa8552020-01-14 04:44:36 -060029 [Template] Create Session And Verify Response Code
Vijay53a00552020-01-08 04:24:47 -060030
Vijaye6fa8552020-01-14 04:44:36 -060031 # username password valid_status_code
32 ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${HTTP_CREATED}
Vijayff2c0bc2020-02-03 00:05:45 -060033 r00t ${OPENBMC_PASSWORD} ${HTTP_UNAUTHORIZED}
34 ${OPENBMC_USERNAME} password ${HTTP_UNAUTHORIZED}
35 r00t password ${HTTP_UNAUTHORIZED}
Vijaye6fa8552020-01-14 04:44:36 -060036 admin_user TestPwd123 ${HTTP_CREATED}
Rahul Maheshwaribb79b9d2022-11-11 05:48:36 -060037
38
39Create Session And Verify Response Code Using Operator Credentials
40 [Documentation] Create session and verify response code using operator credentials.
41 [Tags] Create_Session_And_Verify_Response_Code_Using_Operator_Credentials
42 [Template] Create Session And Verify Response Code
43
44 # username password valid_status_code
Vijaye6fa8552020-01-14 04:44:36 -060045 operator_user TestPwd123 ${HTTP_CREATED}
Vijay53a00552020-01-08 04:24:47 -060046
47
David Wangd511f5d2021-02-26 16:19:20 +080048Set Session Timeout And Verify Response Code
49 [Documentation] Set Session Timeout And Verify Response Code.
50 [Tags] Set_Session_Timeout_And_Verify_Response_Code
51 [Template] Set Session Timeout And Verify
nagarjunb22917d2e32022-04-20 09:57:29 +053052 [Teardown] Set Session Timeout And Verify ${Default_Timeout_Value} ${HTTP_OK}
David Wangd511f5d2021-02-26 16:19:20 +080053
George Keishing96143832021-03-23 07:55:08 -050054 # The minimum & maximum allowed values for session timeout are 30
David Wangd511f5d2021-02-26 16:19:20 +080055 # seconds and 86400 seconds respectively as per the session service
56 # schema mentioned at
57 # https://redfish.dmtf.org/schemas/v1/SessionService.v1_1_7.json
58
59 # value valid_status_code
60 ${25} ${HTTP_BAD_REQUEST}
61 ${30} ${HTTP_OK}
62 ${3600} ${HTTP_OK}
63 ${86400} ${HTTP_OK}
64 ${86500} ${HTTP_BAD_REQUEST}
65
66
nagarjunb22917d2e32022-04-20 09:57:29 +053067Set Session Timeout And Verify Session After Timeout
68 [Documentation] Set timeout for session service and verify session is deleted after timeout.
69 [Tags] Set_Session_Timeout_And_Verify_Session_After_Timeout
70 [Teardown] Set Session Timeout And Verify ${Default_Timeout_Value} ${HTTP_OK}
71 [Template] Set Session Timeout And Verify Session Deleted After Timeout
72
73 #timeout Value
74 ${30}
75 ${300}
76
77
78Verify Session Login And Logout For Newly Created User
79 [Documentation] Verify able to login and logout using the session created for new user.
80 [Tags] Verify_Session_Login_And_Logout_For_Newly_Created_User
81 [Teardown] Redfish.Login
82
83 # Logout already created redfish session.
84 Redfish.Logout
85 Redfish.Login ${ADMIN}[0] ${ADMIN}[1]
86 ${systems}= Redfish.Get Properties /redfish/v1/Systems
87 Rprint Vars systems
88 Redfish.Logout
89 ${systems}= Redfish.Get /redfish/v1/Systems
90 ... valid_status_codes=[${HTTP_UNAUTHORIZED}]
91
92
Vijay53a00552020-01-08 04:24:47 -060093Verify SessionService Defaults
94 [Documentation] Verify SessionService default property values.
95 [Tags] Verify_SessionService_Defaults
96
97 ${session_service}= Redfish.Get Properties /redfish/v1/SessionService
98 Rprint Vars session_service
99
Vijay53a00552020-01-08 04:24:47 -0600100 Valid Value session_service['@odata.id'] ['/redfish/v1/SessionService/']
101 Valid Value session_service['Description'] ['Session Service']
102 Valid Value session_service['Id'] ['SessionService']
103 Valid Value session_service['Name'] ['Session Service']
104 Valid Value session_service['ServiceEnabled'] [True]
nagarjunb22917d2e32022-04-20 09:57:29 +0530105 Valid Value session_service['SessionTimeout'] [${Default_Timeout_Value}]
Vijay53a00552020-01-08 04:24:47 -0600106 Valid Value session_service['Sessions']['@odata.id'] ['/redfish/v1/SessionService/Sessions']
107
108
109Verify Sessions Defaults
110 [Documentation] Verify Sessions default property values.
111 [Tags] Verify_Sessions_Defaults
112
113 ${sessions}= Redfish.Get Properties /redfish/v1/SessionService/Sessions
114 Rprint Vars sessions
115 ${sessions_count}= Get length ${sessions['Members']}
116
Vijay53a00552020-01-08 04:24:47 -0600117 Valid Value sessions['@odata.id'] ['/redfish/v1/SessionService/Sessions/']
118 Valid Value sessions['Description'] ['Session Collection']
119 Valid Value sessions['Name'] ['Session Collection']
120 Valid Value sessions['Members@odata.count'] [${sessions_count}]
121
122
123Verify Current Session Defaults
124 [Documentation] Verify Current session default property values.
125 [Tags] Verify_Current_Session_Defaults
126
127 ${session_location}= Redfish.Get Session Location
128 ${session_id}= Evaluate os.path.basename($session_location) modules=os
129 ${session_properties}= Redfish.Get Properties /redfish/v1/SessionService/Sessions/${session_id}
130 Rprint Vars session_location session_id session_properties
131
Vijay53a00552020-01-08 04:24:47 -0600132 Valid Value session_properties['@odata.id'] ['/redfish/v1/SessionService/Sessions/${session_id}']
133 Valid Value session_properties['Description'] ['Manager User Session']
134 Valid Value session_properties['Name'] ['User Session']
135 Valid Value session_properties['Id'] ['${session_id}']
136 Valid Value session_properties['UserName'] ['${OPENBMC_USERNAME}']
Vijay5b2f7792020-01-14 04:18:32 -0600137
138
139Verify Managers Defaults
140 [Documentation] Verify managers defaults.
141 [Tags] Verify_Managers_Defaults
142
143 ${managers}= Redfish.Get Properties /redfish/v1/Managers
144 Rprint Vars managers
145 ${managers_count}= Get Length ${managers['Members']}
146
Vijay5b2f7792020-01-14 04:18:32 -0600147 Valid Value managers['Name'] ['Manager Collection']
148 Valid Value managers['@odata.id'] ['/redfish/v1/Managers']
149 Valid Value managers['Members@odata.count'] [${managers_count}]
150
Vijayff2c0bc2020-02-03 00:05:45 -0600151 # Members can be one or more, hence checking in the list.
ganesanb4d430282023-04-27 14:33:23 +0000152 Valid List managers['Members'] required_values=[{'@odata.id': '/redfish/v1/Managers/${MANAGER_ID}'}]
Vijay5b2f7792020-01-14 04:18:32 -0600153
154
155Verify Chassis Defaults
156 [Documentation] Verify chassis defaults.
157 [Tags] Verify_Chassis_Defaults
158
159 ${chassis}= Redfish.Get Properties /redfish/v1/Chassis
160 Rprint Vars chassis
161 ${chassis_count}= Get Length ${chassis['Members']}
162
Vijay5b2f7792020-01-14 04:18:32 -0600163 Valid Value chassis['Name'] ['Chassis Collection']
164 Valid Value chassis['@odata.id'] ['/redfish/v1/Chassis']
165 Valid Value chassis['Members@odata.count'] [${chassis_count}]
166 Valid Value chassis['Members@odata.count'] [${chassis_count}]
167
Vijayff2c0bc2020-02-03 00:05:45 -0600168 # Members can be one or more, hence checking in the list.
Vijay5b2f7792020-01-14 04:18:32 -0600169 Valid List chassis['Members']
Tony Lee2b975822021-04-01 11:15:00 +0800170 ... required_values=[{'@odata.id': '/redfish/v1/Chassis/${CHASSIS_ID}'}]
Vijay5b2f7792020-01-14 04:18:32 -0600171
172
173Verify Systems Defaults
174 [Documentation] Verify systems defaults.
175 [Tags] Verify_Systems_Defaults
176
177 ${systems}= Redfish.Get Properties /redfish/v1/Systems
178 Rprint Vars systems
179 ${systems_count}= Get Length ${systems['Members']}
Vijay5b2f7792020-01-14 04:18:32 -0600180 Valid Value systems['Name'] ['Computer System Collection']
181 Valid Value systems['@odata.id'] ['/redfish/v1/Systems']
182 Valid Value systems['Members@odata.count'] [${systems_count}]
183 Valid Value systems['Members@odata.count'] [${systems_count}]
Vijayff2c0bc2020-02-03 00:05:45 -0600184 # Members can be one or more, hence checking in the list.
Yi Huc32434a2024-01-11 17:33:10 -0800185 Valid List systems['Members'] required_values=[{'@odata.id': '/redfish/v1/Systems/${SYSTEM_ID}'}]
Vijay5b2f7792020-01-14 04:18:32 -0600186
187
188Verify Session Persistency After BMC Reboot
189 [Documentation] Verify session persistency after BMC reboot.
190 [Tags] Verify_Session_Persistency_After_BMC_Reboot
191
Vijayff2c0bc2020-02-03 00:05:45 -0600192 # Note the current session location.
Vijay5b2f7792020-01-14 04:18:32 -0600193 ${session_location}= Redfish.Get Session Location
194
195 Redfish OBMC Reboot (off) stack_mode=normal
Vijay5b2f7792020-01-14 04:18:32 -0600196
Vijayff2c0bc2020-02-03 00:05:45 -0600197 # Check for session persistency after BMC reboot.
198 # sessions here will have list of all sessions location.
Vijay5b2f7792020-01-14 04:18:32 -0600199 ${sessions}= Redfish.Get Attribute /redfish/v1/SessionService/Sessions Members
200 ${payload}= Create Dictionary @odata.id=${session_location}
201
202 List Should Contain Value ${sessions} ${payload}
203
Vijaye6fa8552020-01-14 04:44:36 -0600204*** Keywords ***
205
206Create Session And Verify Response Code
207 [Documentation] Create session and verify response code.
208 [Arguments] ${username}=${OPENBMC_USERNAME} ${password}=${OPENBMC_PASSWORD}
209 ... ${valid_status_code}=${HTTP_CREATED}
210
211 # Description of argument(s):
212 # username The username to create a session.
213 # password The password to create a session.
Vijayff2c0bc2020-02-03 00:05:45 -0600214 # valid_status_code Expected response code, default is ${HTTP_CREATED}.
Vijaye6fa8552020-01-14 04:44:36 -0600215
216 ${resp}= Redfish.Post /redfish/v1/SessionService/Sessions
217 ... body={'UserName':'${username}', 'Password': '${password}'}
218 ... valid_status_codes=[${valid_status_code}]
219
220
David Wangd511f5d2021-02-26 16:19:20 +0800221Set Session Timeout And Verify
222 [Documentation] Set Session Timeout And Verify.
223 [Arguments] ${value}=3600 ${valid_status_code}=${HTTP_OK}
224
225 # Description of argument(s):
226 # value The value to patch session timeout.
227 # valid_status_code Expected response code, default is ${HTTP_OK}.
228
nagarjunb22917d2e32022-04-20 09:57:29 +0530229 Redfish.Login
David Wangd511f5d2021-02-26 16:19:20 +0800230 ${data}= Create Dictionary SessionTimeout=${value}
231 Redfish.Patch ${REDFISH_BASE_URI}SessionService
232 ... body=&{data}
233 ... valid_status_codes=[${valid_status_code}]
234
235 ${session_timeout}= Redfish.Get Attribute
236 ... ${REDFISH_BASE_URI}SessionService SessionTimeout
237
238 Run Keyword If ${valid_status_code}==${HTTP_OK}
239 ... Valid Value session_timeout [${value}]
240
241
nagarjunb22917d2e32022-04-20 09:57:29 +0530242Create Session And Check Session Timeout
243 [Documentation] Create session and check session timeout.
244 [Arguments] ${value}
245
246 # Description of argument(s):
247 # value timeout value in integer to be configured.
248
249 ${resp}= Redfish.Post /redfish/v1/SessionService/Sessions
250 ... body={'UserName':'${OPENBMC_USERNAME}', 'Password': '${OPENBMC_PASSWORD}'}
251 ... valid_status_codes=[${HTTP_CREATED}]
252 ${session_id}= Set Variable ${resp.dict['@odata.id']}
253 Sleep ${value}s
254
255 Redfish.Get ${REDFISH_SESSION} valid_status_codes=[${HTTP_UNAUTHORIZED}]
256 # Since sessions will deleted so logging again.
257 Redfish.login
258 ${session_list}= Redfish.Get Members List /redfish/v1/SessionService/Sessions
259
260 List Should Not Contain Value ${session_list} ${session_id}
261
262
263Set Session Timeout And Verify Session Deleted After Timeout
264 [Documentation] Set timeout for session service and verify session is deleted after timeout.
265 [Arguments] ${timeout_value}
266
267 # Description of argument(s):
268 # timeout_value timeout value in integer to be configured.
269
270 ${data}= Create Dictionary SessionTimeout=${timeout_value}
271 ${resp_patch}= Redfish.Patch /redfish/v1/SessionService
272 ... body=&{data} valid_status_codes=[${HTTP_OK}]
273 Create Session And Check Session Timeout ${timeout_value}
274
275
276Get Default Timeout Value
277 [Documentation] Get default session timeout value and set as a suite variable.
278
279 ${Default_Timeout_Value}= Redfish.Get Attribute /redfish/v1/SessionService SessionTimeout
280 Set Suite Variable ${Default_Timeout_Value}
281
282
Vijaye6fa8552020-01-14 04:44:36 -0600283Suite Setup Execution
284 [Documentation] Suite Setup Execution.
285
286 Redfish.Login
Rahul Maheshwarib0753972022-08-29 05:04:47 -0500287
288 # Skip operator user if SKIP_OPERATOR_USER is 1.
289 Run Keyword If
290 ... ${SKIP_OPERATOR_USER} == ${1}
291 ... Set Suite Variable &{USERS} Administrator=${ADMIN}
292 ... ELSE
293 ... Set Suite Variable &{USERS} Administrator=${ADMIN} Operator=${OPERATOR}
294
Vijayff2c0bc2020-02-03 00:05:45 -0600295 Create Users With Different Roles users=${USERS} force=${True}
nagarjunb22917d2e32022-04-20 09:57:29 +0530296 Get Default Timeout Value
Yi Hu02d32762024-03-07 14:34:34 -0800297 Set Redfish Delete Session Flag ${0}
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}
Yi Hu02d32762024-03-07 14:34:34 -0800304 Set Redfish Delete Session Flag ${1}
nagarjunb22917d2e32022-04-20 09:57:29 +0530305 Run Keyword And Ignore Error Delete All Redfish Sessions
Vijay39373152020-02-14 08:08:20 -0600306 Redfish.Logout