Skip to content

Commit 4c13fc2

Browse files
committed
ci: add automated postman contract testing with newman
1 parent f200fa6 commit 4c13fc2

2 files changed

Lines changed: 316 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: "API Contract: Postman Validation"
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
# También puedes activarlo manualmente desde GitHub
7+
workflow_dispatch:
8+
9+
jobs:
10+
postman-tests:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout Code
14+
uses: actions/checkout@v4
15+
16+
- name: Install Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: '20'
20+
21+
- name: Install Newman
22+
run: npm install -g newman
23+
24+
- name: Run Postman Collection
25+
run: |
26+
newman run email-api/auth-mailer.json \
27+
--reporters cli \
28+
--env-var "baseUrl=https://auth-mailer-api.onrender.com"

email-api/auth-mailer.json

Lines changed: 288 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,288 @@
1+
{
2+
"info": {
3+
"_postman_id": "89b60f1b-5101-40d8-82fa-027d917e66f3",
4+
"name": "Auth-Mailer-API",
5+
"description": "# 📑 Auth-Mailer-API – Postman Documentation\n\nAuth-Mailer-API is a RESTful service that provides **user authentication** and **email sending capabilities**. This documentation is designed for Postman to help developers test, explore, and integrate the API quickly.\n\n## 🔑 Authentication\n\n- **Type:** JWT (JSON Web Token)\n \n- CódigoAuthorization: Bearer\n \n\n## 📬 Base URL\n\nCódigo\n\n```\nhttps://auth-mailer-api.onrender.com\n\n ```\n\n## ⚠️ Error Responses\n\n- **400 Bad Request:** Missing or invalid parameters.\n \n- **401 Unauthorized:** Invalid or missing token.\n \n- **404 Not Found:** Resource not found.\n \n- **500 Internal Server Error:** Unexpected server issue.\n \n\n## 🛠️ Postman Setup\n\n1. Import this collection into Postman.\n \n2. Set the **Base URL** as an environment variable (`{{base_url}}`).\n \n3. Add an **Authorization** header with your JWT token.\n \n4. Test endpoints individually or chain them in workflows.",
6+
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
7+
"_exporter_id": "48309056",
8+
"_collection_link": "https://go.postman.co/collection/48309056-89b60f1b-5101-40d8-82fa-027d917e66f3?source=collection_link"
9+
},
10+
"item": [
11+
{
12+
"name": "Users",
13+
"item": [
14+
{
15+
"name": "Get All Users",
16+
"request": {
17+
"method": "GET",
18+
"header": [
19+
{
20+
"key": "Authorization",
21+
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjoxMiwiZW1haWwiOiJjbGlvYW5haGlAZ21haWwuY29tIiwiZmlyc3ROYW1lIjoiQ2xpbyIsImxhc3ROYW1lIjoiU2FsZ2FkbyIsImNvdW50cnkiOiJNZXhpY28iLCJpbWFnZSI6Imh0dHBzOi8veHNnYW1lcy5jby9yYW5kb211c2Vycy9hc3NldHMvYXZhdGFycy9mZW1hbGUvMTQuanBnIiwiaXNWZXJpZmllZCI6dHJ1ZSwiY3JlYXRlZEF0IjoiMjAyNS0xMi0wOVQyMTo0MzoxNC41NjBaIiwidXBkYXRlZEF0IjoiMjAyNS0xMi0wOVQyMTo0NTozNS40NDJaIn0sImlhdCI6MTc3Mzg2ODIzNywiZXhwIjoxNzczOTU0NjM3fQ._hiSuc4zyg8FFEugbzzP8sADKARpyFdqnf7U51D5raY",
22+
"type": "text"
23+
}
24+
],
25+
"url": {
26+
"raw": "{{BASE_URL}}/users",
27+
"host": [
28+
"{{BASE_URL}}"
29+
],
30+
"path": [
31+
"users"
32+
]
33+
},
34+
"description": "**Description:** Retrieves a list of all registered users.\n\n**Correct Response:**\n\n``` json\n[\n {\n \"id\": 6,\n \"email\": \"clioanahisalgado@gmail.com\",\n \"firstName\": \"Anahi\",\n \"lastName\": \"Aguayo\",\n \"country\": \"Mexico\",\n \"image\": \"https://xsgames.co/randomusers/assets/avatars/female/14.jpg\",\n \"isVerified\": true,\n \"createdAt\": \"2025-12-09T01:41:39.255Z\",\n \"updatedAt\": \"2025-12-09T19:57:22.649Z\"\n }\n]\n\n ```"
35+
},
36+
"response": []
37+
},
38+
{
39+
"name": "Create User",
40+
"request": {
41+
"method": "POST",
42+
"header": [],
43+
"body": {
44+
"mode": "raw",
45+
"raw": "{\r\n \"email\": \"clioanahi@gmail1.com\",\r\n \"password\": \"123456\",\r\n \"firstName\": \"Clio\",\r\n \"lastName\": \"Salgado\",\r\n \"country\": \"Mexico\",\r\n \"image\": \"https://xsgames.co/randomusers/assets/avatars/female/14.jpg\",\r\n \"frontBaseUrl\": \"https://auth-mailer-api.netlify.app/auth/verify_email\"\r\n}",
46+
"options": {
47+
"raw": {
48+
"language": "json"
49+
}
50+
}
51+
},
52+
"url": {
53+
"raw": "{{BASE_URL}}/users",
54+
"host": [
55+
"{{BASE_URL}}"
56+
],
57+
"path": [
58+
"users"
59+
]
60+
},
61+
"description": "**Description:** Create a new user into database.\n\n**Correct Response:**\n\n``` json\n{\n \"message\": \"User created successfully!\",\n \"user\": {\n \"isVerified\": false,\n \"id\": 13,\n \"email\": \"clioanahi@gmail.com\",\n \"firstName\": \"Clio\",\n \"lastName\": \"Salgado\",\n \"country\": \"Mexico\",\n \"image\": \"https://xsgames.co/randomusers/assets/avatars/female/14.jpg\",\n \"updatedAt\": \"2025-12-09T22:29:32.222Z\",\n \"createdAt\": \"2025-12-09T22:29:32.222Z\"\n }\n}\n\n ```"
62+
},
63+
"response": []
64+
},
65+
{
66+
"name": "Delete User",
67+
"request": {
68+
"method": "DELETE",
69+
"header": [
70+
{
71+
"key": "Authorization",
72+
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjoxMiwiZW1haWwiOiJjbGlvYW5haGlAZ21haWwuY29tIiwiZmlyc3ROYW1lIjoiQ2xpbyIsImxhc3ROYW1lIjoiU2FsZ2FkbyIsImNvdW50cnkiOiJNZXhpY28iLCJpbWFnZSI6Imh0dHBzOi8veHNnYW1lcy5jby9yYW5kb211c2Vycy9hc3NldHMvYXZhdGFycy9mZW1hbGUvMTQuanBnIiwiaXNWZXJpZmllZCI6dHJ1ZSwiY3JlYXRlZEF0IjoiMjAyNS0xMi0wOVQyMTo0MzoxNC41NjBaIiwidXBkYXRlZEF0IjoiMjAyNS0xMi0wOVQyMTo0NTozNS40NDJaIn0sImlhdCI6MTc3Mzg2ODIzNywiZXhwIjoxNzczOTU0NjM3fQ._hiSuc4zyg8FFEugbzzP8sADKARpyFdqnf7U51D5raY",
73+
"type": "text"
74+
}
75+
],
76+
"url": {
77+
"raw": "{{BASE_URL}}/users/16",
78+
"host": [
79+
"{{BASE_URL}}"
80+
],
81+
"path": [
82+
"users",
83+
"16"
84+
]
85+
},
86+
"description": "**Description:** Delete one user by ID.\n\n**Correct Response:**\n\n<img src=\"https://content.pstmn.io/2ec227d8-cd81-4989-ade7-8c81e8e2404d/aW1hZ2UucG5n\" alt=\"\" height=\"759\" width=\"1359\">"
87+
},
88+
"response": []
89+
},
90+
{
91+
"name": "Verify Email",
92+
"request": {
93+
"method": "GET",
94+
"header": [],
95+
"url": {
96+
"raw": "{{BASE_URL}}/users/verify/98318bf65c21ea227d75456522a642aea63b515273e98fe41624f6c8859bb6bc",
97+
"host": [
98+
"{{BASE_URL}}"
99+
],
100+
"path": [
101+
"users",
102+
"verify",
103+
"98318bf65c21ea227d75456522a642aea63b515273e98fe41624f6c8859bb6bc"
104+
]
105+
},
106+
"description": "**Description:** Verify the email user.\n\n**Correct Response:**\n\n<img src=\"https://content.pstmn.io/2b73aaa1-5f6c-4629-98a6-2acef2564f2e/aW1hZ2UucG5n\" width=\"1364\" height=\"750\">"
107+
},
108+
"response": []
109+
},
110+
{
111+
"name": "Login",
112+
"request": {
113+
"method": "POST",
114+
"header": [],
115+
"body": {
116+
"mode": "raw",
117+
"raw": "{\r\n \"email\": \"clioanahi@gmail.com\",\r\n \"password\": \"789101\"\r\n}",
118+
"options": {
119+
"raw": {
120+
"language": "json"
121+
}
122+
}
123+
},
124+
"url": {
125+
"raw": "{{BASE_URL}}/users/login",
126+
"host": [
127+
"{{BASE_URL}}"
128+
],
129+
"path": [
130+
"users",
131+
"login"
132+
]
133+
},
134+
"description": "**Description:** Login User into API.\n\n**Correct Response:**\n\n``` json\n{\n \"message\": \"Correct Login\",\n \"token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjoxMiwiZW1haWwiOiJjbGlvYW5haGlAZ21haWwuY29tIiwiZmlyc3ROYW1lIjoiQ2xpbyIsImxhc3ROYW1lIjoiU2FsZ2FkbyIsImNvdW50cnkiOiJNZXhpY28iLCJpbWFnZSI6Imh0dHBzOi8veHNnYW1lcy5jby9yYW5kb211c2Vycy9hc3NldHMvYXZhdGFycy9mZW1hbGUvMTQuanBnIiwiaXNWZXJpZmllZCI6dHJ1ZSwiY3JlYXRlZEF0IjoiMjAyNS0xMi0wOVQyMTo0MzoxNC41NjBaIiwidXBkYXRlZEF0IjoiMjAyNS0xMi0wOVQyMTo0NTozNS40NDJaIn0sImlhdCI6MTc2NTMxOTk2MCwiZXhwIjoxNzY1NDA2MzYwfQ.NsSCJeoGFSle8-a7mNhpFWhkvqpdLYJKaKbdnPo48f4\",\n \"user\": {\n \"id\": 12,\n \"email\": \"clioanahi@gmail.com\",\n \"firstName\": \"Clio\",\n \"lastName\": \"Salgado\",\n \"country\": \"Mexico\",\n \"image\": \"https://xsgames.co/randomusers/assets/avatars/female/14.jpg\",\n \"isVerified\": true,\n \"createdAt\": \"2025-12-09T21:43:14.560Z\",\n \"updatedAt\": \"2025-12-09T21:45:35.442Z\"\n }\n}\n\n ```"
135+
},
136+
"response": []
137+
},
138+
{
139+
"name": "Get One User",
140+
"request": {
141+
"method": "GET",
142+
"header": [
143+
{
144+
"key": "Authorization",
145+
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjozLCJlbWFpbCI6Inp5YmFyaXRlQHByb3Rvbi5tZSIsImZpcnN0TmFtZSI6IkNhc3RvbGl0byIsImxhc3ROYW1lIjoiQmIiLCJjb3VudHJ5IjoiTcOpeGljbyIsImltYWdlIjoiaHR0cHM6Ly94c2dhbWVzLmNvL3JhbmRvbXVzZXJzL2Fzc2V0cy9hdmF0YXJzL21hbGUvNy5qcGciLCJpc1ZlcmlmaWVkIjp0cnVlLCJjcmVhdGVkQXQiOiIyMDI1LTEyLTA5VDAxOjIyOjU3Ljk1OFoiLCJ1cGRhdGVkQXQiOiIyMDI1LTEyLTA5VDAxOjIzOjQxLjI2MloifSwiaWF0IjoxNzY1MjQzNjA2LCJleHAiOjE3NjUzMzAwMDZ9.Ld3lKkUe-9P3C7vCiVH076nM_GtVIC_ct1EzGyBpWHQ",
146+
"type": "text"
147+
}
148+
],
149+
"url": {
150+
"raw": "{{BASE_URL}}/users/3",
151+
"host": [
152+
"{{BASE_URL}}"
153+
],
154+
"path": [
155+
"users",
156+
"3"
157+
]
158+
},
159+
"description": "**Description:** Get One User by ID.\n\n**Correct Response:**\n\n``` json\n{\n \"id\": 3,\n \"email\": \"zybarite@proton.me\",\n \"firstName\": \"Israel\",\n \"lastName\": \"Ramírez\",\n \"country\": \"Mexico\",\n \"image\": \"https://xsgames.co/randomusers/assets/avatars/male/7.jpg\",\n \"isVerified\": true,\n \"createdAt\": \"2025-12-09T01:22:57.958Z\",\n \"updatedAt\": \"2025-12-09T21:46:09.101Z\"\n}\n\n ```"
160+
},
161+
"response": []
162+
},
163+
{
164+
"name": "Reset Password",
165+
"request": {
166+
"method": "POST",
167+
"header": [],
168+
"body": {
169+
"mode": "raw",
170+
"raw": "{\r\n \"email\": \"clioanahisalgado@gmail.com\",\r\n \"frontBaseUrl\": \"https://auth-mailer-api.netlify.app/auth/reset_password\"\r\n}",
171+
"options": {
172+
"raw": {
173+
"language": "json"
174+
}
175+
}
176+
},
177+
"url": {
178+
"raw": "{{BASE_URL}}/users/reset_password",
179+
"host": [
180+
"{{BASE_URL}}"
181+
],
182+
"path": [
183+
"users",
184+
"reset_password"
185+
]
186+
},
187+
"description": "**Description:** Reset user password.\n\n**Correct Response:**\n\n<img src=\"https://content.pstmn.io/81e24b41-4cb4-46b2-b343-be7cbb2127d0/aW1hZ2UucG5n\" width=\"931\" height=\"228\">"
188+
},
189+
"response": []
190+
},
191+
{
192+
"name": "Update Password",
193+
"request": {
194+
"method": "POST",
195+
"header": [],
196+
"body": {
197+
"mode": "raw",
198+
"raw": "{\r\n \"password\": \"789101\"\r\n}",
199+
"options": {
200+
"raw": {
201+
"language": "json"
202+
}
203+
}
204+
},
205+
"url": {
206+
"raw": "{{BASE_URL}}/users/reset_password/f9eb2f39d7920052f89d9916be0fc10bacc4bd50fc72b1d03c8b5737ced363c4",
207+
"host": [
208+
"{{BASE_URL}}"
209+
],
210+
"path": [
211+
"users",
212+
"reset_password",
213+
"f9eb2f39d7920052f89d9916be0fc10bacc4bd50fc72b1d03c8b5737ced363c4"
214+
]
215+
},
216+
"description": "**Description:** Update user password into db.\n\n**Correct Response:**\n\n<img src=\"https://content.pstmn.io/8192e454-fbc7-49d3-b03f-a67bd09aee3f/aW1hZ2UucG5n\" width=\"1360\" height=\"765\">"
217+
},
218+
"response": []
219+
},
220+
{
221+
"name": "Update User",
222+
"request": {
223+
"method": "PUT",
224+
"header": [
225+
{
226+
"key": "Authorization",
227+
"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjozLCJlbWFpbCI6Inp5YmFyaXRlQHByb3Rvbi5tZSIsImZpcnN0TmFtZSI6IkNhc3RvbGl0byIsImxhc3ROYW1lIjoiQmIiLCJjb3VudHJ5IjoiTcOpeGljbyIsImltYWdlIjoiaHR0cHM6Ly94c2dhbWVzLmNvL3JhbmRvbXVzZXJzL2Fzc2V0cy9hdmF0YXJzL21hbGUvNy5qcGciLCJpc1ZlcmlmaWVkIjp0cnVlLCJjcmVhdGVkQXQiOiIyMDI1LTEyLTA5VDAxOjIyOjU3Ljk1OFoiLCJ1cGRhdGVkQXQiOiIyMDI1LTEyLTA5VDAxOjIzOjQxLjI2MloifSwiaWF0IjoxNzY1MjQzNjA2LCJleHAiOjE3NjUzMzAwMDZ9.Ld3lKkUe-9P3C7vCiVH076nM_GtVIC_ct1EzGyBpWHQ",
228+
"type": "text"
229+
}
230+
],
231+
"body": {
232+
"mode": "raw",
233+
"raw": "{\r\n \"email\": \"zybarite@proton.me\",\r\n \"firstName\": \"Israel\",\r\n \"lastName\": \"Ramírez\",\r\n \"country\": \"Mexico\",\r\n \"image\": \"https://xsgames.co/randomusers/assets/avatars/male/7.jpg\"\r\n}",
234+
"options": {
235+
"raw": {
236+
"language": "json"
237+
}
238+
}
239+
},
240+
"url": {
241+
"raw": "{{BASE_URL}}/users/3",
242+
"host": [
243+
"{{BASE_URL}}"
244+
],
245+
"path": [
246+
"users",
247+
"3"
248+
]
249+
},
250+
"description": "**Description:** Update user into db.\n\n**Correct Response:**\n\n<img src=\"https://content.pstmn.io/18533bbd-5a11-46e6-a88b-fb10f8f19864/aW1hZ2UucG5n\" width=\"941\" height=\"305\">"
251+
},
252+
"response": []
253+
}
254+
],
255+
"description": "The **Users** folder contains endpoints related to user management in the Auth-Mailer-API. These endpoints allow developers to register, authenticate, and manage users within the system.\n\n### 📌 Endpoints\n\n| Method | Endpoint | Description | **Authorization** |\n| --- | --- | --- | --- |\n| GET | `/users` | Get all users | Token is Required |\n| GET | `/users/:id` | Get a single user by ID | Token is Required |\n| POST | `/users` | Create a new user | Not Required |\n| PUT | `/users/:id` | Update an existing user | Token is required |\n| DELETE | `/users/:id` | Delete an user by ID | Token is required |\n| GET | `/users/verify/:code` | Verify user email with code from email_codes | Not Required |\n| POST | `/users/login` | Login User | Not Required |\n| POST | `/users/reset_password` | Resest user password | Not Required |\n| POST | `/users/reset_password/:code` | Update password with code generated from email_codes | Not required |"
256+
}
257+
],
258+
"event": [
259+
{
260+
"listen": "prerequest",
261+
"script": {
262+
"type": "text/javascript",
263+
"packages": {},
264+
"requests": {},
265+
"exec": [
266+
""
267+
]
268+
}
269+
},
270+
{
271+
"listen": "test",
272+
"script": {
273+
"type": "text/javascript",
274+
"packages": {},
275+
"requests": {},
276+
"exec": [
277+
""
278+
]
279+
}
280+
}
281+
],
282+
"variable": [
283+
{
284+
"key": "BASE_URL",
285+
"value": "https://auth-mailer-api.onrender.com"
286+
}
287+
]
288+
}

0 commit comments

Comments
 (0)