-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIntegration Testing.postman_collection.json
More file actions
167 lines (167 loc) · 5.59 KB
/
Integration Testing.postman_collection.json
File metadata and controls
167 lines (167 loc) · 5.59 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
{
"info": {
"_postman_id": "c7e742c0-97fc-4017-b5a4-61381df021f3",
"name": "Integration Testing",
"description": "# About this collection\n\nPostman allows you to test your APIs using simple Javascript code. You can evaluate your response body, headers, cookies, and more using the [ChaiJS BDD](https://www.chaijs.com/api/bdd/) syntax.\n\nThis collection guides you through the process of setting up an integration test to ensure that all individual components of an API function together seamlessly.\n\nThe API under test in this collection includes three endpoints for registering and receiving a token, accessing your unique generated name, and unregistering a token:\n\n- POST `/register`\n- POST `/unregister`\n- GET `/my-name`\n \n\nBy setting up requests in the order of the operation, we can test the flow of data to and from the endpoints and ensure they work together as expected. We also verify that the data persists between requests on the back end.\n\n## **Using this collection**\n\n**Step 1:** Check out the requests' documentation to learn more about -\n\n- what each request is meant to do.\n- the tests we've added against each one.\n \n\n**Step 2:** Run this collection by clicking on \"Run\".\n\n<img src=\"https://content.pstmn.io/84019b0f-69c8-4c5f-98b9-2c90a6f9a0b1/Y29sbGVjdGlvbi1ydW5uZXItYnV0dG9uLmpwZWc=\" width=\"266\" height=\"103\">\n\n**Step 3:** To customize this collection, replace the request URLs with your API endpoints and add or edit the tests if needed.\n\n## Resources\n\n[Scripting in Postman](https://learning.postman.com/docs/writing-scripts/intro-to-scripts/)\n\n[Test script examples](https://learning.postman.com/docs/writing-scripts/script-references/test-examples/)\n\n[Postman Sandbox API reference](https://learning.postman.com/docs/sending-requests/grpc/postman-sandbox-api/#writing-assertions)\n\n[Using the Collection Runner](https://learning.postman.com/docs/collections/running-collections/intro-to-collection-runs/)",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "27860752"
},
"item": [
{
"name": "Register",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"An access token is returned\", () => {",
" pm.expect(pm.response.json()).to.have.property('token')",
" pm.expect(pm.response.json().token).to.be.a('string')",
" // Set the collection-scope \"token\" variable to the token received from the API",
" // This lets us use it in other requests",
" pm.collectionVariables.set('token', pm.response.json().token)",
"})",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"url": {
"raw": "{{baseUrl}}/register",
"host": [
"{{baseUrl}}"
],
"path": [
"register"
]
},
"description": "This returns a `token` that you can use to retrieve information later on.\n\nWe have included a test to confirm if a token is returned. We have also added test scripts to copy the token to the `token` collection variable. This makes it easy for us to reuse this token in other requests in the collection."
},
"response": []
},
{
"name": "Get name",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"A name is returned\", () => {",
" pm.expect(pm.response.json()).to.have.property('name');",
" pm.expect(pm.response.json().name).to.be.a('string');",
"})"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": "",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/my-name?token={{token}}",
"host": [
"{{baseUrl}}"
],
"path": [
"my-name"
],
"query": [
{
"key": "token",
"value": "{{token}}"
}
]
},
"description": "This request uses the saved `token` collection variable to access a secret 'name' stored against that token.\n\nIn this request, we used the `token` collection variable as a query param to fetch the name generated for that token. We have added a test to check that a name is correctly returned."
},
"response": []
},
{
"name": "Unregister",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Returns 200 OK status\", () => {",
" pm.response.to.have.status(200)",
"})"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"token\": \"{{token}}\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/unregister",
"host": [
"{{baseUrl}}"
],
"path": [
"unregister"
]
},
"description": "This request un-registers a token by using the token collection variable in the POST body.\n\nWe also added a test to ensure the response has a 200 OK status code."
},
"response": []
}
],
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
}
],
"variable": [
{
"key": "token",
"value": ""
},
{
"key": "baseUrl",
"value": "https://postman-integration-testing.glitch.me/"
}
]
}