blob: 60a7514800aac1a8d995eaf40145de0b5c292c2e [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
20&{USERS} Administrator=${ADMIN} Operator=${OPERATOR}
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}
36 operator_user TestPwd123 ${HTTP_CREATED}
Vijay53a00552020-01-08 04:24:47 -060037
38
David Wangd511f5d2021-02-26 16:19:20 +080039Set Session Timeout And Verify Response Code
40 [Documentation] Set Session Timeout And Verify Response Code.
41 [Tags] Set_Session_Timeout_And_Verify_Response_Code
42 [Template] Set Session Timeout And Verify
nagarjunb22917d2e32022-04-20 09:57:29 +053043 [Teardown] Set Session Timeout And Verify ${Default_Timeout_Value} ${HTTP_OK}
David Wangd511f5d2021-02-26 16:19:20 +080044
George Keishing96143832021-03-23 07:55:08 -050045 # The minimum & maximum allowed values for session timeout are 30
David Wangd511f5d2021-02-26 16:19:20 +080046 # seconds and 86400 seconds respectively as per the session service
47 # schema mentioned at
48 # https://redfish.dmtf.org/schemas/v1/SessionService.v1_1_7.json
49
50 # value valid_status_code
51 ${25} ${HTTP_BAD_REQUEST}
52 ${30} ${HTTP_OK}
53 ${3600} ${HTTP_OK}
54 ${86400} ${HTTP_OK}
55 ${86500} ${HTTP_BAD_REQUEST}
56
57
nagarjunb22917d2e32022-04-20 09:57:29 +053058Set Session Timeout And Verify Session After Timeout
59 [Documentation] Set timeout for session service and verify session is deleted after timeout.
60 [Tags] Set_Session_Timeout_And_Verify_Session_After_Timeout
61 [Teardown] Set Session Timeout And Verify ${Default_Timeout_Value} ${HTTP_OK}
62 [Template] Set Session Timeout And Verify Session Deleted After Timeout
63
64 #timeout Value
65 ${30}
66 ${300}
67
68
69Verify Session Login And Logout For Newly Created User
70 [Documentation] Verify able to login and logout using the session created for new user.
71 [Tags] Verify_Session_Login_And_Logout_For_Newly_Created_User
72 [Teardown] Redfish.Login
73
74 # Logout already created redfish session.
75 Redfish.Logout
76 Redfish.Login ${ADMIN}[0] ${ADMIN}[1]
77 ${systems}= Redfish.Get Properties /redfish/v1/Systems
78 Rprint Vars systems
79 Redfish.Logout
80 ${systems}= Redfish.Get /redfish/v1/Systems
81 ... valid_status_codes=[${HTTP_UNAUTHORIZED}]
82
83
Vijay53a00552020-01-08 04:24:47 -060084Verify SessionService Defaults
85 [Documentation] Verify SessionService default property values.
86 [Tags] Verify_SessionService_Defaults
87
88 ${session_service}= Redfish.Get Properties /redfish/v1/SessionService
89 Rprint Vars session_service
90
Vijay53a00552020-01-08 04:24:47 -060091 Valid Value session_service['@odata.id'] ['/redfish/v1/SessionService/']
92 Valid Value session_service['Description'] ['Session Service']
93 Valid Value session_service['Id'] ['SessionService']
94 Valid Value session_service['Name'] ['Session Service']
95 Valid Value session_service['ServiceEnabled'] [True]
nagarjunb22917d2e32022-04-20 09:57:29 +053096 Valid Value session_service['SessionTimeout'] [${Default_Timeout_Value}]
Vijay53a00552020-01-08 04:24:47 -060097 Valid Value session_service['Sessions']['@odata.id'] ['/redfish/v1/SessionService/Sessions']
98
99
100Verify Sessions Defaults
101 [Documentation] Verify Sessions default property values.
102 [Tags] Verify_Sessions_Defaults
103
104 ${sessions}= Redfish.Get Properties /redfish/v1/SessionService/Sessions
105 Rprint Vars sessions
106 ${sessions_count}= Get length ${sessions['Members']}
107
Vijay53a00552020-01-08 04:24:47 -0600108 Valid Value sessions['@odata.id'] ['/redfish/v1/SessionService/Sessions/']
109 Valid Value sessions['Description'] ['Session Collection']
110 Valid Value sessions['Name'] ['Session Collection']
111 Valid Value sessions['Members@odata.count'] [${sessions_count}]
112
113
114Verify Current Session Defaults
115 [Documentation] Verify Current session default property values.
116 [Tags] Verify_Current_Session_Defaults
117
118 ${session_location}= Redfish.Get Session Location
119 ${session_id}= Evaluate os.path.basename($session_location) modules=os
120 ${session_properties}= Redfish.Get Properties /redfish/v1/SessionService/Sessions/${session_id}
121 Rprint Vars session_location session_id session_properties
122
Vijay53a00552020-01-08 04:24:47 -0600123 Valid Value session_properties['@odata.id'] ['/redfish/v1/SessionService/Sessions/${session_id}']
124 Valid Value session_properties['Description'] ['Manager User Session']
125 Valid Value session_properties['Name'] ['User Session']
126 Valid Value session_properties['Id'] ['${session_id}']
127 Valid Value session_properties['UserName'] ['${OPENBMC_USERNAME}']
Vijay5b2f7792020-01-14 04:18:32 -0600128
129
130Verify Managers Defaults
131 [Documentation] Verify managers defaults.
132 [Tags] Verify_Managers_Defaults
133
134 ${managers}= Redfish.Get Properties /redfish/v1/Managers
135 Rprint Vars managers
136 ${managers_count}= Get Length ${managers['Members']}
137
Vijay5b2f7792020-01-14 04:18:32 -0600138 Valid Value managers['Name'] ['Manager Collection']
139 Valid Value managers['@odata.id'] ['/redfish/v1/Managers']
140 Valid Value managers['Members@odata.count'] [${managers_count}]
141
Vijayff2c0bc2020-02-03 00:05:45 -0600142 # Members can be one or more, hence checking in the list.
Vijay5b2f7792020-01-14 04:18:32 -0600143 Valid List managers['Members'] required_values=[{'@odata.id': '/redfish/v1/Managers/bmc'}]
144
145
146Verify Chassis Defaults
147 [Documentation] Verify chassis defaults.
148 [Tags] Verify_Chassis_Defaults
149
150 ${chassis}= Redfish.Get Properties /redfish/v1/Chassis
151 Rprint Vars chassis
152 ${chassis_count}= Get Length ${chassis['Members']}
153
Vijay5b2f7792020-01-14 04:18:32 -0600154 Valid Value chassis['Name'] ['Chassis Collection']
155 Valid Value chassis['@odata.id'] ['/redfish/v1/Chassis']
156 Valid Value chassis['Members@odata.count'] [${chassis_count}]
157 Valid Value chassis['Members@odata.count'] [${chassis_count}]
158
Vijayff2c0bc2020-02-03 00:05:45 -0600159 # Members can be one or more, hence checking in the list.
Vijay5b2f7792020-01-14 04:18:32 -0600160 Valid List chassis['Members']
Tony Lee2b975822021-04-01 11:15:00 +0800161 ... required_values=[{'@odata.id': '/redfish/v1/Chassis/${CHASSIS_ID}'}]
Vijay5b2f7792020-01-14 04:18:32 -0600162
163
164Verify Systems Defaults
165 [Documentation] Verify systems defaults.
166 [Tags] Verify_Systems_Defaults
167
168 ${systems}= Redfish.Get Properties /redfish/v1/Systems
169 Rprint Vars systems
170 ${systems_count}= Get Length ${systems['Members']}
Vijay5b2f7792020-01-14 04:18:32 -0600171 Valid Value systems['Name'] ['Computer System Collection']
172 Valid Value systems['@odata.id'] ['/redfish/v1/Systems']
173 Valid Value systems['Members@odata.count'] [${systems_count}]
174 Valid Value systems['Members@odata.count'] [${systems_count}]
Vijayff2c0bc2020-02-03 00:05:45 -0600175 # Members can be one or more, hence checking in the list.
Vijay5b2f7792020-01-14 04:18:32 -0600176 Valid List systems['Members'] required_values=[{'@odata.id': '/redfish/v1/Systems/system'}]
177
178
179Verify Session Persistency After BMC Reboot
180 [Documentation] Verify session persistency after BMC reboot.
181 [Tags] Verify_Session_Persistency_After_BMC_Reboot
182
Vijayff2c0bc2020-02-03 00:05:45 -0600183 # Note the current session location.
Vijay5b2f7792020-01-14 04:18:32 -0600184 ${session_location}= Redfish.Get Session Location
185
186 Redfish OBMC Reboot (off) stack_mode=normal
Vijay5b2f7792020-01-14 04:18:32 -0600187
Vijayff2c0bc2020-02-03 00:05:45 -0600188 # Check for session persistency after BMC reboot.
189 # sessions here will have list of all sessions location.
Vijay5b2f7792020-01-14 04:18:32 -0600190 ${sessions}= Redfish.Get Attribute /redfish/v1/SessionService/Sessions Members
191 ${payload}= Create Dictionary @odata.id=${session_location}
192
193 List Should Contain Value ${sessions} ${payload}
194
Vijaye6fa8552020-01-14 04:44:36 -0600195*** Keywords ***
196
197Create Session And Verify Response Code
198 [Documentation] Create session and verify response code.
199 [Arguments] ${username}=${OPENBMC_USERNAME} ${password}=${OPENBMC_PASSWORD}
200 ... ${valid_status_code}=${HTTP_CREATED}
201
202 # Description of argument(s):
203 # username The username to create a session.
204 # password The password to create a session.
Vijayff2c0bc2020-02-03 00:05:45 -0600205 # valid_status_code Expected response code, default is ${HTTP_CREATED}.
Vijaye6fa8552020-01-14 04:44:36 -0600206
207 ${resp}= Redfish.Post /redfish/v1/SessionService/Sessions
208 ... body={'UserName':'${username}', 'Password': '${password}'}
209 ... valid_status_codes=[${valid_status_code}]
210
211
David Wangd511f5d2021-02-26 16:19:20 +0800212Set Session Timeout And Verify
213 [Documentation] Set Session Timeout And Verify.
214 [Arguments] ${value}=3600 ${valid_status_code}=${HTTP_OK}
215
216 # Description of argument(s):
217 # value The value to patch session timeout.
218 # valid_status_code Expected response code, default is ${HTTP_OK}.
219
nagarjunb22917d2e32022-04-20 09:57:29 +0530220 Redfish.Login
David Wangd511f5d2021-02-26 16:19:20 +0800221 ${data}= Create Dictionary SessionTimeout=${value}
222 Redfish.Patch ${REDFISH_BASE_URI}SessionService
223 ... body=&{data}
224 ... valid_status_codes=[${valid_status_code}]
225
226 ${session_timeout}= Redfish.Get Attribute
227 ... ${REDFISH_BASE_URI}SessionService SessionTimeout
228
229 Run Keyword If ${valid_status_code}==${HTTP_OK}
230 ... Valid Value session_timeout [${value}]
231
232
nagarjunb22917d2e32022-04-20 09:57:29 +0530233Create Session And Check Session Timeout
234 [Documentation] Create session and check session timeout.
235 [Arguments] ${value}
236
237 # Description of argument(s):
238 # value timeout value in integer to be configured.
239
240 ${resp}= Redfish.Post /redfish/v1/SessionService/Sessions
241 ... body={'UserName':'${OPENBMC_USERNAME}', 'Password': '${OPENBMC_PASSWORD}'}
242 ... valid_status_codes=[${HTTP_CREATED}]
243 ${session_id}= Set Variable ${resp.dict['@odata.id']}
244 Sleep ${value}s
245
246 Redfish.Get ${REDFISH_SESSION} valid_status_codes=[${HTTP_UNAUTHORIZED}]
247 # Since sessions will deleted so logging again.
248 Redfish.login
249 ${session_list}= Redfish.Get Members List /redfish/v1/SessionService/Sessions
250
251 List Should Not Contain Value ${session_list} ${session_id}
252
253
254Set Session Timeout And Verify Session Deleted After Timeout
255 [Documentation] Set timeout for session service and verify session is deleted after timeout.
256 [Arguments] ${timeout_value}
257
258 # Description of argument(s):
259 # timeout_value timeout value in integer to be configured.
260
261 ${data}= Create Dictionary SessionTimeout=${timeout_value}
262 ${resp_patch}= Redfish.Patch /redfish/v1/SessionService
263 ... body=&{data} valid_status_codes=[${HTTP_OK}]
264 Create Session And Check Session Timeout ${timeout_value}
265
266
267Get Default Timeout Value
268 [Documentation] Get default session timeout value and set as a suite variable.
269
270 ${Default_Timeout_Value}= Redfish.Get Attribute /redfish/v1/SessionService SessionTimeout
271 Set Suite Variable ${Default_Timeout_Value}
272
273
Vijaye6fa8552020-01-14 04:44:36 -0600274Suite Setup Execution
275 [Documentation] Suite Setup Execution.
276
277 Redfish.Login
Vijayff2c0bc2020-02-03 00:05:45 -0600278 Create Users With Different Roles users=${USERS} force=${True}
nagarjunb22917d2e32022-04-20 09:57:29 +0530279 Get Default Timeout Value
Vijay39373152020-02-14 08:08:20 -0600280
281
282Suite Teardown Execution
283 [Documentation] Suite teardown execution.
284
285 Delete BMC Users Via Redfish users=${USERS}
nagarjunb22917d2e32022-04-20 09:57:29 +0530286 Run Keyword And Ignore Error Delete All Redfish Sessions
Vijay39373152020-02-14 08:08:20 -0600287 Redfish.Logout