-
Notifications
You must be signed in to change notification settings - Fork 78
337 lines (306 loc) · 12 KB
/
it-tests.yml
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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
on:
pull_request:
push:
branches: [main]
jobs:
test-method-get-on-existing-url:
name: "IT Test - Request Postman Echo GET"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Given the gh-action is used with GET and a valid URL
id: execution
uses: ./
with:
url: 'https://postman-echo.com/get'
method: 'GET'
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 200
with:
expected: '200'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
test-method-post-on-existing-url:
name: "IT Test - Request Postman Echo POST"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Given the gh-action is used with POST using valid data
id: execution
uses: ./
with:
url: "https://postman-echo.com/post"
method: 'POST'
data: '{ "key": "value" }'
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 200
with:
expected: '200'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
test-method-post-on-existing-url-with-unescaped-newline:
name: "IT Test - Request Postman Echo POST with Unescaped Newline"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Given the gh-action is used with POST using unescaped new line within data
id: execution
uses: ./
with:
url: "https://postman-echo.com/post"
method: 'POST'
escapeData: 'true'
data: >-
{
"key":"multi line\ntest
text"
}
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 200
with:
expected: '200'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
test-basic-auth:
name: "IT Test - Request Postman Echo BasicAuth"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Given the gh-action is used with valid BasicAuth parameters
id: execution
uses: ./
with:
url: 'https://postman-echo.com/basic-auth'
method: 'GET'
username: 'postman'
password: 'password'
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 200 as this URL exists
with:
expected: '200'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
test-input-ignore-failure-code-404:
name: "IT Test - Request Postman Echo with 404 Response and ignore failure code"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Given the gh-action is used with unknown URL and ignoreStatusCode 404 for it
id: execution
uses: ./
with:
url: 'https://postman-echo.com/status/404'
method: 'GET'
ignoreStatusCodes: '404'
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must 404
with:
expected: '404'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then the outcome value must be success as the error 404 is ignored
with:
expected: 'success'
actual: ${{ steps.execution.outcome }}
comparison: exact
test-input-ignore-failure-multiple-codes-401-404:
name: "IT Test - Request Postman Echo with 404 Response and ignore failure code"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Given the gh-action is used with unknown URL and ignore status codes 401,404
id: execution
uses: ./
with:
url: 'https://postman-echo.com/status/404'
method: 'GET'
ignoreStatusCodes: '401,404'
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 404
with:
expected: '404'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then the outcome value must be success as the error 404 is ignored
with:
expected: 'success'
actual: ${{ steps.execution.outcome }}
comparison: exact
test-input-files:
name: "IT Test - Request Postman Echo POST Multipart"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Create Test File
run: |
echo "test" > testfile.txt
- name: Given the gh-action is used with file and data
id: execution
uses: ./
with:
url: 'https://postman-echo.com/post'
method: 'POST'
data: '{ "key": "value" }'
files: '{ "file": "${{ github.workspace }}/testfile.txt" }'
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 200
with:
expected: '200'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
test-input-responseFile:
name: "IT Test - Request Postman Echo POST and persist response"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Create Test File
run: |
echo "test" > testfile2.txt
- name: Given the gh-action is used with file and responseFile
id: execution
uses: ./
with:
url: 'https://postman-echo.com/post'
method: 'POST'
file: "${{ github.workspace }}/testfile2.txt"
responseFile: "${{ github.workspace }}/response.json"
- name: Output responseFile
id: execution-response-file
run: |
echo "response_content=$(cat ${{ github.workspace }}/response.json)" >> $GITHUB_OUTPUT
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.response_content value must include
with:
expected: '{"args":{},"data":"test\n","files":{},"form":{},"headers":{"host":"postman-echo.com",'
actual: ${{ steps.execution-response-file.outputs.response_content }}
comparison: contains
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.response_content value must include
with:
expected: '"accept":"application/json, text/plain, */*","content-type":"application/json","user-agent"'
actual: ${{ steps.execution-response-file.outputs.response_content }}
comparison: contains
test-input-files-without-data:
name: "IT Test - Request Postman Echo POST Multipart without data"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Create Test File
run: |
echo "test" > testfile3.txt
- name: Given the gh-action is used with file
id: execution
uses: ./
with:
url: 'https://postman-echo.com/post'
method: 'POST'
files: '{ "file": "${{ github.workspace }}/testfile3.txt" }'
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 200
with:
expected: '200'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
test-input-file-with-single-file:
name: "IT Test - Request Postman Echo POST single file"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Create Test File
run: |
echo "test" > testfile4.txt
- name: Given the gh-action is used with file
id: execution
uses: ./
with:
url: 'https://postman-echo.com/post'
method: 'POST'
file: "${{ github.workspace }}/testfile4.txt"
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 200
with:
expected: '200'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
test-input-data-with-url-encoded-string:
name: "IT Test - Request Postman Echo POST URLEncoded string data"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Given the gh-action is used with data form url encoded
id: execution
uses: ./
with:
url: 'https://postman-echo.com/post'
contentType : 'application/x-www-form-urlencoded'
method: 'POST'
data: 'key=value'
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 200
with:
expected: '200'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
test-input-data-with-url-encoded-json-data:
name: "IT Test - Request Postman Echo POST URLEncoded json data"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Given the gh-action is used with json data
id: execution
uses: ./
with:
url: 'https://postman-echo.com/post'
contentType : 'application/x-www-form-urlencoded'
method: 'POST'
data: '{"key":"value"}'
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 200
with:
expected: '200'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
test-delete-http-method:
name: "IT Test - Request Postman Echo DELETE"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Given the gh-action is used with method DELETE
id: execution
uses: ./
with:
url: 'https://postman-echo.com/delete'
contentType : 'application/json'
method: 'DELETE'
data: '{"key":"value"}'
- uses: nick-fields/assert-action@aa0067e01f0f6545c31755d6ca128c5a3a14f6bf # v2
name: Then outputs.status value must be 200
with:
expected: '200'
actual: ${{ steps.execution.outputs.status }}
comparison: exact
it-tests:
name: "All IT Tests have to pass"
runs-on: ubuntu-latest
if: always()
needs:
# Add your tests here so that they prevent the merge of broken changes
- test-method-get-on-existing-url
- test-method-post-on-existing-url
- test-method-post-on-existing-url-with-unescaped-newline
- test-basic-auth
- test-input-ignore-failure-code-404
- test-input-ignore-failure-multiple-codes-401-404
- test-input-files
- test-input-responseFile
- test-input-files-without-data
- test-input-file-with-single-file
- test-input-data-with-url-encoded-string
- test-input-data-with-url-encoded-json-data
- test-delete-http-method
steps:
- uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2
with:
jobs: ${{ toJSON(needs) }}