blob: ff05c18cb2e4f7bb7a29e12762915bf341b9532b [file] [log] [blame]
manashsarma8b5d6802020-03-09 04:09:15 -05001*** Settings ***
manashsarma91abf372020-03-17 20:34:02 -05002
3
manashsarma8b5d6802020-03-09 04:09:15 -05004Documentation Verify Redfish tool functionality.
5
manashsarma91abf372020-03-17 20:34:02 -05006Library OperatingSystem
7Library String
8Library Collections
manashsarma8b5d6802020-03-09 04:09:15 -05009
manashsarma91abf372020-03-17 20:34:02 -050010Resource ../../lib/resource.robot
11Resource ../../lib/bmc_redfish_resource.robot
12Resource ../../lib/openbmc_ffdc.robot
manashsarma8b5d6802020-03-09 04:09:15 -050013
manashsarma91abf372020-03-17 20:34:02 -050014
15Suite Setup Suite Setup Execution
16
manashsarma8b5d6802020-03-09 04:09:15 -050017
18*** Variables ***
19
manashsarma91abf372020-03-17 20:34:02 -050020
21${root_cmd_args} redfishtool raw -r ${OPENBMC_HOST} -u ${OPENBMC_USERNAME} -p ${OPENBMC_PASSWORD} -S Always
22${min_number_sensors} ${15}
manashsarma8b5d6802020-03-09 04:09:15 -050023
24*** Test Cases ***
25
manashsarma91abf372020-03-17 20:34:02 -050026
manashsarma8b5d6802020-03-09 04:09:15 -050027Verify Redfishtool Sensor Commands
28 [Documentation] Verify redfishtool's sensor commands.
29 [Tags] Verify_Redfishtool_Sensor_Commands
30
31 ${sensor_status}= Redfishtool Get /redfish/v1/Chassis/chassis/Sensors
32 ${json_object}= Evaluate json.loads('''${sensor_status}''') json
33 Should Be True ${json_object["Members@odata.count"]} > ${min_number_sensors}
34 ... msg=There should be at least ${min_number_sensors} sensors.
35
manashsarma91abf372020-03-17 20:34:02 -050036
manashsarma8b5d6802020-03-09 04:09:15 -050037Verify Redfishtool Health Check Commands
38 [Documentation] Verify redfishtool's health check command.
39 [Tags] Verify_Redfishtool_Health_Check_Commands
40
41 ${chassis_data}= Redfishtool Get /redfish/v1/Chassis/chassis/
42 ${json_object}= Evaluate json.loads('''${chassis_data}''') json
43 ${status}= Set Variable ${json_object["Status"]}
44 Should Be Equal OK ${status["Health"]}
45 ... msg=Health status should be OK.
46
manashsarma91abf372020-03-17 20:34:02 -050047
48Verify Redfishtool Create Users
49 [Documentation] Create user via Redfishtool and verify.
50 [Tags] Verify_Redfishtool_Create_Users
51 [Teardown] Redfishtool Delete User "UserT100"
52
53 Redfishtool Create User "UserT100" "TestPwd123" "Operator" true
54 Redfishtool Verify User "UserT100" "Operator"
55
56
57Verify Redfishtool Modify Users
58 [Documentation] Modify user via Redfishtool and verify.
59 [Tags] Verify_Redfishtool_Modify_Users
60 [Teardown] Redfishtool Delete User "UserT100"
61
62 Redfishtool Create User "UserT100" "TestPwd123" "Operator" true
63 Redfishtool Update User Role "UserT100" "Administrator"
64 Redfishtool Verify User "UserT100" "Administrator"
65
66
67Verify Redfishtool Delete Users
68 [Documentation] Delete user via Redfishtool and verify.
69 [Tags] Verify_Redfishtool_Delete_Users
70
71 Redfishtool Create User "UserT100" "TestPwd123" "Operator" true
72 Redfishtool Delete User "UserT100"
73 ${status}= Redfishtool Verify User Name Exists "UserT100"
74 Should Be True ${status} == False
75
76
manashsarma8b5d6802020-03-09 04:09:15 -050077*** Keywords ***
78
manashsarma91abf372020-03-17 20:34:02 -050079
80Is HTTP error Expected
81 [Documentation] Check if the HTTP error is expected.
82 [Arguments] ${cmd_output} ${error_expected}
manashsarma8b5d6802020-03-09 04:09:15 -050083
84 # Description of argument(s):
manashsarma91abf372020-03-17 20:34:02 -050085 # cmd_output Output of an HTTP operation.
86 # error_expected Expected error.
manashsarma8b5d6802020-03-09 04:09:15 -050087
manashsarma91abf372020-03-17 20:34:02 -050088 ${error_expected}= Evaluate "${error_expected}" in """${cmd_output}"""
89 Should Be True ${error_expected} == True
90
91
92Redfishtool Create User
93 [Documentation] Create new user.
94 [Arguments] ${user_name} ${password} ${roleID} ${enable} ${expected_error}=""
95
96 # Description of argument(s):
97 # user_name The user name (e.g. "test", "robert", etc.).
98 # password The user password (e.g. "0penBmc", "0penBmc1", etc.).
99 # roleID The role of user (e.g. "Administrator", "Operator", etc.).
100 # enable Enabled attribute of (e.g. true or false).
101 # expected_error Expected error optionally provided in testcase (e.g. 401 /
102 # authentication error, etc. )
103
104 ${data}= Set Variable '{"UserName":${user_name},"Password":${password},"RoleId":${roleId},"Enabled":${enable}}'
105 Redfishtool Post ${data} /redfish/v1/AccountService/Accounts ${root_cmd_args}
106 ... ${expected_error}
107
108Redfishtool Update User Role
109 [Documentation] Update user role.
110 [Arguments] ${user_name} ${newRole} ${login_user}="" ${login_pasword}=""
111 ... ${expected_error}=""
112
113 # Description of argument(s):
114 # user_name The user name (e.g. "test", "robert", etc.).
115 # newRole The new role of user (e.g. "Administrator", "Operator", etc.).
116 # login_user The login user name used other than default root user.
117 # login_pasword The login password.
118 # expected_error Expected error optionally provided in testcase (e.g. 401 /
119 # authentication error, etc. )
120
121 Redfishtool Patch '{"RoleId":${newRole}}' /redfish/v1/AccountService/Accounts/${user_name}
122 ... ${root_cmd_args} ${expected_error}
123
124Redfishtool Delete User
125 [Documentation] Delete an user.
126 [Arguments] ${user_name} ${expected_error}=""
127
128 # Description of argument(s):
129 # user_name The user name (e.g. "test", "robert", etc.).
130 # expected_error Expected error optionally provided in testcase (e.g. 401 /
131 # authentication error, etc. ).
132
133 Redfishtool Delete /redfish/v1/AccountService/Accounts/${user_name}
134 ... ${root_cmd_args} ${expected_error}
135
136
137Redfishtool Verify User
138 [Documentation] Verify role of the user.
139 [Arguments] ${user_name} ${role}
140
141 # Description of argument(s):
142 # user_name The user name (e.g. "test", "robert", etc.).
143 # role The new role of user (e.g. "Administrator", "Operator", etc.).
144
145 ${user_account}= Redfishtool Get /redfish/v1/AccountService/Accounts/${user_name}
146 ${json_obj}= Evaluate json.loads('''${user_account}''') json
147 Should Be equal "${json_obj["RoleId"]}" ${role}
148
149
150Redfishtool Verify User Name Exists
151 [Documentation] Verify user name exists.
152 [Arguments] ${user_name}
153
154 # Description of argument(s):
155 # user_name The user name (e.g. "test", "robert", etc.).
156
157 ${status}= Run Keyword And Return Status redfishtool Get
158 ... /redfish/v1/AccountService/Accounts/${user_name}
159 [return] ${status}
160
161
162Redfishtool Get
163 [Documentation] Execute redfishtool for GET operation.
164 [Arguments] ${uri} ${cmd_args}=${root_cmd_args} ${expected_error}=""
165
166 # Description of argument(s):
167 # uri URI for GET operation (e.g. /redfish/v1/AccountService/Accounts/).
168 # cmd_args Commandline arguments.
169 # expected_error Expected error optionally provided in testcase (e.g. 401 /
170 # authentication error, etc. ).
171
172 ${rc} ${cmd_output}= Run and Return RC and Output ${cmd_args} GET ${uri}
173 Run Keyword If ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error}
manashsarma8b5d6802020-03-09 04:09:15 -0500174 [Return] ${cmd_output}
175
manashsarma91abf372020-03-17 20:34:02 -0500176
177Redfishtool Post
178 [Documentation] Execute redfishtool for Post operation.
179 [Arguments] ${payload} ${uri} ${cmd_args}=${root_cmd_args} ${expected_error}=""
180
181 # Description of argument(s):
182 # payload Payload with POST operation (e.g. data for user name, password, role,
183 # enabled attribute)
184 # uri URI for POST operation (e.g. /redfish/v1/AccountService/Accounts/).
185 # cmd_args Commandline arguments.
186 # expected_error Expected error optionally provided in testcase (e.g. 401 /
187 # authentication error, etc. ).
188
189 ${rc} ${cmd_output}= Run and Return RC and Output ${cmd_args} POST ${uri} --data=${payload}
190 Run Keyword If ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error}
191 [Return] ${cmd_output}
192
193
194Redfishtool Patch
195 [Documentation] Execute redfishtool for Patch operation.
196 [Arguments] ${payload} ${uri} ${cmd_args}=${root_cmd_args} ${expected_error}=""
197
198 # Description of argument(s):
199 # payload Payload with POST operation (e.g. data for user name, role, etc. ).
200 # uri URI for PATCH operation (e.g. /redfish/v1/AccountService/Accounts/ ).
201 # cmd_args Commandline arguments.
202 # expected_error Expected error optionally provided in testcase (e.g. 401 /
203 # authentication error, etc. ).
204
205 ${rc} ${cmd_output}= Run and Return RC and Output ${cmd_args} PATCH ${uri} --data=${payload}
206 Run Keyword If ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error}
207 [Return] ${cmd_output}
208
209
210Redfishtool Delete
211 [Documentation] Execute redfishtool for Post operation.
212 [Arguments] ${uri} ${cmd_args}=${root_cmd_args} ${expected_error}=""
213
214 # Description of argument(s):
215 # uri URI for DELETE operation.
216 # cmd_args Commandline arguments.
217 # expected_error Expected error optionally provided in testcase (e.g. 401 /
218 # authentication error, etc. ).
219
220 ${rc} ${cmd_output}= Run and Return RC and Output ${cmd_args} DELETE ${uri}
221 Run Keyword If ${rc} != 0 Is HTTP error Expected ${cmd_output} ${expected_error}
222 [Return] ${cmd_output}
223
224
manashsarma8b5d6802020-03-09 04:09:15 -0500225Suite Setup Execution
226 [Documentation] Do suite setup execution.
227
228 ${tool_exist}= Run which redfishtool
229 Should Not Be Empty ${tool_exist}