blob: 1ef3717c43f517952c0785c11120166db89f4afb [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.
27 [Tags] Create_Session_And_Verify_Response_Code_Using_Different_Credentails
28 [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
43 [Teardown] Set Session Timeout And Verify ${3600} ${HTTP_OK}
44
45 # The mininum & maximum allowed values for session timeout are 30
46 # 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
Vijay53a00552020-01-08 04:24:47 -060058Verify SessionService Defaults
59 [Documentation] Verify SessionService default property values.
60 [Tags] Verify_SessionService_Defaults
61
62 ${session_service}= Redfish.Get Properties /redfish/v1/SessionService
63 Rprint Vars session_service
64
Vijay53a00552020-01-08 04:24:47 -060065 Valid Value session_service['@odata.id'] ['/redfish/v1/SessionService/']
66 Valid Value session_service['Description'] ['Session Service']
67 Valid Value session_service['Id'] ['SessionService']
68 Valid Value session_service['Name'] ['Session Service']
69 Valid Value session_service['ServiceEnabled'] [True]
70 Valid Value session_service['SessionTimeout'] [3600]
71 Valid Value session_service['Sessions']['@odata.id'] ['/redfish/v1/SessionService/Sessions']
72
73
74Verify Sessions Defaults
75 [Documentation] Verify Sessions default property values.
76 [Tags] Verify_Sessions_Defaults
77
78 ${sessions}= Redfish.Get Properties /redfish/v1/SessionService/Sessions
79 Rprint Vars sessions
80 ${sessions_count}= Get length ${sessions['Members']}
81
Vijay53a00552020-01-08 04:24:47 -060082 Valid Value sessions['@odata.id'] ['/redfish/v1/SessionService/Sessions/']
83 Valid Value sessions['Description'] ['Session Collection']
84 Valid Value sessions['Name'] ['Session Collection']
85 Valid Value sessions['Members@odata.count'] [${sessions_count}]
86
87
88Verify Current Session Defaults
89 [Documentation] Verify Current session default property values.
90 [Tags] Verify_Current_Session_Defaults
91
92 ${session_location}= Redfish.Get Session Location
93 ${session_id}= Evaluate os.path.basename($session_location) modules=os
94 ${session_properties}= Redfish.Get Properties /redfish/v1/SessionService/Sessions/${session_id}
95 Rprint Vars session_location session_id session_properties
96
Vijay53a00552020-01-08 04:24:47 -060097 Valid Value session_properties['@odata.id'] ['/redfish/v1/SessionService/Sessions/${session_id}']
98 Valid Value session_properties['Description'] ['Manager User Session']
99 Valid Value session_properties['Name'] ['User Session']
100 Valid Value session_properties['Id'] ['${session_id}']
101 Valid Value session_properties['UserName'] ['${OPENBMC_USERNAME}']
Vijay5b2f7792020-01-14 04:18:32 -0600102
103
104Verify Managers Defaults
105 [Documentation] Verify managers defaults.
106 [Tags] Verify_Managers_Defaults
107
108 ${managers}= Redfish.Get Properties /redfish/v1/Managers
109 Rprint Vars managers
110 ${managers_count}= Get Length ${managers['Members']}
111
Vijay5b2f7792020-01-14 04:18:32 -0600112 Valid Value managers['Name'] ['Manager Collection']
113 Valid Value managers['@odata.id'] ['/redfish/v1/Managers']
114 Valid Value managers['Members@odata.count'] [${managers_count}]
115
Vijayff2c0bc2020-02-03 00:05:45 -0600116 # Members can be one or more, hence checking in the list.
Vijay5b2f7792020-01-14 04:18:32 -0600117 Valid List managers['Members'] required_values=[{'@odata.id': '/redfish/v1/Managers/bmc'}]
118
119
120Verify Chassis Defaults
121 [Documentation] Verify chassis defaults.
122 [Tags] Verify_Chassis_Defaults
123
124 ${chassis}= Redfish.Get Properties /redfish/v1/Chassis
125 Rprint Vars chassis
126 ${chassis_count}= Get Length ${chassis['Members']}
127
Vijay5b2f7792020-01-14 04:18:32 -0600128 Valid Value chassis['Name'] ['Chassis Collection']
129 Valid Value chassis['@odata.id'] ['/redfish/v1/Chassis']
130 Valid Value chassis['Members@odata.count'] [${chassis_count}]
131 Valid Value chassis['Members@odata.count'] [${chassis_count}]
132
Vijayff2c0bc2020-02-03 00:05:45 -0600133 # Members can be one or more, hence checking in the list.
Vijay5b2f7792020-01-14 04:18:32 -0600134 Valid List chassis['Members']
135 ... required_values=[{'@odata.id': '/redfish/v1/Chassis/chassis'}]
136
137
138Verify Systems Defaults
139 [Documentation] Verify systems defaults.
140 [Tags] Verify_Systems_Defaults
141
142 ${systems}= Redfish.Get Properties /redfish/v1/Systems
143 Rprint Vars systems
144 ${systems_count}= Get Length ${systems['Members']}
Vijay5b2f7792020-01-14 04:18:32 -0600145 Valid Value systems['Name'] ['Computer System Collection']
146 Valid Value systems['@odata.id'] ['/redfish/v1/Systems']
147 Valid Value systems['Members@odata.count'] [${systems_count}]
148 Valid Value systems['Members@odata.count'] [${systems_count}]
Vijayff2c0bc2020-02-03 00:05:45 -0600149 # Members can be one or more, hence checking in the list.
Vijay5b2f7792020-01-14 04:18:32 -0600150 Valid List systems['Members'] required_values=[{'@odata.id': '/redfish/v1/Systems/system'}]
151
152
153Verify Session Persistency After BMC Reboot
154 [Documentation] Verify session persistency after BMC reboot.
155 [Tags] Verify_Session_Persistency_After_BMC_Reboot
156
Vijayff2c0bc2020-02-03 00:05:45 -0600157 # Note the current session location.
Vijay5b2f7792020-01-14 04:18:32 -0600158 ${session_location}= Redfish.Get Session Location
159
160 Redfish OBMC Reboot (off) stack_mode=normal
161 Redfish.Login
162
Vijayff2c0bc2020-02-03 00:05:45 -0600163 # Check for session persistency after BMC reboot.
164 # sessions here will have list of all sessions location.
Vijay5b2f7792020-01-14 04:18:32 -0600165 ${sessions}= Redfish.Get Attribute /redfish/v1/SessionService/Sessions Members
166 ${payload}= Create Dictionary @odata.id=${session_location}
167
168 List Should Contain Value ${sessions} ${payload}
169
170
171REST Logging Interface Read Should Be A SUCCESS For Authorized Users
172 [Documentation] REST logging interface read should be a success for authorized users.
173 [Tags] REST_Logging_Interface_Read_Should_Be_A_SUCCESS_For_Authorized_Users
174
175 ${resp}= Redfish.Get /xyz/openbmc_project/logging
176
177 ${resp_output}= evaluate json.loads('''${resp.text}''') json
178 ${log_count}= Get Length ${resp_output["data"]}
179
Vijayff2c0bc2020-02-03 00:05:45 -0600180 # Max 200 error logs are allowed in OpenBmc.
Vijay5b2f7792020-01-14 04:18:32 -0600181 Run Keyword Unless ${-1} < ${log_count} < ${201} Fail
182
Vijaye6fa8552020-01-14 04:44:36 -0600183
Vijaye6fa8552020-01-14 04:44:36 -0600184*** Keywords ***
185
186Create Session And Verify Response Code
187 [Documentation] Create session and verify response code.
188 [Arguments] ${username}=${OPENBMC_USERNAME} ${password}=${OPENBMC_PASSWORD}
189 ... ${valid_status_code}=${HTTP_CREATED}
190
191 # Description of argument(s):
192 # username The username to create a session.
193 # password The password to create a session.
Vijayff2c0bc2020-02-03 00:05:45 -0600194 # valid_status_code Expected response code, default is ${HTTP_CREATED}.
Vijaye6fa8552020-01-14 04:44:36 -0600195
196 ${resp}= Redfish.Post /redfish/v1/SessionService/Sessions
197 ... body={'UserName':'${username}', 'Password': '${password}'}
198 ... valid_status_codes=[${valid_status_code}]
199
200
David Wangd511f5d2021-02-26 16:19:20 +0800201Set Session Timeout And Verify
202 [Documentation] Set Session Timeout And Verify.
203 [Arguments] ${value}=3600 ${valid_status_code}=${HTTP_OK}
204
205 # Description of argument(s):
206 # value The value to patch session timeout.
207 # valid_status_code Expected response code, default is ${HTTP_OK}.
208
209 ${data}= Create Dictionary SessionTimeout=${value}
210 Redfish.Patch ${REDFISH_BASE_URI}SessionService
211 ... body=&{data}
212 ... valid_status_codes=[${valid_status_code}]
213
214 ${session_timeout}= Redfish.Get Attribute
215 ... ${REDFISH_BASE_URI}SessionService SessionTimeout
216
217 Run Keyword If ${valid_status_code}==${HTTP_OK}
218 ... Valid Value session_timeout [${value}]
219
220
Vijaye6fa8552020-01-14 04:44:36 -0600221Suite Setup Execution
222 [Documentation] Suite Setup Execution.
223
224 Redfish.Login
Vijayff2c0bc2020-02-03 00:05:45 -0600225 Create Users With Different Roles users=${USERS} force=${True}
Vijay39373152020-02-14 08:08:20 -0600226
227
228Suite Teardown Execution
229 [Documentation] Suite teardown execution.
230
231 Delete BMC Users Via Redfish users=${USERS}
232 Redfish.Logout