blob: 718cb253b3b63a63f51d55b8b750de70aa661bbb [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}
38 operator_user TestPwd123 ${HTTP_CREATED}
Vijay53a00552020-01-08 04:24:47 -060039
40
David Wangd511f5d2021-02-26 16:19:20 +080041Set Session Timeout And Verify Response Code
42 [Documentation] Set Session Timeout And Verify Response Code.
43 [Tags] Set_Session_Timeout_And_Verify_Response_Code
44 [Template] Set Session Timeout And Verify
nagarjunb22917d2e32022-04-20 09:57:29 +053045 [Teardown] Set Session Timeout And Verify ${Default_Timeout_Value} ${HTTP_OK}
David Wangd511f5d2021-02-26 16:19:20 +080046
George Keishing96143832021-03-23 07:55:08 -050047 # The minimum & maximum allowed values for session timeout are 30
David Wangd511f5d2021-02-26 16:19:20 +080048 # seconds and 86400 seconds respectively as per the session service
49 # schema mentioned at
50 # https://redfish.dmtf.org/schemas/v1/SessionService.v1_1_7.json
51
52 # value valid_status_code
53 ${25} ${HTTP_BAD_REQUEST}
54 ${30} ${HTTP_OK}
55 ${3600} ${HTTP_OK}
56 ${86400} ${HTTP_OK}
57 ${86500} ${HTTP_BAD_REQUEST}
58
59
nagarjunb22917d2e32022-04-20 09:57:29 +053060Set Session Timeout And Verify Session After Timeout
61 [Documentation] Set timeout for session service and verify session is deleted after timeout.
62 [Tags] Set_Session_Timeout_And_Verify_Session_After_Timeout
63 [Teardown] Set Session Timeout And Verify ${Default_Timeout_Value} ${HTTP_OK}
64 [Template] Set Session Timeout And Verify Session Deleted After Timeout
65
66 #timeout Value
67 ${30}
68 ${300}
69
70
71Verify Session Login And Logout For Newly Created User
72 [Documentation] Verify able to login and logout using the session created for new user.
73 [Tags] Verify_Session_Login_And_Logout_For_Newly_Created_User
74 [Teardown] Redfish.Login
75
76 # Logout already created redfish session.
77 Redfish.Logout
78 Redfish.Login ${ADMIN}[0] ${ADMIN}[1]
79 ${systems}= Redfish.Get Properties /redfish/v1/Systems
80 Rprint Vars systems
81 Redfish.Logout
82 ${systems}= Redfish.Get /redfish/v1/Systems
83 ... valid_status_codes=[${HTTP_UNAUTHORIZED}]
84
85
Vijay53a00552020-01-08 04:24:47 -060086Verify SessionService Defaults
87 [Documentation] Verify SessionService default property values.
88 [Tags] Verify_SessionService_Defaults
89
90 ${session_service}= Redfish.Get Properties /redfish/v1/SessionService
91 Rprint Vars session_service
92
Vijay53a00552020-01-08 04:24:47 -060093 Valid Value session_service['@odata.id'] ['/redfish/v1/SessionService/']
94 Valid Value session_service['Description'] ['Session Service']
95 Valid Value session_service['Id'] ['SessionService']
96 Valid Value session_service['Name'] ['Session Service']
97 Valid Value session_service['ServiceEnabled'] [True]
nagarjunb22917d2e32022-04-20 09:57:29 +053098 Valid Value session_service['SessionTimeout'] [${Default_Timeout_Value}]
Vijay53a00552020-01-08 04:24:47 -060099 Valid Value session_service['Sessions']['@odata.id'] ['/redfish/v1/SessionService/Sessions']
100
101
102Verify Sessions Defaults
103 [Documentation] Verify Sessions default property values.
104 [Tags] Verify_Sessions_Defaults
105
106 ${sessions}= Redfish.Get Properties /redfish/v1/SessionService/Sessions
107 Rprint Vars sessions
108 ${sessions_count}= Get length ${sessions['Members']}
109
Vijay53a00552020-01-08 04:24:47 -0600110 Valid Value sessions['@odata.id'] ['/redfish/v1/SessionService/Sessions/']
111 Valid Value sessions['Description'] ['Session Collection']
112 Valid Value sessions['Name'] ['Session Collection']
113 Valid Value sessions['Members@odata.count'] [${sessions_count}]
114
115
116Verify Current Session Defaults
117 [Documentation] Verify Current session default property values.
118 [Tags] Verify_Current_Session_Defaults
119
120 ${session_location}= Redfish.Get Session Location
121 ${session_id}= Evaluate os.path.basename($session_location) modules=os
122 ${session_properties}= Redfish.Get Properties /redfish/v1/SessionService/Sessions/${session_id}
123 Rprint Vars session_location session_id session_properties
124
Vijay53a00552020-01-08 04:24:47 -0600125 Valid Value session_properties['@odata.id'] ['/redfish/v1/SessionService/Sessions/${session_id}']
126 Valid Value session_properties['Description'] ['Manager User Session']
127 Valid Value session_properties['Name'] ['User Session']
128 Valid Value session_properties['Id'] ['${session_id}']
129 Valid Value session_properties['UserName'] ['${OPENBMC_USERNAME}']
Vijay5b2f7792020-01-14 04:18:32 -0600130
131
132Verify Managers Defaults
133 [Documentation] Verify managers defaults.
134 [Tags] Verify_Managers_Defaults
135
136 ${managers}= Redfish.Get Properties /redfish/v1/Managers
137 Rprint Vars managers
138 ${managers_count}= Get Length ${managers['Members']}
139
Vijay5b2f7792020-01-14 04:18:32 -0600140 Valid Value managers['Name'] ['Manager Collection']
141 Valid Value managers['@odata.id'] ['/redfish/v1/Managers']
142 Valid Value managers['Members@odata.count'] [${managers_count}]
143
Vijayff2c0bc2020-02-03 00:05:45 -0600144 # Members can be one or more, hence checking in the list.
Vijay5b2f7792020-01-14 04:18:32 -0600145 Valid List managers['Members'] required_values=[{'@odata.id': '/redfish/v1/Managers/bmc'}]
146
147
148Verify Chassis Defaults
149 [Documentation] Verify chassis defaults.
150 [Tags] Verify_Chassis_Defaults
151
152 ${chassis}= Redfish.Get Properties /redfish/v1/Chassis
153 Rprint Vars chassis
154 ${chassis_count}= Get Length ${chassis['Members']}
155
Vijay5b2f7792020-01-14 04:18:32 -0600156 Valid Value chassis['Name'] ['Chassis Collection']
157 Valid Value chassis['@odata.id'] ['/redfish/v1/Chassis']
158 Valid Value chassis['Members@odata.count'] [${chassis_count}]
159 Valid Value chassis['Members@odata.count'] [${chassis_count}]
160
Vijayff2c0bc2020-02-03 00:05:45 -0600161 # Members can be one or more, hence checking in the list.
Vijay5b2f7792020-01-14 04:18:32 -0600162 Valid List chassis['Members']
Tony Lee2b975822021-04-01 11:15:00 +0800163 ... required_values=[{'@odata.id': '/redfish/v1/Chassis/${CHASSIS_ID}'}]
Vijay5b2f7792020-01-14 04:18:32 -0600164
165
166Verify Systems Defaults
167 [Documentation] Verify systems defaults.
168 [Tags] Verify_Systems_Defaults
169
170 ${systems}= Redfish.Get Properties /redfish/v1/Systems
171 Rprint Vars systems
172 ${systems_count}= Get Length ${systems['Members']}
Vijay5b2f7792020-01-14 04:18:32 -0600173 Valid Value systems['Name'] ['Computer System Collection']
174 Valid Value systems['@odata.id'] ['/redfish/v1/Systems']
175 Valid Value systems['Members@odata.count'] [${systems_count}]
176 Valid Value systems['Members@odata.count'] [${systems_count}]
Vijayff2c0bc2020-02-03 00:05:45 -0600177 # Members can be one or more, hence checking in the list.
Vijay5b2f7792020-01-14 04:18:32 -0600178 Valid List systems['Members'] required_values=[{'@odata.id': '/redfish/v1/Systems/system'}]
179
180
181Verify Session Persistency After BMC Reboot
182 [Documentation] Verify session persistency after BMC reboot.
183 [Tags] Verify_Session_Persistency_After_BMC_Reboot
184
Vijayff2c0bc2020-02-03 00:05:45 -0600185 # Note the current session location.
Vijay5b2f7792020-01-14 04:18:32 -0600186 ${session_location}= Redfish.Get Session Location
187
188 Redfish OBMC Reboot (off) stack_mode=normal
Vijay5b2f7792020-01-14 04:18:32 -0600189
Vijayff2c0bc2020-02-03 00:05:45 -0600190 # Check for session persistency after BMC reboot.
191 # sessions here will have list of all sessions location.
Vijay5b2f7792020-01-14 04:18:32 -0600192 ${sessions}= Redfish.Get Attribute /redfish/v1/SessionService/Sessions Members
193 ${payload}= Create Dictionary @odata.id=${session_location}
194
195 List Should Contain Value ${sessions} ${payload}
196
Vijaye6fa8552020-01-14 04:44:36 -0600197*** Keywords ***
198
199Create Session And Verify Response Code
200 [Documentation] Create session and verify response code.
201 [Arguments] ${username}=${OPENBMC_USERNAME} ${password}=${OPENBMC_PASSWORD}
202 ... ${valid_status_code}=${HTTP_CREATED}
203
204 # Description of argument(s):
205 # username The username to create a session.
206 # password The password to create a session.
Vijayff2c0bc2020-02-03 00:05:45 -0600207 # valid_status_code Expected response code, default is ${HTTP_CREATED}.
Vijaye6fa8552020-01-14 04:44:36 -0600208
209 ${resp}= Redfish.Post /redfish/v1/SessionService/Sessions
210 ... body={'UserName':'${username}', 'Password': '${password}'}
211 ... valid_status_codes=[${valid_status_code}]
212
213
David Wangd511f5d2021-02-26 16:19:20 +0800214Set Session Timeout And Verify
215 [Documentation] Set Session Timeout And Verify.
216 [Arguments] ${value}=3600 ${valid_status_code}=${HTTP_OK}
217
218 # Description of argument(s):
219 # value The value to patch session timeout.
220 # valid_status_code Expected response code, default is ${HTTP_OK}.
221
nagarjunb22917d2e32022-04-20 09:57:29 +0530222 Redfish.Login
David Wangd511f5d2021-02-26 16:19:20 +0800223 ${data}= Create Dictionary SessionTimeout=${value}
224 Redfish.Patch ${REDFISH_BASE_URI}SessionService
225 ... body=&{data}
226 ... valid_status_codes=[${valid_status_code}]
227
228 ${session_timeout}= Redfish.Get Attribute
229 ... ${REDFISH_BASE_URI}SessionService SessionTimeout
230
231 Run Keyword If ${valid_status_code}==${HTTP_OK}
232 ... Valid Value session_timeout [${value}]
233
234
nagarjunb22917d2e32022-04-20 09:57:29 +0530235Create Session And Check Session Timeout
236 [Documentation] Create session and check session timeout.
237 [Arguments] ${value}
238
239 # Description of argument(s):
240 # value timeout value in integer to be configured.
241
242 ${resp}= Redfish.Post /redfish/v1/SessionService/Sessions
243 ... body={'UserName':'${OPENBMC_USERNAME}', 'Password': '${OPENBMC_PASSWORD}'}
244 ... valid_status_codes=[${HTTP_CREATED}]
245 ${session_id}= Set Variable ${resp.dict['@odata.id']}
246 Sleep ${value}s
247
248 Redfish.Get ${REDFISH_SESSION} valid_status_codes=[${HTTP_UNAUTHORIZED}]
249 # Since sessions will deleted so logging again.
250 Redfish.login
251 ${session_list}= Redfish.Get Members List /redfish/v1/SessionService/Sessions
252
253 List Should Not Contain Value ${session_list} ${session_id}
254
255
256Set Session Timeout And Verify Session Deleted After Timeout
257 [Documentation] Set timeout for session service and verify session is deleted after timeout.
258 [Arguments] ${timeout_value}
259
260 # Description of argument(s):
261 # timeout_value timeout value in integer to be configured.
262
263 ${data}= Create Dictionary SessionTimeout=${timeout_value}
264 ${resp_patch}= Redfish.Patch /redfish/v1/SessionService
265 ... body=&{data} valid_status_codes=[${HTTP_OK}]
266 Create Session And Check Session Timeout ${timeout_value}
267
268
269Get Default Timeout Value
270 [Documentation] Get default session timeout value and set as a suite variable.
271
272 ${Default_Timeout_Value}= Redfish.Get Attribute /redfish/v1/SessionService SessionTimeout
273 Set Suite Variable ${Default_Timeout_Value}
274
275
Vijaye6fa8552020-01-14 04:44:36 -0600276Suite Setup Execution
277 [Documentation] Suite Setup Execution.
278
279 Redfish.Login
Rahul Maheshwarib0753972022-08-29 05:04:47 -0500280
281 # Skip operator user if SKIP_OPERATOR_USER is 1.
282 Run Keyword If
283 ... ${SKIP_OPERATOR_USER} == ${1}
284 ... Set Suite Variable &{USERS} Administrator=${ADMIN}
285 ... ELSE
286 ... Set Suite Variable &{USERS} Administrator=${ADMIN} Operator=${OPERATOR}
287
Vijayff2c0bc2020-02-03 00:05:45 -0600288 Create Users With Different Roles users=${USERS} force=${True}
nagarjunb22917d2e32022-04-20 09:57:29 +0530289 Get Default Timeout Value
Vijay39373152020-02-14 08:08:20 -0600290
291
292Suite Teardown Execution
293 [Documentation] Suite teardown execution.
294
295 Delete BMC Users Via Redfish users=${USERS}
nagarjunb22917d2e32022-04-20 09:57:29 +0530296 Run Keyword And Ignore Error Delete All Redfish Sessions
Vijay39373152020-02-14 08:08:20 -0600297 Redfish.Logout