Created
May 11, 2025 13:56
-
-
Save gsdt/b01b5533357fe6b8db09684c000a167d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"info": { | |
"_postman_id": "7fb46906-7d12-4890-af10-0e89824c9705", | |
"name": "Smoke Tests", | |
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", | |
"_exporter_id": "4413391", | |
"_collection_link": "https://sydexa-learning-student.postman.co/workspace/Sydexa---IG001~aec9e5aa-2744-4c49-87d5-9d2b8ed074dc/collection/4413391-7fb46906-7d12-4890-af10-0e89824c9705?action=share&source=collection_link&creator=4413391" | |
}, | |
"item": [ | |
{ | |
"name": "Authentication Endpoint", | |
"item": [ | |
{ | |
"name": "Test User Registration", | |
"event": [ | |
{ | |
"listen": "test", | |
"script": { | |
"exec": [ | |
"// Test for status code", | |
"pm.test(\"Status code is 201\", function () {", | |
" pm.response.to.have.status(201);", | |
"});", | |
"", | |
"// Test for response time", | |
"pm.test(\"Response time is less than 200ms\", function () {", | |
" pm.expect(pm.response.responseTime).to.be.below(200);", | |
"});", | |
"", | |
"// Test for response body properties", | |
"pm.test(\"Response body has data, message, status, and success properties\", function () {", | |
" const responseBody = pm.response.json();", | |
" pm.expect(responseBody).to.have.property('data');", | |
" pm.expect(responseBody).to.have.property('message');", | |
" pm.expect(responseBody).to.have.property('status');", | |
" pm.expect(responseBody).to.have.property('success');", | |
"});" | |
], | |
"type": "text/javascript", | |
"packages": {} | |
} | |
}, | |
{ | |
"listen": "prerequest", | |
"script": { | |
"exec": [ | |
"const randomId = Math.floor(Math.random() * 100000);", | |
"pm.environment.set(\"username\", \"testuser_\" + randomId);", | |
"pm.environment.set(\"fullname\", \"Test User \" + randomId);", | |
"pm.environment.set(\"email\", \"test_\" + randomId + \"@example.com\");", | |
"pm.environment.set(\"password\", \"secret123\");" | |
], | |
"type": "text/javascript", | |
"packages": {} | |
} | |
} | |
], | |
"request": { | |
"method": "POST", | |
"header": [], | |
"body": { | |
"mode": "raw", | |
"raw": "{\n \"username\": \"{{username}}\",\n \"password\": \"{{password}}\",\n \"fullname\": \"{{fullname}}\",\n \"email\": \"{{email}}\"\n}", | |
"options": { | |
"raw": { | |
"language": "json" | |
} | |
} | |
}, | |
"url": { | |
"raw": "{{host}}/api/auth/register", | |
"host": [ | |
"{{host}}" | |
], | |
"path": [ | |
"api", | |
"auth", | |
"register" | |
] | |
} | |
}, | |
"response": [] | |
}, | |
{ | |
"name": "Test Login Wrong Identity", | |
"event": [ | |
{ | |
"listen": "test", | |
"script": { | |
"exec": [ | |
"pm.test(\"Status code is 401\", function () {", | |
" pm.response.to.have.status(401);", | |
"});", | |
"", | |
"pm.test(\"Response time is less than 200ms\", function () {", | |
" pm.expect(pm.response.responseTime).to.be.below(200);", | |
"});", | |
"", | |
"pm.test(\"Response body has correct message and status\", function () {", | |
" const jsonData = pm.response.json();", | |
" pm.expect(jsonData.message).to.equal(\"Username or password is incorrect\");", | |
" pm.expect(jsonData.status).to.equal(401);", | |
" pm.expect(jsonData.success).to.be.false;", | |
"});", | |
"" | |
], | |
"type": "text/javascript", | |
"packages": {} | |
} | |
} | |
], | |
"request": { | |
"method": "POST", | |
"header": [], | |
"body": { | |
"mode": "raw", | |
"raw": "{\n \"username\": \"hello\",\n \"password\": \"1212\"\n}", | |
"options": { | |
"raw": { | |
"language": "json" | |
} | |
} | |
}, | |
"url": { | |
"raw": "{{host}}/api/auth/login", | |
"host": [ | |
"{{host}}" | |
], | |
"path": [ | |
"api", | |
"auth", | |
"login" | |
] | |
} | |
}, | |
"response": [] | |
}, | |
{ | |
"name": "Test Login Success", | |
"event": [ | |
{ | |
"listen": "test", | |
"script": { | |
"exec": [ | |
"// Test for status code", | |
"pm.test(\"Status code is 200\", function () {", | |
" pm.response.to.have.status(200);", | |
"});", | |
"", | |
"// Test for response time", | |
"pm.test(\"Response time is less than 200ms\", function () {", | |
" pm.expect(pm.response.responseTime).to.be.below(200);", | |
"});", | |
"", | |
"// Test for response body properties", | |
"pm.test(\"Response body has required properties\", function () {", | |
" const responseBody = pm.response.json();", | |
" pm.expect(responseBody.data).to.have.property('access_token');", | |
" pm.expect(responseBody.data).to.have.property('refresh_token');", | |
" pm.expect(responseBody.data).to.have.property('user');", | |
" pm.expect(responseBody.message).to.equal(\"Login successful\");", | |
" pm.expect(responseBody.success).to.be.true;", | |
"});", | |
"" | |
], | |
"type": "text/javascript", | |
"packages": {} | |
} | |
} | |
], | |
"request": { | |
"method": "POST", | |
"header": [], | |
"body": { | |
"mode": "raw", | |
"raw": "{\n \"username\": \"{{username}}\",\n \"password\": \"{{password}}\"\n}", | |
"options": { | |
"raw": { | |
"language": "json" | |
} | |
} | |
}, | |
"url": { | |
"raw": "{{host}}/api/auth/login", | |
"host": [ | |
"{{host}}" | |
], | |
"path": [ | |
"api", | |
"auth", | |
"login" | |
] | |
} | |
}, | |
"response": [] | |
} | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment