blob: 31aa3b4f4b79acff556ba84be8a694fe289e102f [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}
Vijay53a00552020-01-08 04:24:47 -060021
Vijay39373152020-02-14 08:08:20 -060022
Vijay53a00552020-01-08 04:24:47 -060023*** Test Cases ***
24
Vijaye6fa8552020-01-14 04:44:36 -060025Create Session And Verify Response Code Using Different Credentials
26 [Documentation] Create session and verify response code using different credentials.
George Keishing0c8100f2022-01-13 00:24:57 -060027 [Tags] Create_Session_And_Verify_Response_Code_Using_Different_Credentials
Vijaye6fa8552020-01-14 04:44:36 -060028 [Template] Create Session And Verify Response Code
Vijay53a00552020-01-08 04:24:47 -060029
Vijaye6fa8552020-01-14 04:44:36 -060030 # username password valid_status_code
31 ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${HTTP_CREATED}
Vijayff2c0bc2020-02-03 00:05:45 -060032 r00t ${OPENBMC_PASSWORD} ${HTTP_UNAUTHORIZED}
33 ${OPENBMC_USERNAME} password ${HTTP_UNAUTHORIZED}
34 r00t password ${HTTP_UNAUTHORIZED}
Vijaye6fa8552020-01-14 04:44:36 -060035 admin_user TestPwd123 ${HTTP_CREATED}
Rahul Maheshwaribb79b9d2022-11-11 05:48:36 -060036
37
38Create Session And Verify Response Code Using Operator Credentials
39 [Documentation] Create session and verify response code using operator credentials.
40 [Tags] Create_Session_And_Verify_Response_Code_Using_Operator_Credentials
41 [Template] Create Session And Verify Response Code
42
43 # username password valid_status_code
Vijaye6fa8552020-01-14 04:44:36 -060044 operator_user TestPwd123 ${HTTP_CREATED}
Vijay53a00552020-01-08 04:24:47 -060045
46
David Wangd511f5d2021-02-26 16:19:20 +080047Set Session Timeout And Verify Response Code
48 [Documentation] Set Session Timeout And Verify Response Code.
49 [Tags] Set_Session_Timeout_And_Verify_Response_Code
50 [Template] Set Session Timeout And Verify
nagarjunb22917d2e32022-04-20 09:57:29 +053051 [Teardown] Set Session Timeout And Verify ${Default_Timeout_Value} ${HTTP_OK}
David Wangd511f5d2021-02-26 16:19:20 +080052
George Keishing96143832021-03-23 07:55:08 -050053 # The minimum & maximum allowed values for session timeout are 30
David Wangd511f5d2021-02-26 16:19:20 +080054 # seconds and 86400 seconds respectively as per the session service
55 # schema mentioned at
56 # https://redfish.dmtf.org/schemas/v1/SessionService.v1_1_7.json
57
58 # value valid_status_code
59 ${25} ${HTTP_BAD_REQUEST}
60 ${30} ${HTTP_OK}
61 ${3600} ${HTTP_OK}
62 ${86400} ${HTTP_OK}
63 ${86500} ${HTTP_BAD_REQUEST}
64
65
nagarjunb22917d2e32022-04-20 09:57:29 +053066Set Session Timeout And Verify Session After Timeout
67 [Documentation] Set timeout for session service and verify session is deleted after timeout.
68 [Tags] Set_Session_Timeout_And_Verify_Session_After_Timeout
69 [Teardown] Set Session Timeout And Verify ${Default_Timeout_Value} ${HTTP_OK}
70 [Template] Set Session Timeout And Verify Session Deleted After Timeout
71
72 #timeout Value
73 ${30}
74 ${300}
75
76
77Verify Session Login And Logout For Newly Created User
78 [Documentation] Verify able to login and logout using the session created for new user.
79 [Tags] Verify_Session_Login_And_Logout_For_Newly_Created_User
80 [Teardown] Redfish.Login
81
82 # Logout already created redfish session.
83 Redfish.Logout
84 Redfish.Login ${ADMIN}[0] ${ADMIN}[1]
85 ${systems}= Redfish.Get Properties /redfish/v1/Systems
86 Rprint Vars systems
87 Redfish.Logout
88 ${systems}= Redfish.Get /redfish/v1/Systems
89 ... valid_status_codes=[${HTTP_UNAUTHORIZED}]
90
91
Vijay53a00552020-01-08 04:24:47 -060092Verify SessionService Defaults
93 [Documentation] Verify SessionService default property values.
94 [Tags] Verify_SessionService_Defaults
95
96 ${session_service}= Redfish.Get Properties /redfish/v1/SessionService
97 Rprint Vars session_service
98
Vijay53a00552020-01-08 04:24:47 -060099 Valid Value session_service['@odata.id'] ['/redfish/v1/SessionService/']
100 Valid Value session_service['Description'] ['Session Service']
101 Valid Value session_service['Id'] ['SessionService']
102 Valid Value session_service['Name'] ['Session Service']
103 Valid Value session_service['ServiceEnabled'] [True]
nagarjunb22917d2e32022-04-20 09:57:29 +0530104 Valid Value session_service['SessionTimeout'] [${Default_Timeout_Value}]
Vijay53a00552020-01-08 04:24:47 -0600105 Valid Value session_service['Sessions']['@odata.id'] ['/redfish/v1/SessionService/Sessions']
106
107
108Verify Sessions Defaults
109 [Documentation] Verify Sessions default property values.
110 [Tags] Verify_Sessions_Defaults
111
112 ${sessions}= Redfish.Get Properties /redfish/v1/SessionService/Sessions
113 Rprint Vars sessions
114 ${sessions_count}= Get length ${sessions['Members']}
115
Vijay53a00552020-01-08 04:24:47 -0600116 Valid Value sessions['@odata.id'] ['/redfish/v1/SessionService/Sessions/']
117 Valid Value sessions['Description'] ['Session Collection']
118 Valid Value sessions['Name'] ['Session Collection']
119 Valid Value sessions['Members@odata.count'] [${sessions_count}]
120
121
122Verify Current Session Defaults
123 [Documentation] Verify Current session default property values.
124 [Tags] Verify_Current_Session_Defaults
125
126 ${session_location}= Redfish.Get Session Location
127 ${session_id}= Evaluate os.path.basename($session_location) modules=os
128 ${session_properties}= Redfish.Get Properties /redfish/v1/SessionService/Sessions/${session_id}
129 Rprint Vars session_location session_id session_properties
130
Vijay53a00552020-01-08 04:24:47 -0600131 Valid Value session_properties['@odata.id'] ['/redfish/v1/SessionService/Sessions/${session_id}']
132 Valid Value session_properties['Description'] ['Manager User Session']
133 Valid Value session_properties['Name'] ['User Session']
134 Valid Value session_properties['Id'] ['${session_id}']
135 Valid Value session_properties['UserName'] ['${OPENBMC_USERNAME}']
Vijay5b2f7792020-01-14 04:18:32 -0600136
137
138Verify Managers Defaults
139 [Documentation] Verify managers defaults.
140 [Tags] Verify_Managers_Defaults
141
142 ${managers}= Redfish.Get Properties /redfish/v1/Managers
143 Rprint Vars managers
144 ${managers_count}= Get Length ${managers['Members']}
145
Vijay5b2f7792020-01-14 04:18:32 -0600146 Valid Value managers['Name'] ['Manager Collection']
147 Valid Value managers['@odata.id'] ['/redfish/v1/Managers']
148 Valid Value managers['Members@odata.count'] [${managers_count}]
149
Vijayff2c0bc2020-02-03 00:05:45 -0600150 # Members can be one or more, hence checking in the list.
ganesanb4d430282023-04-27 14:33:23 +0000151 Valid List managers['Members'] required_values=[{'@odata.id': '/redfish/v1/Managers/${MANAGER_ID}'}]
Vijay5b2f7792020-01-14 04:18:32 -0600152
153
154Verify Chassis Defaults
155 [Documentation] Verify chassis defaults.
156 [Tags] Verify_Chassis_Defaults
157
158 ${chassis}= Redfish.Get Properties /redfish/v1/Chassis
159 Rprint Vars chassis
160 ${chassis_count}= Get Length ${chassis['Members']}
161
Vijay5b2f7792020-01-14 04:18:32 -0600162 Valid Value chassis['Name'] ['Chassis Collection']
163 Valid Value chassis['@odata.id'] ['/redfish/v1/Chassis']
164 Valid Value chassis['Members@odata.count'] [${chassis_count}]
165 Valid Value chassis['Members@odata.count'] [${chassis_count}]
166
Vijayff2c0bc2020-02-03 00:05:45 -0600167 # Members can be one or more, hence checking in the list.
Vijay5b2f7792020-01-14 04:18:32 -0600168 Valid List chassis['Members']
Tony Lee2b975822021-04-01 11:15:00 +0800169 ... required_values=[{'@odata.id': '/redfish/v1/Chassis/${CHASSIS_ID}'}]
Vijay5b2f7792020-01-14 04:18:32 -0600170
171
172Verify Systems Defaults
173 [Documentation] Verify systems defaults.
174 [Tags] Verify_Systems_Defaults
175
176 ${systems}= Redfish.Get Properties /redfish/v1/Systems
177 Rprint Vars systems
178 ${systems_count}= Get Length ${systems['Members']}
Vijay5b2f7792020-01-14 04:18:32 -0600179 Valid Value systems['Name'] ['Computer System Collection']
180 Valid Value systems['@odata.id'] ['/redfish/v1/Systems']
181 Valid Value systems['Members@odata.count'] [${systems_count}]
182 Valid Value systems['Members@odata.count'] [${systems_count}]
Vijayff2c0bc2020-02-03 00:05:45 -0600183 # Members can be one or more, hence checking in the list.
Yi Huc32434a2024-01-11 17:33:10 -0800184 Valid List systems['Members'] required_values=[{'@odata.id': '/redfish/v1/Systems/${SYSTEM_ID}'}]
Vijay5b2f7792020-01-14 04:18:32 -0600185
186
187Verify Session Persistency After BMC Reboot
188 [Documentation] Verify session persistency after BMC reboot.
189 [Tags] Verify_Session_Persistency_After_BMC_Reboot
190
Vijayff2c0bc2020-02-03 00:05:45 -0600191 # Note the current session location.
Vijay5b2f7792020-01-14 04:18:32 -0600192 ${session_location}= Redfish.Get Session Location
193
194 Redfish OBMC Reboot (off) stack_mode=normal
Vijay5b2f7792020-01-14 04:18:32 -0600195
Vijayff2c0bc2020-02-03 00:05:45 -0600196 # Check for session persistency after BMC reboot.
197 # sessions here will have list of all sessions location.
Vijay5b2f7792020-01-14 04:18:32 -0600198 ${sessions}= Redfish.Get Attribute /redfish/v1/SessionService/Sessions Members
199 ${payload}= Create Dictionary @odata.id=${session_location}
200
201 List Should Contain Value ${sessions} ${payload}
202
Vijaye6fa8552020-01-14 04:44:36 -0600203*** Keywords ***
204
205Create Session And Verify Response Code
206 [Documentation] Create session and verify response code.
207 [Arguments] ${username}=${OPENBMC_USERNAME} ${password}=${OPENBMC_PASSWORD}
208 ... ${valid_status_code}=${HTTP_CREATED}
209
210 # Description of argument(s):
211 # username The username to create a session.
212 # password The password to create a session.
Vijayff2c0bc2020-02-03 00:05:45 -0600213 # valid_status_code Expected response code, default is ${HTTP_CREATED}.
Vijaye6fa8552020-01-14 04:44:36 -0600214
215 ${resp}= Redfish.Post /redfish/v1/SessionService/Sessions
216 ... body={'UserName':'${username}', 'Password': '${password}'}
217 ... valid_status_codes=[${valid_status_code}]
218
219
David Wangd511f5d2021-02-26 16:19:20 +0800220Set Session Timeout And Verify
221 [Documentation] Set Session Timeout And Verify.
222 [Arguments] ${value}=3600 ${valid_status_code}=${HTTP_OK}
223
224 # Description of argument(s):
225 # value The value to patch session timeout.
226 # valid_status_code Expected response code, default is ${HTTP_OK}.
227
nagarjunb22917d2e32022-04-20 09:57:29 +0530228 Redfish.Login
David Wangd511f5d2021-02-26 16:19:20 +0800229 ${data}= Create Dictionary SessionTimeout=${value}
230 Redfish.Patch ${REDFISH_BASE_URI}SessionService
231 ... body=&{data}
232 ... valid_status_codes=[${valid_status_code}]
233
234 ${session_timeout}= Redfish.Get Attribute
235 ... ${REDFISH_BASE_URI}SessionService SessionTimeout
236
237 Run Keyword If ${valid_status_code}==${HTTP_OK}
238 ... Valid Value session_timeout [${value}]
239
240
nagarjunb22917d2e32022-04-20 09:57:29 +0530241Create Session And Check Session Timeout
242 [Documentation] Create session and check session timeout.
243 [Arguments] ${value}
244
245 # Description of argument(s):
246 # value timeout value in integer to be configured.
247
248 ${resp}= Redfish.Post /redfish/v1/SessionService/Sessions
249 ... body={'UserName':'${OPENBMC_USERNAME}', 'Password': '${OPENBMC_PASSWORD}'}
250 ... valid_status_codes=[${HTTP_CREATED}]
251 ${session_id}= Set Variable ${resp.dict['@odata.id']}
252 Sleep ${value}s
253
254 Redfish.Get ${REDFISH_SESSION} valid_status_codes=[${HTTP_UNAUTHORIZED}]
255 # Since sessions will deleted so logging again.
256 Redfish.login
257 ${session_list}= Redfish.Get Members List /redfish/v1/SessionService/Sessions
258
259 List Should Not Contain Value ${session_list} ${session_id}
260
261
262Set Session Timeout And Verify Session Deleted After Timeout
263 [Documentation] Set timeout for session service and verify session is deleted after timeout.
264 [Arguments] ${timeout_value}
265
266 # Description of argument(s):
267 # timeout_value timeout value in integer to be configured.
268
269 ${data}= Create Dictionary SessionTimeout=${timeout_value}
270 ${resp_patch}= Redfish.Patch /redfish/v1/SessionService
271 ... body=&{data} valid_status_codes=[${HTTP_OK}]
272 Create Session And Check Session Timeout ${timeout_value}
273
274
275Get Default Timeout Value
276 [Documentation] Get default session timeout value and set as a suite variable.
277
278 ${Default_Timeout_Value}= Redfish.Get Attribute /redfish/v1/SessionService SessionTimeout
279 Set Suite Variable ${Default_Timeout_Value}
280
281
Vijaye6fa8552020-01-14 04:44:36 -0600282Suite Setup Execution
283 [Documentation] Suite Setup Execution.
284
285 Redfish.Login
Rahul Maheshwarib0753972022-08-29 05:04:47 -0500286
287 # Skip operator user if SKIP_OPERATOR_USER is 1.
288 Run Keyword If
289 ... ${SKIP_OPERATOR_USER} == ${1}
290 ... Set Suite Variable &{USERS} Administrator=${ADMIN}
291 ... ELSE
292 ... Set Suite Variable &{USERS} Administrator=${ADMIN} Operator=${OPERATOR}
293
Vijayff2c0bc2020-02-03 00:05:45 -0600294 Create Users With Different Roles users=${USERS} force=${True}
nagarjunb22917d2e32022-04-20 09:57:29 +0530295 Get Default Timeout Value
Vijay39373152020-02-14 08:08:20 -0600296
297
298Suite Teardown Execution
299 [Documentation] Suite teardown execution.
300
301 Delete BMC Users Via Redfish users=${USERS}
nagarjunb22917d2e32022-04-20 09:57:29 +0530302 Run Keyword And Ignore Error Delete All Redfish Sessions
Vijay39373152020-02-14 08:08:20 -0600303 Redfish.Logout