Skip to content

Commit f61b057

Browse files
committed
Added httpbin.org example
1 parent 3ec3f79 commit f61b057

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed

httpbin-api/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# httpbin.org REST API
2+
3+
A simple HTTP Request & Response Service.
4+
5+
## Run
6+
7+
Requirements:
8+
- [ScanAPI](https://pypi.org/project/scanapi/)
9+
10+
```shell
11+
$ git clone [email protected]:scanapi/examples.git
12+
$ cd httpbin-api
13+
$ scanapi run httpbin.yaml
14+
```
15+
16+
The report will be available at `scanapi-report.html`

httpbin-api/httpbin.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
endpoints:
2+
- name: httpbin
3+
path: https://httpbin.org
4+
headers:
5+
Accept: application/json
6+
requests:
7+
- name: get-simple
8+
path: /get
9+
method: get
10+
11+
- name: get-image
12+
path: /image/png
13+
headers:
14+
Accept: image/png
15+
method: get
16+
tests:
17+
- name: status_code_is_200
18+
assert: ${{ response.status_code == 200 }}
19+
- name: content_type_is_png
20+
assert: ${{ response.headers.get("content-type") == "image/png" }}
21+
22+
- name: post-simple
23+
path: /post
24+
method: post
25+
vars:
26+
scanapi_var: scanapi_test1
27+
body:
28+
description: hello scanapi
29+
scanapi_test: ${scanapi_var}
30+
tests:
31+
- name: status_code_is_200
32+
assert: ${{ response.status_code == 200 }}
33+
- name: body_is_ok
34+
assert: ${{ response.json()["json"].get("scanapi_test") == "${scanapi_var}" }}
35+
- name: response_origin
36+
assert: ${{ response.json()["origin"] is not None }}
37+
38+
- name: put-simple
39+
path: /put
40+
method: put
41+
vars:
42+
scanapi_description: hello scanapi again
43+
body:
44+
description: ${scanapi_description}
45+
tests:
46+
- name: status_code_is_200
47+
assert: ${{ response.status_code == 200 }}
48+
- name: description_changed
49+
assert: ${{ response.json()["json"].get("description") == "${scanapi_description}" }}
50+
51+
- name: delete-simple
52+
path: /delete
53+
method: delete
54+
tests:
55+
- name: status_code_is_200
56+
assert: ${{ response.status_code == 200 }}

httpbin-api/scanapi.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
project_name: httpbin.org API

0 commit comments

Comments
 (0)