blob: 5e1fc3772a47b95ce4c98b2ac5d74ce82f79895d [file] [log] [blame]
Chris Austenb29d2e82016-06-07 12:25:35 -05001*** Settings ***
George Keishing85536662017-03-03 10:49:58 -06002Documentation Verify REST services Get/Put/Post/Delete.
Chris Austenb29d2e82016-06-07 12:25:35 -05003
George Keishing97651c72016-10-04 00:44:15 -05004Resource ../lib/rest_client.robot
George Keishingd55a4be2016-08-26 03:28:17 -05005Resource ../lib/openbmc_ffdc.robot
George Keishing7230bbc2016-12-14 07:02:48 -06006Resource ../lib/resource.txt
George Keishing85536662017-03-03 10:49:58 -06007Library Collections
Gunnar Millseac1af22016-11-14 15:30:09 -06008Test Teardown FFDC On Test Case Fail
Chris Austenb29d2e82016-06-07 12:25:35 -05009
Chris Austenb29d2e82016-06-07 12:25:35 -050010*** Variables ***
11
Chris Austenb29d2e82016-06-07 12:25:35 -050012*** Test Cases ***
Chris Austenb29d2e82016-06-07 12:25:35 -050013
George Keishing89f7c1f2017-05-03 16:08:37 -050014REST Login Session To BMC
15 [Documentation] Test REST session log-in.
16 [Tags] REST_Login_Session_To_BMC
17
18 Initialize OpenBMC
19 # Raw GET REST operation to verify session is established.
20 ${resp}= Get Request openbmc /xyz/openbmc_project/
21 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
22
23
24REST Logout Session To BMC
25 [Documentation] Test REST session log-out.
26 [Tags] REST_Logout_Session_To_BMC
27
28 Initialize OpenBMC
29 Log Out OpenBMC
30 # Raw GET REST operation to verify session is logout.
31 ${resp}= Get Request openbmc /xyz/openbmc_project/
32 Should Be Equal As Strings ${resp.status_code} ${HTTP_UNAUTHORIZED}
33
34
George Keishing85536662017-03-03 10:49:58 -060035Get Response Codes
36 [Documentation] REST "Get" response status test.
37 #--------------------------------------------------------------------
38 # Expect status URL Path
39 #--------------------------------------------------------------------
40 ${HTTP_OK} /
41 ${HTTP_OK} /xyz/
42 ${HTTP_OK} /xyz/openbmc_project/
43 ${HTTP_OK} /xyz/openbmc_project/enumerate
44 ${HTTP_NOT_FOUND} /i/dont/exist/
Chris Austenb29d2e82016-06-07 12:25:35 -050045
George Keishing85536662017-03-03 10:49:58 -060046 [Tags] Get_Response_Codes
47 [Template] Execute Get And Check Response
Chris Austenb29d2e82016-06-07 12:25:35 -050048
Chris Austenb29d2e82016-06-07 12:25:35 -050049
George Keishing85536662017-03-03 10:49:58 -060050Get Data
51 [Documentation] REST "Get" request url and expect the
52 ... response OK and data non empty.
53 #--------------------------------------------------------------------
54 # URL Path
55 #--------------------------------------------------------------------
56 /xyz/openbmc_project/
57 /xyz/openbmc_project/list
58 /xyz/openbmc_project/enumerate
Chris Austenb29d2e82016-06-07 12:25:35 -050059
George Keishing85536662017-03-03 10:49:58 -060060 [Tags] Get_Data
61 [Template] Execute Get And Check Data
Chris Austenb29d2e82016-06-07 12:25:35 -050062
Chris Austenb29d2e82016-06-07 12:25:35 -050063
George Keishing85536662017-03-03 10:49:58 -060064Get Data Validation
65 [Documentation] REST "Get" request url and expect the
66 ... pre-defined string in response data.
67 #--------------------------------------------------------------------
68 # URL Path Expect Data
69 #--------------------------------------------------------------------
70 /xyz/openbmc_project/ /xyz/openbmc_project/logging
71 /i/dont/exist/ path or object not found: /i/dont/exist
72
73 [Tags] Get_Data_Validation
74 [Template] Execute Get And Verify Data
75
76
77Put Response Codes
78 [Documentation] REST "Put" request url and expect the REST pre-defined
79 ... codes.
80 #--------------------------------------------------------------------
81 # Expect status URL Path
82 #--------------------------------------------------------------------
83 ${HTTP_METHOD_NOT_ALLOWED} /
84 ${HTTP_METHOD_NOT_ALLOWED} /xyz/
85 ${HTTP_METHOD_NOT_ALLOWED} /i/dont/exist/
86 ${HTTP_METHOD_NOT_ALLOWED} /xyz/list
87 ${HTTP_METHOD_NOT_ALLOWED} /xyz/enumerate
88
89 [Tags] Put_Response_Codes
90 [Template] Execute Put And Check Response
91
92
93Put Data Validation
94 [Documentation] REST "Put" request url and expect success.
95 #--------------------------------------------------------------------
96 # URL Path Parm Data
97 #--------------------------------------------------------------------
98 /xyz/openbmc_project/state/host0/attr/RequestedHostTransition xyz.openbmc_project.State.Host.Transition.Off
99
100 [Tags] Put_Data_Validation
101 [Template] Execute Put And Expect Success
102
103
104Post Response Code
105 [Documentation] REST Post request url and expect the
106 ... REST response code pre define.
107 #--------------------------------------------------------------------
108 # Expect status URL Path
109 #--------------------------------------------------------------------
110 ${HTTP_METHOD_NOT_ALLOWED} /
111 ${HTTP_METHOD_NOT_ALLOWED} /xyz/
112 ${HTTP_METHOD_NOT_ALLOWED} /i/dont/exist/
113 ${HTTP_METHOD_NOT_ALLOWED} /xyz/enumerate
114
115 [Tags] Post_Response_Codes
116 [Template] Execute Post And Check Response
117
118
119Delete Response Code
120 [Documentation] REST "Delete" request url and expect the
121 ... REST response code pre define.
122 #--------------------------------------------------------------------
123 # Expect status URL Path
124 #--------------------------------------------------------------------
125 ${HTTP_METHOD_NOT_ALLOWED} /
126 ${HTTP_METHOD_NOT_ALLOWED} /xyz/
127 ${HTTP_METHOD_NOT_ALLOWED} /xyz/nothere/
128 ${HTTP_METHOD_NOT_ALLOWED} /xyz/enumerate
129 ${HTTP_METHOD_NOT_ALLOWED} /xyz/openbmc_project/list
130 ${HTTP_METHOD_NOT_ALLOWED} /xyz/openbmc_project/enumerate
131
132 [Tags] Delete_Response_Codes
133 [Template] Execute Delete And Check Response
134
Gunnar Mills56b32892016-11-14 13:56:17 -0600135
Gunnar Mills7c8923f2016-12-12 21:19:52 -0600136*** Keywords ***
George Keishing85536662017-03-03 10:49:58 -0600137
138Execute Get And Check Response
139 [Documentation] Request "Get" url path and expect REST response code.
140 [Arguments] ${expected_response_code} ${url_path}
141 # Description of arguments:
142 # expected_response_code Expected REST status codes.
143 # url_path URL path.
144 ${resp}= Openbmc Get Request ${url_path}
145 Should Be Equal As Strings ${resp.status_code} ${expected_response_code}
146
147Execute Get And Check Data
148 [Documentation] Request "Get" url path and expect non empty data.
149 [Arguments] ${url_path}
150 # Description of arguments:
151 # url_path URL path.
152 ${resp}= Openbmc Get Request ${url_path}
153 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
154 ${jsondata}= To JSON ${resp.content}
155 Should Not Be Empty ${jsondata["data"]}
156
157Execute Get And Verify Data
158 [Documentation] Request "Get" url path and verify data.
159 [Arguments] ${url_path} ${expected_response_code}
160 # Description of arguments:
161 # expected_response_code Expected REST status codes.
162 # url_path URL path.
163 ${resp}= Openbmc Get Request ${url_path}
164 ${jsondata}= To JSON ${resp.content}
165 Run Keyword If '${resp.status_code}' == '${HTTP_OK}'
166 ... Should Contain ${jsondata["data"]} ${expected_response_code}
167 ... ELSE
168 ... Should Contain ${jsondata["data"]["description"]} ${expected_response_code}
169
170Execute Put And Check Response
171 [Documentation] Request "Put" url path and expect REST response code.
172 [Arguments] ${expected_response_code} ${url_path}
173 # Description of arguments:
174 # expected_response_code Expected REST status codes.
175 # url_path URL path.
176 ${resp}= Openbmc Put Request ${url_path}
177 Should Be Equal As Strings ${resp.status_code} ${expected_response_code}
178
179Execute Put And Expect Success
180 [Documentation] Request "Put" on url path.
181 [Arguments] ${url_path} ${parm}
182 # Description of arguments:
183 # url_path URL path.
184 # parm Value/string to be set.
185 # expected_response_code Expected REST status codes.
186 ${parmDict}= Create Dictionary data=${parm}
187 ${resp}= Openbmc Put Request ${url_path} data=${parmDict}
188 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
189
190Execute Post And Check Response
191 [Documentation] Request Post url path and expect REST response code.
192 [Arguments] ${expected_response_code} ${url_path}
193 # Description of arguments:
194 # expected_response_code Expected REST status codes.
195 # url_path URL path.
196 ${resp}= Openbmc Post Request ${url_path}
197 Should Be Equal As Strings ${resp.status_code} ${expected_response_code}
198
199Execute Post And Check Data
200 [Arguments] ${url_path} ${parm}
201 [Documentation] Request Post on url path and expected non empty data.
202 # Description of arguments:
203 # url_path URL path.
George Keishing4c02e622017-04-17 07:57:10 -0500204 ${data}= Create Dictionary data=@{parm}
George Keishing85536662017-03-03 10:49:58 -0600205 ${resp}= Openbmc Post Request ${url_path} data=${data}
206 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
207 ${jsondata}= To JSON ${resp.content}
208 Should Not Be Empty ${jsondata["data"]}
209
210Execute Delete And Check Response
211 [Documentation] Request "Delete" url path and expected REST response code.
212 [Arguments] ${expected_response_code} ${url_path}
213 # Description of arguments:
214 # expected_response_code Expected REST status codes.
215 # url_path URL path.
George Keishing4c02e622017-04-17 07:57:10 -0500216 ${data}= Create Dictionary data=@{EMPTY}
217 ${resp}= Openbmc Delete Request ${url_path} data=${data}
George Keishing85536662017-03-03 10:49:58 -0600218 Should Be Equal As Strings ${resp.status_code} ${expected_response_code}