-
Notifications
You must be signed in to change notification settings - Fork 288
Expand file tree
/
Copy pathtest_requests_on_session.robot
More file actions
282 lines (234 loc) · 11.1 KB
/
test_requests_on_session.robot
File metadata and controls
282 lines (234 loc) · 11.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
*** Settings ***
Library Collections
Library String
Library RequestsLibrary
*** Test Cases ***
Get Request On Existing Session
[Tags] get
${resp}= GET On Session ${GLOBAL_SESSION} /anything
Status Should Be OK ${resp}
Get Request Should Have Get Method
[Tags] get
${resp}= GET On Session ${GLOBAL_SESSION} /anything
Should Be Equal As Strings ${resp.json()}[method] GET
Get Request With Url Params As Dictionary
[Tags] get
${params}= Create Dictionary param1=1 param2=2
${resp}= GET On Session ${GLOBAL_SESSION} /anything ${params}
Status Should Be OK ${resp}
Dictionaries Should Be Equal ${params} ${resp.json()}[args]
Get Request With Url Params As Kwargs String
[Tags] get
${params}= Create Dictionary this_is_a_string=1 p2=2
${resp}= GET On Session ${GLOBAL_SESSION} /anything
... params=this_is_a_string=1&p2=2
Status Should Be OK ${resp}
Dictionaries Should Be Equal ${params} ${resp.json()}[args]
Get Request With Url Params As Escaped String
[Tags] get
${params}= Create Dictionary this_is_a_string=1 p2=2
${resp}= GET On Session ${GLOBAL_SESSION} /anything
... this_is_a_string\=1&p2\=2
Status Should Be OK ${resp}
Dictionaries Should Be Equal ${params} ${resp.json()}[args]
Get Request With Url Duplicated Keys In Params
[Tags] get
${array}= Create List 1 2
${resp}= GET On Session ${GLOBAL_SESSION} /anything
... params=key=1&key=2
Status Should Be OK ${resp}
Lists Should Be Equal ${array} ${resp.json()}[args][key]
Get Request With Url Duplicated Keys In Params And PHP Style Array
[Tags] get
${array}= Create List 1 2
${resp}= GET On Session ${GLOBAL_SESSION} /anything
... params=key[]=1&key[]=2
Status Should Be OK ${resp}
Lists Should Be Equal ${array} ${resp.json()}[args][key[]]
Get Request With Url Params As PHP Style Array
[Tags] get
${resp}= GET On Session ${GLOBAL_SESSION} /anything
... params=key[]=1,2
Status Should Be OK ${resp}
Should Be Equal As Strings 1,2 ${resp.json()}[args][key[]]
Get Request With Url Params As Array
[Tags] get
${resp}= GET On Session ${GLOBAL_SESSION} /anything
... params=key=[1,2]
Status Should Be OK ${resp}
Should Be Equal As Strings [1,2] ${resp.json()}[args][key]
Get Request With Unordered Parameters
[Tags] get
${params}= Create Dictionary param1=1 param2=2
${resp}= GET On Session params=${params} alias=${GLOBAL_SESSION}
... url=/anything data=data expected_status=200
Status Should Be OK ${resp}
Dictionaries Should Be Equal ${params} ${resp.json()}[args]
Should Be Equal As Strings data ${resp.json()}[data]
Get Request And Fail By Default On Http Error
[Tags] get
Run Keyword And Expect Error HTTPError: 400*
... GET On Session ${GLOBAL_SESSION} /status/400
Get Request And Fail By Expecting A 200 Status
[Tags] get
Run Keyword And Expect Error Url: ${HTTP_LOCAL_SERVER}/status/404?param Expected status: 200 != 404
... GET On Session ${GLOBAL_SESSION} /status/404 param 200
Get Request And Fail By Expecting A 200 Status With A Message
[Tags] get
Run Keyword And Expect Error Custom msg Url: ${HTTP_LOCAL_SERVER}/status/404?param Expected status: 200 != 404
... GET On Session ${GLOBAL_SESSION} /status/404 param 200 Custom msg
Get Request Expect An Error And Evaluate Response
[Tags] get
${resp}= GET On Session ${GLOBAL_SESSION} /status/401 expected_status=401
Should Be Equal As Strings UNAUTHORIZED ${resp.reason}
Get Request Expect Any Status And Continue On Error
[Tags] get
${resp}= GET On Session ${GLOBAL_SESSION} /status/404 expected_status=ANY
Should Be Equal As Strings NOT FOUND ${resp.reason}
Get Request Expect Anything Status And Continue On Error
[Tags] get
${resp}= GET On Session ${GLOBAL_SESSION} /status/404 expected_status=Anything
Should Be Equal As Strings NOT FOUND ${resp.reason}
Post Request On Existing Session
[Tags] post
${resp}= POST On Session ${GLOBAL_SESSION} /anything
Status Should Be OK ${resp}
Post Request Should Have Post Method
[Tags] post
${resp}= POST On Session ${GLOBAL_SESSION} /anything
Should Be Equal As Strings ${resp.json()}[method] POST
Post Request With Data
[Tags] post
${resp}= POST On Session ${GLOBAL_SESSION} /anything string
Status Should Be OK ${resp}
Should Be Equal As Strings ${resp.json()}[data] string
Post Request With Json
[Tags] post
${body}= Create Dictionary a=1 b=2
${resp}= POST On Session ${GLOBAL_SESSION} /anything json=${body}
Status Should Be OK ${resp}
${data}= Evaluate ${resp.json()}[data]
Dictionaries Should Be Equal ${data} ${body}
Post Request Expect An Error And Evaluate Response
[Tags] post
${resp}= POST On Session ${GLOBAL_SESSION} /status/401 expected_status=401
Should Be Equal As Strings UNAUTHORIZED ${resp.reason}
Post Request Expect Anything Status And Continue On Error
[Tags] post
${resp}= POST On Session ${GLOBAL_SESSION} /status/400 expected_status=anything
Should Be Equal As Strings BAD REQUEST ${resp.reason}
Put Request On Existing Session
[Tags] put
${resp}= PUT On Session ${GLOBAL_SESSION} /anything
Status Should Be OK ${resp}
Put Request Should Have Put Method
[Tags] put
${resp}= PUT On Session ${GLOBAL_SESSION} /anything
Should Be Equal As Strings ${resp.json()}[method] PUT
Put Request With Data
[Tags] put
${resp}= PUT On Session ${GLOBAL_SESSION} /anything string
Status Should Be OK ${resp}
Should Be Equal As Strings ${resp.json()}[data] string
Put Request With Json
[Tags] put
${body}= Create Dictionary a=1 b=2
${resp}= PUT On Session ${GLOBAL_SESSION} /anything json=${body}
Status Should Be OK ${resp}
Dictionaries Should Be Equal ${resp.json()}[json] ${body}
Put Request Expect An Error And Evaluate Response
[Tags] put
${resp}= PUT On Session ${GLOBAL_SESSION} /status/401 expected_status=401
Should Be Equal As Strings UNAUTHORIZED ${resp.reason}
Head Request On Existing Session
[Tags] head
${resp}= HEAD On Session ${GLOBAL_SESSION} /anything
Status Should Be OK ${resp}
Head Request Should Not Have A Body
[Tags] head
${resp}= HEAD On Session ${GLOBAL_SESSION} /anything
Should Be Equal As Strings ${resp.content} ${Empty}
Head Request With Kwargs Params
[Tags] head
${params}= Create Dictionary param1=1 param2=2
${resp}= HEAD On Session ${GLOBAL_SESSION} /anything params=${params}
Status Should Be OK ${resp}
Head Request With Header
[Tags] head
${accept_type}= Set Variable application/json
${headers}= Create Dictionary Accept ${accept_type}
${resp}= HEAD On Session ${GLOBAL_SESSION} /anything headers=${headers}
Status Should Be OK ${resp}
${content_type_response}= Get From Dictionary ${resp.headers} Content-Type
Should Be Equal ${accept_type} ${content_type_response}
Head Request And Fail By Default On Http Error
[Tags] head
Run Keyword And Expect Error HTTPError: 400*
... HEAD On Session ${GLOBAL_SESSION} /status/400
Head Request Expect An Error And Evaluate Response
[Tags] head
${resp}= HEAD On Session ${GLOBAL_SESSION} /status/401 expected_status=401
Should Be Equal As Strings UNAUTHORIZED ${resp.reason}
Patch Request On Existing Session
[Tags] patch
${resp}= PATCH On Session ${GLOBAL_SESSION} /anything
Status Should Be OK ${resp}
Patch Request Should Have Patch Method
[Tags] patch
${resp}= PATCH On Session ${GLOBAL_SESSION} /anything
Should Be Equal As Strings ${resp.json()}[method] PATCH
Patch Request With Data
[Tags] patch
${resp}= PATCH On Session ${GLOBAL_SESSION} /anything string
Status Should Be OK ${resp}
Should Be Equal As Strings ${resp.json()}[data] string
Patch Request With Json
[Tags] patch
${body}= Create Dictionary a=1 b=2
${resp}= PATCH On Session ${GLOBAL_SESSION} /anything json=${body}
Status Should Be OK ${resp}
Dictionaries Should Be Equal ${resp.json()}[json] ${body}
Patch Request Expect An Error And Evaluate Response
[Tags] patch
${resp}= PATCH On Session ${GLOBAL_SESSION} /status/401 expected_status=401
Should Be Equal As Strings UNAUTHORIZED ${resp.reason}
Delete Request On Existing Session
[Tags] delete
${resp}= DELETE On Session ${GLOBAL_SESSION} /anything
Status Should Be OK ${resp}
Delete Request Should Have Delete Method
[Tags] delete
${resp}= DELETE On Session ${GLOBAL_SESSION} /anything
Should Be Equal As Strings ${resp.json()}[method] DELETE
Delete Request Expect An Error And Evaluate Response
[Tags] delete
${resp}= DELETE On Session ${GLOBAL_SESSION} /status/202 expected_status=202
Should Be Equal As Strings ACCEPTED ${resp.reason}
Options Request On Existing Session
[Tags] options
${resp}= OPTIONS On Session ${GLOBAL_SESSION} /anything
Status Should Be OK ${resp}
Options Request Check Allow Header
[Tags] options
${allow_header}= Create List POST HEAD PATCH GET TRACE DELETE OPTIONS PUT CONNECT
${resp}= OPTIONS On Session ${GLOBAL_SESSION} /anything
Status Should Be OK ${resp}
${allow_response_header}= Get From Dictionary ${resp.headers} Allow
${allow_response_header}= Split String ${allow_response_header} ,${SPACE}
Lists Should Be Equal ${allow_header} ${allow_response_header} ignore_order=True
Options Request And Bad Request Not Fail
[Tags] options
${resp}= OPTIONS On Session ${GLOBAL_SESSION} /status/400
Status Should Be OK ${resp}
Options Request Expect A Success On Unauthorized Request
[Tags] options
${resp}= OPTIONS On Session ${GLOBAL_SESSION} /status/401 expected_status=200
Status Should Be OK ${resp}
Connect Request On Existing Session
[Tags] connect
${resp}= CONNECT On Session ${GLOBAL_SESSION} /anything
Status Should Be OK ${resp}
Trace Request On Existing Session
[Tags] trace
${resp}= TRACE On Session ${GLOBAL_SESSION} /anything
Status Should Be OK ${resp}