blob: 9c9d919f38e8c364b19279c81b25e1bb63ce4993 [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 Keishing85536662017-03-03 10:49:58 -060014Get Response Codes
15 [Documentation] REST "Get" response status test.
16 #--------------------------------------------------------------------
17 # Expect status URL Path
18 #--------------------------------------------------------------------
19 ${HTTP_OK} /
20 ${HTTP_OK} /xyz/
21 ${HTTP_OK} /xyz/openbmc_project/
22 ${HTTP_OK} /xyz/openbmc_project/enumerate
23 ${HTTP_NOT_FOUND} /i/dont/exist/
Chris Austenb29d2e82016-06-07 12:25:35 -050024
George Keishing85536662017-03-03 10:49:58 -060025 [Tags] Get_Response_Codes
26 [Template] Execute Get And Check Response
Chris Austenb29d2e82016-06-07 12:25:35 -050027
Chris Austenb29d2e82016-06-07 12:25:35 -050028
George Keishing85536662017-03-03 10:49:58 -060029Get Data
30 [Documentation] REST "Get" request url and expect the
31 ... response OK and data non empty.
32 #--------------------------------------------------------------------
33 # URL Path
34 #--------------------------------------------------------------------
35 /xyz/openbmc_project/
36 /xyz/openbmc_project/list
37 /xyz/openbmc_project/enumerate
Chris Austenb29d2e82016-06-07 12:25:35 -050038
George Keishing85536662017-03-03 10:49:58 -060039 [Tags] Get_Data
40 [Template] Execute Get And Check Data
Chris Austenb29d2e82016-06-07 12:25:35 -050041
Chris Austenb29d2e82016-06-07 12:25:35 -050042
George Keishing85536662017-03-03 10:49:58 -060043Get Data Validation
44 [Documentation] REST "Get" request url and expect the
45 ... pre-defined string in response data.
46 #--------------------------------------------------------------------
47 # URL Path Expect Data
48 #--------------------------------------------------------------------
49 /xyz/openbmc_project/ /xyz/openbmc_project/logging
50 /i/dont/exist/ path or object not found: /i/dont/exist
51
52 [Tags] Get_Data_Validation
53 [Template] Execute Get And Verify Data
54
55
56Put Response Codes
57 [Documentation] REST "Put" request url and expect the REST pre-defined
58 ... codes.
59 #--------------------------------------------------------------------
60 # Expect status URL Path
61 #--------------------------------------------------------------------
62 ${HTTP_METHOD_NOT_ALLOWED} /
63 ${HTTP_METHOD_NOT_ALLOWED} /xyz/
64 ${HTTP_METHOD_NOT_ALLOWED} /i/dont/exist/
65 ${HTTP_METHOD_NOT_ALLOWED} /xyz/list
66 ${HTTP_METHOD_NOT_ALLOWED} /xyz/enumerate
67
68 [Tags] Put_Response_Codes
69 [Template] Execute Put And Check Response
70
71
72Put Data Validation
73 [Documentation] REST "Put" request url and expect success.
74 #--------------------------------------------------------------------
75 # URL Path Parm Data
76 #--------------------------------------------------------------------
77 /xyz/openbmc_project/state/host0/attr/RequestedHostTransition xyz.openbmc_project.State.Host.Transition.Off
78
79 [Tags] Put_Data_Validation
80 [Template] Execute Put And Expect Success
81
82
83Post Response Code
84 [Documentation] REST Post request url and expect the
85 ... REST response code pre define.
86 #--------------------------------------------------------------------
87 # Expect status URL Path
88 #--------------------------------------------------------------------
89 ${HTTP_METHOD_NOT_ALLOWED} /
90 ${HTTP_METHOD_NOT_ALLOWED} /xyz/
91 ${HTTP_METHOD_NOT_ALLOWED} /i/dont/exist/
92 ${HTTP_METHOD_NOT_ALLOWED} /xyz/enumerate
93
94 [Tags] Post_Response_Codes
95 [Template] Execute Post And Check Response
96
97
98Delete Response Code
99 [Documentation] REST "Delete" request url and expect the
100 ... REST response code pre define.
101 #--------------------------------------------------------------------
102 # Expect status URL Path
103 #--------------------------------------------------------------------
104 ${HTTP_METHOD_NOT_ALLOWED} /
105 ${HTTP_METHOD_NOT_ALLOWED} /xyz/
106 ${HTTP_METHOD_NOT_ALLOWED} /xyz/nothere/
107 ${HTTP_METHOD_NOT_ALLOWED} /xyz/enumerate
108 ${HTTP_METHOD_NOT_ALLOWED} /xyz/openbmc_project/list
109 ${HTTP_METHOD_NOT_ALLOWED} /xyz/openbmc_project/enumerate
110
111 [Tags] Delete_Response_Codes
112 [Template] Execute Delete And Check Response
113
Gunnar Mills56b32892016-11-14 13:56:17 -0600114
Gunnar Mills7c8923f2016-12-12 21:19:52 -0600115*** Keywords ***
George Keishing85536662017-03-03 10:49:58 -0600116
117Execute Get And Check Response
118 [Documentation] Request "Get" url path and expect REST response code.
119 [Arguments] ${expected_response_code} ${url_path}
120 # Description of arguments:
121 # expected_response_code Expected REST status codes.
122 # url_path URL path.
123 ${resp}= Openbmc Get Request ${url_path}
124 Should Be Equal As Strings ${resp.status_code} ${expected_response_code}
125
126Execute Get And Check Data
127 [Documentation] Request "Get" url path and expect non empty data.
128 [Arguments] ${url_path}
129 # Description of arguments:
130 # url_path URL path.
131 ${resp}= Openbmc Get Request ${url_path}
132 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
133 ${jsondata}= To JSON ${resp.content}
134 Should Not Be Empty ${jsondata["data"]}
135
136Execute Get And Verify Data
137 [Documentation] Request "Get" url path and verify data.
138 [Arguments] ${url_path} ${expected_response_code}
139 # Description of arguments:
140 # expected_response_code Expected REST status codes.
141 # url_path URL path.
142 ${resp}= Openbmc Get Request ${url_path}
143 ${jsondata}= To JSON ${resp.content}
144 Run Keyword If '${resp.status_code}' == '${HTTP_OK}'
145 ... Should Contain ${jsondata["data"]} ${expected_response_code}
146 ... ELSE
147 ... Should Contain ${jsondata["data"]["description"]} ${expected_response_code}
148
149Execute Put And Check Response
150 [Documentation] Request "Put" url path and expect REST response code.
151 [Arguments] ${expected_response_code} ${url_path}
152 # Description of arguments:
153 # expected_response_code Expected REST status codes.
154 # url_path URL path.
155 ${resp}= Openbmc Put Request ${url_path}
156 Should Be Equal As Strings ${resp.status_code} ${expected_response_code}
157
158Execute Put And Expect Success
159 [Documentation] Request "Put" on url path.
160 [Arguments] ${url_path} ${parm}
161 # Description of arguments:
162 # url_path URL path.
163 # parm Value/string to be set.
164 # expected_response_code Expected REST status codes.
165 ${parmDict}= Create Dictionary data=${parm}
166 ${resp}= Openbmc Put Request ${url_path} data=${parmDict}
167 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
168
169Execute Post And Check Response
170 [Documentation] Request Post url path and expect REST response code.
171 [Arguments] ${expected_response_code} ${url_path}
172 # Description of arguments:
173 # expected_response_code Expected REST status codes.
174 # url_path URL path.
175 ${resp}= Openbmc Post Request ${url_path}
176 Should Be Equal As Strings ${resp.status_code} ${expected_response_code}
177
178Execute Post And Check Data
179 [Arguments] ${url_path} ${parm}
180 [Documentation] Request Post on url path and expected non empty data.
181 # Description of arguments:
182 # url_path URL path.
183 ${data}= Create Dictionary data=@{data}
184 ${resp}= Openbmc Post Request ${url_path} data=${data}
185 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
186 ${jsondata}= To JSON ${resp.content}
187 Should Not Be Empty ${jsondata["data"]}
188
189Execute Delete And Check Response
190 [Documentation] Request "Delete" url path and expected REST response code.
191 [Arguments] ${expected_response_code} ${url_path}
192 # Description of arguments:
193 # expected_response_code Expected REST status codes.
194 # url_path URL path.
195 ${resp}= Openbmc Delete Request ${url_path}
196 Should Be Equal As Strings ${resp.status_code} ${expected_response_code}