-
Notifications
You must be signed in to change notification settings - Fork 326
/
content-test.yaml
123 lines (116 loc) · 3.91 KB
/
content-test.yaml
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
# Test parsing and logic around templating
# Using included Django test app
# First install python-django
# Then launch the app in another terminal by doing
# cd testapp
# python manage.py testserver test_data.json
# Once launched, tests can be executed via:
# python resttest.py http://localhost:8000 {this_file_name}
---
- config:
- testset: "Test content/url/header templating & file read"
- variable_binds: {'headername': 'Content-Type', 'headervalue': 'application/json'}
- test:
- name: "Get person, validate that header validator works right"
- url: "/api/person/1/"
- validators:
- assertTrue: {header: content-type, test: exists}
- test:
- name: "Create/update person 7, no template"
- url: "/api/person/7/"
- method: "PUT"
- headers: {template: {'$headername': '$headervalue'}}
- body: '{"first_name": "Gaius","id": "7","last_name": "Romani","login": "gromani"}'
- test:
- name: "Basic get for simple user"
- url: "/api/person/7/"
- test:
- name: "Get single person"
- url: "/api/person/7/"
- method: 'DELETE'
# Test a PUT with an empty body
- test:
- name: "Get single person"
- url: "/api/person/9999/"
- method: 'PUT'
- expected_status: [400, 404, 500]
- test: # Inline body, template URL and body
- name: "Create/update person 8 with templating"
- variable_binds: {id: 8, login: traitor}
- url: {"template":"/api/person/$id/"}
- method: "PUT"
- headers: {'Content-Type': 'application/json'}
- body: {template: '{"first_name": "Gaius","id": "$id","last_name": "Baltar","login": "$login"}'}
- test:
- name: "Basic get with templating"
- url: {template: "/api/person/$id/"}
- test:
- name: "Delete single person with templating"
- url: {template: "/api/person/$id/"}
- method: 'DELETE'
- test:
- name: "Templated get to confirm deletion"
- url: {template: "/api/person/8/"}
- expected_status: [404]
# Body from file with templating for file content
- test:
- name: "Create/update person 9 using templated body from file"
- variable_binds: {id: 9, login: 'horseyface'}
- url: {'template': "/api/person/$id/"}
- method: "PUT"
- headers: {'Content-Type': 'application/json'}
- body: {'template':{'file':'person_body_template.json'}}
- test:
- name: "Confirm person 9 create"
- url: "/api/person/9/"
- test:
- name: "Cleanup person 9"
- url: "/api/person/9/"
- method: 'DELETE'
# Body from file testing, no actual templating, one no-op templating on URL
- test:
- name: "Create/update person 10 using body from file"
- url: "/api/person/10/"
- method: "PUT"
- headers: {'Content-Type': 'application/json'}
- body: {'file':'person_body_notemplate.json'}
- test:
- name: "Confirm person 10 create"
- url: {template: "/api/person/10/"}
- test:
- name: "Cleanup person 10"
- url: "/api/person/10/"
- method: 'DELETE'
# Template body path, but not body itself
- test:
- name: "Create/update person 10 using templating for body path"
- variable_binds: {'path':'person_body_notemplate.json'}
- url: "/api/person/10/"
- method: "PUT"
- headers: {'Content-Type': 'application/json'}
- body: {'file':{'template':'$path'}}
- test:
- name: "Confirm person 10 create"
- url: "/api/person/10/"
- test:
- name: "Cleanup person 10"
- url: "/api/person/10/"
- method: 'DELETE'
# Template both request content and its path
- test:
- name: "Create/update person 12 using templating for body path"
- variable_binds:
- 'path': 'person_body_template.json'
- id: 12
- login: 'random'
- url: "/api/person/12/"
- method: "PUT"
- headers: {'Content-Type': 'application/json'}
- body: {template: {'file':{'template':'$path'}}}
- test:
- name: "Confirm person 12 create"
- url: "/api/person/12/"
- test:
- name: "Cleanup person 12"
- url: "/api/person/12/"
- method: 'DELETE'