640 lines
19 KiB
JSON
640 lines
19 KiB
JSON
{
|
|
"info": {
|
|
"_postman_id": "8f8e8a60-a292-4c28-9892-a1f727de5a6b",
|
|
"name": "FarmaFinder API Monitoring Collection",
|
|
"description": "Comprehensive integration testing and monitoring collection for FarmaFinder's Express API. Includes automated lifecycle tests for pharmacies and medicine links.",
|
|
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
|
},
|
|
"item": [
|
|
{
|
|
"name": "Public APIs",
|
|
"item": [
|
|
{
|
|
"name": "Search Medicines",
|
|
"request": {
|
|
"method": "GET",
|
|
"header": [],
|
|
"url": {
|
|
"raw": "{{baseUrl}}/api/medicines/search?q=Paracetamol",
|
|
"host": [
|
|
"{{baseUrl}}"
|
|
],
|
|
"path": [
|
|
"api",
|
|
"medicines",
|
|
"search"
|
|
],
|
|
"query": [
|
|
{
|
|
"key": "q",
|
|
"value": "Paracetamol"
|
|
}
|
|
]
|
|
},
|
|
"description": "Searches medicines via the CIMA API with Redis cache."
|
|
},
|
|
"event": [
|
|
{
|
|
"listen": "test",
|
|
"script": {
|
|
"exec": [
|
|
"pm.test(\"Status code is 200\", function () {",
|
|
" pm.response.to.have.status(200);",
|
|
"});",
|
|
"",
|
|
"pm.test(\"Response is an array\", function () {",
|
|
" var jsonData = pm.response.json();",
|
|
" pm.expect(jsonData).to.be.an('array');",
|
|
"});",
|
|
"",
|
|
"pm.test(\"Response returns valid medicine objects\", function () {",
|
|
" var jsonData = pm.response.json();",
|
|
" if (jsonData.length > 0) {",
|
|
" pm.expect(jsonData[0]).to.have.property('nregistro');",
|
|
" pm.expect(jsonData[0]).to.have.property('name');",
|
|
" }",
|
|
"});"
|
|
],
|
|
"type": "text/javascript"
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "Get Medicine Details",
|
|
"request": {
|
|
"method": "GET",
|
|
"header": [],
|
|
"url": {
|
|
"raw": "{{baseUrl}}/api/medicines/51346",
|
|
"host": [
|
|
"{{baseUrl}}"
|
|
],
|
|
"path": [
|
|
"api",
|
|
"medicines",
|
|
"51346"
|
|
]
|
|
},
|
|
"description": "Retrieves medicine metadata from CIMA using its registration number (nregistro)."
|
|
},
|
|
"event": [
|
|
{
|
|
"listen": "test",
|
|
"script": {
|
|
"exec": [
|
|
"pm.test(\"Status code is 200 or 404\", function () {",
|
|
" pm.expect(pm.response.code).to.be.oneOf([200, 404]);",
|
|
"});",
|
|
"",
|
|
"pm.test(\"Response time is acceptable\", function () {",
|
|
" pm.expect(pm.response.responseTime).to.be.below(3000);",
|
|
"});"
|
|
],
|
|
"type": "text/javascript"
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "Get Pharmacies Selling Medicine",
|
|
"request": {
|
|
"method": "GET",
|
|
"header": [],
|
|
"url": {
|
|
"raw": "{{baseUrl}}/api/medicines/51346/pharmacies",
|
|
"host": [
|
|
"{{baseUrl}}"
|
|
],
|
|
"path": [
|
|
"api",
|
|
"medicines",
|
|
"51346",
|
|
"pharmacies"
|
|
]
|
|
},
|
|
"description": "Retrieves the list of pharmacies offering a specific medicine."
|
|
},
|
|
"event": [
|
|
{
|
|
"listen": "test",
|
|
"script": {
|
|
"exec": [
|
|
"pm.test(\"Status code is 200\", function () {",
|
|
" pm.response.to.have.status(200);",
|
|
"});",
|
|
"",
|
|
"pm.test(\"Response is an array\", function () {",
|
|
" pm.expect(pm.response.json()).to.be.an('array');",
|
|
"});"
|
|
],
|
|
"type": "text/javascript"
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "Get All Pharmacies",
|
|
"request": {
|
|
"method": "GET",
|
|
"header": [],
|
|
"url": {
|
|
"raw": "{{baseUrl}}/api/pharmacies",
|
|
"host": [
|
|
"{{baseUrl}}"
|
|
],
|
|
"path": [
|
|
"api",
|
|
"pharmacies"
|
|
]
|
|
},
|
|
"description": "Retrieves all registered pharmacies."
|
|
},
|
|
"event": [
|
|
{
|
|
"listen": "test",
|
|
"script": {
|
|
"exec": [
|
|
"pm.test(\"Status code is 200\", function () {",
|
|
" pm.response.to.have.status(200);",
|
|
"});",
|
|
"",
|
|
"pm.test(\"Response is a list of pharmacies\", function () {",
|
|
" var jsonData = pm.response.json();",
|
|
" pm.expect(jsonData).to.be.an('array');",
|
|
" if (jsonData.length > 0) {",
|
|
" pm.expect(jsonData[0]).to.have.property('name');",
|
|
" pm.expect(jsonData[0]).to.have.property('address');",
|
|
" }",
|
|
"});"
|
|
],
|
|
"type": "text/javascript"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "Authentication APIs",
|
|
"item": [
|
|
{
|
|
"name": "Login",
|
|
"request": {
|
|
"method": "POST",
|
|
"header": [
|
|
{
|
|
"key": "Content-Type",
|
|
"value": "application/json",
|
|
"type": "text"
|
|
}
|
|
],
|
|
"body": {
|
|
"mode": "raw",
|
|
"raw": "{\n \"username\": \"{{username}}\",\n \"password\": \"{{password}}\"\n}"
|
|
},
|
|
"url": {
|
|
"raw": "{{baseUrl}}/api/auth/login",
|
|
"host": [
|
|
"{{baseUrl}}"
|
|
],
|
|
"path": [
|
|
"api",
|
|
"auth",
|
|
"login"
|
|
]
|
|
},
|
|
"description": "Authenticates the admin user and receives session cookie."
|
|
},
|
|
"event": [
|
|
{
|
|
"listen": "test",
|
|
"script": {
|
|
"exec": [
|
|
"pm.test(\"Status code is 200\", function () {",
|
|
" pm.response.to.have.status(200);",
|
|
"});",
|
|
"",
|
|
"pm.test(\"Verify user is admin\", function () {",
|
|
" var jsonData = pm.response.json();",
|
|
" pm.expect(jsonData.message).to.equal(\"Login successful\");",
|
|
" pm.expect(jsonData.user.is_admin).to.be.true;",
|
|
"});"
|
|
],
|
|
"type": "text/javascript"
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "Check Authentication Status",
|
|
"request": {
|
|
"method": "GET",
|
|
"header": [],
|
|
"url": {
|
|
"raw": "{{baseUrl}}/api/auth/check",
|
|
"host": [
|
|
"{{baseUrl}}"
|
|
],
|
|
"path": [
|
|
"api",
|
|
"auth",
|
|
"check"
|
|
]
|
|
},
|
|
"description": "Checks if the session cookie is valid and active."
|
|
},
|
|
"event": [
|
|
{
|
|
"listen": "test",
|
|
"script": {
|
|
"exec": [
|
|
"pm.test(\"Status code is 200\", function () {",
|
|
" pm.response.to.have.status(200);",
|
|
"});",
|
|
"",
|
|
"pm.test(\"Session is authenticated\", function () {",
|
|
" var jsonData = pm.response.json();",
|
|
" pm.expect(jsonData.authenticated).to.be.true;",
|
|
"});"
|
|
],
|
|
"type": "text/javascript"
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "Get Admin Profile",
|
|
"request": {
|
|
"method": "GET",
|
|
"header": [],
|
|
"url": {
|
|
"raw": "{{baseUrl}}/api/users/me",
|
|
"host": [
|
|
"{{baseUrl}}"
|
|
],
|
|
"path": [
|
|
"api",
|
|
"users",
|
|
"me"
|
|
]
|
|
},
|
|
"description": "Loads profile details for the authenticated user."
|
|
},
|
|
"event": [
|
|
{
|
|
"listen": "test",
|
|
"script": {
|
|
"exec": [
|
|
"pm.test(\"Status code is 200\", function () {",
|
|
" pm.response.to.have.status(200);",
|
|
"});"
|
|
],
|
|
"type": "text/javascript"
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "Logout",
|
|
"request": {
|
|
"method": "POST",
|
|
"header": [],
|
|
"url": {
|
|
"raw": "{{baseUrl}}/api/auth/logout",
|
|
"host": [
|
|
"{{baseUrl}}"
|
|
],
|
|
"path": [
|
|
"api",
|
|
"auth",
|
|
"logout"
|
|
]
|
|
},
|
|
"description": "Destroys the current authenticated session."
|
|
},
|
|
"event": [
|
|
{
|
|
"listen": "test",
|
|
"script": {
|
|
"exec": [
|
|
"pm.test(\"Status code is 200\", function () {",
|
|
" pm.response.to.have.status(200);",
|
|
"});"
|
|
],
|
|
"type": "text/javascript"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "Admin APIs (Transactional)",
|
|
"item": [
|
|
{
|
|
"name": "Create Pharmacy",
|
|
"request": {
|
|
"method": "POST",
|
|
"header": [
|
|
{
|
|
"key": "Content-Type",
|
|
"value": "application/json",
|
|
"type": "text"
|
|
}
|
|
],
|
|
"body": {
|
|
"mode": "raw",
|
|
"raw": "{\n \"name\": \"Postman Monitor Pharmacy\",\n \"address\": \"Calle del Monitor 99, Madrid\",\n \"phone\": \"+34 900 123 456\",\n \"latitude\": 40.4168,\n \"longitude\": -3.7038,\n \"opening_hours\": \"24h\"\n}"
|
|
},
|
|
"url": {
|
|
"raw": "{{baseUrl}}/api/admin/pharmacies",
|
|
"host": [
|
|
"{{baseUrl}}"
|
|
],
|
|
"path": [
|
|
"api",
|
|
"admin",
|
|
"pharmacies"
|
|
]
|
|
},
|
|
"description": "Creates a new pharmacy for testing."
|
|
},
|
|
"event": [
|
|
{
|
|
"listen": "test",
|
|
"script": {
|
|
"exec": [
|
|
"pm.test(\"Status code is 201\", function () {",
|
|
" pm.response.to.have.status(201);",
|
|
"});",
|
|
"",
|
|
"var jsonData = pm.response.json();",
|
|
"pm.test(\"Response contains created pharmacy ID\", function () {",
|
|
" pm.expect(jsonData.id).to.exist;",
|
|
" pm.collectionVariables.set(\"temp_pharmacy_id\", jsonData.id);",
|
|
"});"
|
|
],
|
|
"type": "text/javascript"
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "Update Pharmacy",
|
|
"request": {
|
|
"method": "PUT",
|
|
"header": [
|
|
{
|
|
"key": "Content-Type",
|
|
"value": "application/json",
|
|
"type": "text"
|
|
}
|
|
],
|
|
"body": {
|
|
"mode": "raw",
|
|
"raw": "{\n \"name\": \"Postman Monitor Pharmacy - Updated\",\n \"address\": \"Calle del Monitor 99, Madrid\",\n \"phone\": \"+34 900 123 456\",\n \"latitude\": 40.4170,\n \"longitude\": -3.7040,\n \"opening_hours\": \"9:00 - 22:00\"\n}"
|
|
},
|
|
"url": {
|
|
"raw": "{{baseUrl}}/api/admin/pharmacies/{{temp_pharmacy_id}}",
|
|
"host": [
|
|
"{{baseUrl}}"
|
|
],
|
|
"path": [
|
|
"api",
|
|
"admin",
|
|
"pharmacies",
|
|
"{{temp_pharmacy_id}}"
|
|
]
|
|
},
|
|
"description": "Updates the properties of the temporary pharmacy."
|
|
},
|
|
"event": [
|
|
{
|
|
"listen": "test",
|
|
"script": {
|
|
"exec": [
|
|
"pm.test(\"Status code is 200\", function () {",
|
|
" pm.response.to.have.status(200);",
|
|
"});",
|
|
"",
|
|
"pm.test(\"Fields were successfully updated\", function () {",
|
|
" var jsonData = pm.response.json();",
|
|
" pm.expect(jsonData.name).to.include(\"Updated\");",
|
|
"});"
|
|
],
|
|
"type": "text/javascript"
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "Get Pharmacy Medicines",
|
|
"request": {
|
|
"method": "GET",
|
|
"header": [],
|
|
"url": {
|
|
"raw": "{{baseUrl}}/api/admin/pharmacies/{{temp_pharmacy_id}}/medicines",
|
|
"host": [
|
|
"{{baseUrl}}"
|
|
],
|
|
"path": [
|
|
"api",
|
|
"admin",
|
|
"pharmacies",
|
|
"{{temp_pharmacy_id}}",
|
|
"medicines"
|
|
]
|
|
},
|
|
"description": "Retrieves the list of medicines linked to the temporary pharmacy."
|
|
},
|
|
"event": [
|
|
{
|
|
"listen": "test",
|
|
"script": {
|
|
"exec": [
|
|
"pm.test(\"Status code is 200\", function () {",
|
|
" pm.response.to.have.status(200);",
|
|
"});",
|
|
"",
|
|
"pm.test(\"Response is an array\", function () {",
|
|
" pm.expect(pm.response.json()).to.be.an('array');",
|
|
"});"
|
|
],
|
|
"type": "text/javascript"
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "Link Medicine to Pharmacy",
|
|
"request": {
|
|
"method": "POST",
|
|
"header": [
|
|
{
|
|
"key": "Content-Type",
|
|
"value": "application/json",
|
|
"type": "text"
|
|
}
|
|
],
|
|
"body": {
|
|
"mode": "raw",
|
|
"raw": "{\n \"pharmacy_id\": {{temp_pharmacy_id}},\n \"medicine_nregistro\": \"51346\",\n \"medicine_name\": \"Paracetamol 500mg\",\n \"price\": 4.75,\n \"stock\": 100\n}"
|
|
},
|
|
"url": {
|
|
"raw": "{{baseUrl}}/api/admin/pharmacy-medicines",
|
|
"host": [
|
|
"{{baseUrl}}"
|
|
],
|
|
"path": [
|
|
"api",
|
|
"admin",
|
|
"pharmacy-medicines"
|
|
]
|
|
},
|
|
"description": "Links a medicine to the temporary pharmacy with stock and price details."
|
|
},
|
|
"event": [
|
|
{
|
|
"listen": "test",
|
|
"script": {
|
|
"exec": [
|
|
"pm.test(\"Status code is 201\", function () {",
|
|
" pm.response.to.have.status(201);",
|
|
"});",
|
|
"",
|
|
"var jsonData = pm.response.json();",
|
|
"pm.test(\"Link relationship created\", function () {",
|
|
" pm.expect(jsonData.id).to.exist;",
|
|
" pm.collectionVariables.set(\"temp_relation_id\", jsonData.id);",
|
|
"});"
|
|
],
|
|
"type": "text/javascript"
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "Update Pharmacy Medicine Relation",
|
|
"request": {
|
|
"method": "PUT",
|
|
"header": [
|
|
{
|
|
"key": "Content-Type",
|
|
"value": "application/json",
|
|
"type": "text"
|
|
}
|
|
],
|
|
"body": {
|
|
"mode": "raw",
|
|
"raw": "{\n \"price\": 5.25,\n \"stock\": 95\n}"
|
|
},
|
|
"url": {
|
|
"raw": "{{baseUrl}}/api/admin/pharmacy-medicines/{{temp_relation_id}}",
|
|
"host": [
|
|
"{{baseUrl}}"
|
|
],
|
|
"path": [
|
|
"api",
|
|
"admin",
|
|
"pharmacy-medicines",
|
|
"{{temp_relation_id}}"
|
|
]
|
|
},
|
|
"description": "Updates price and stock properties on the relation."
|
|
},
|
|
"event": [
|
|
{
|
|
"listen": "test",
|
|
"script": {
|
|
"exec": [
|
|
"pm.test(\"Status code is 200\", function () {",
|
|
" pm.response.to.have.status(200);",
|
|
"});"
|
|
],
|
|
"type": "text/javascript"
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "Unlink Medicine from Pharmacy",
|
|
"request": {
|
|
"method": "DELETE",
|
|
"header": [],
|
|
"url": {
|
|
"raw": "{{baseUrl}}/api/admin/pharmacy-medicines/{{temp_relation_id}}",
|
|
"host": [
|
|
"{{baseUrl}}"
|
|
],
|
|
"path": [
|
|
"api",
|
|
"admin",
|
|
"pharmacy-medicines",
|
|
"{{temp_relation_id}}"
|
|
]
|
|
},
|
|
"description": "Removes the relation between the medicine and pharmacy."
|
|
},
|
|
"event": [
|
|
{
|
|
"listen": "test",
|
|
"script": {
|
|
"exec": [
|
|
"pm.test(\"Status code is 200\", function () {",
|
|
" pm.response.to.have.status(200);",
|
|
"});"
|
|
],
|
|
"type": "text/javascript"
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "Delete Pharmacy",
|
|
"request": {
|
|
"method": "DELETE",
|
|
"header": [],
|
|
"url": {
|
|
"raw": "{{baseUrl}}/api/admin/pharmacies/{{temp_pharmacy_id}}",
|
|
"host": [
|
|
"{{baseUrl}}"
|
|
],
|
|
"path": [
|
|
"api",
|
|
"admin",
|
|
"pharmacies",
|
|
"{{temp_pharmacy_id}}"
|
|
]
|
|
},
|
|
"description": "Deletes the temporary pharmacy to restore database clean state."
|
|
},
|
|
"event": [
|
|
{
|
|
"listen": "test",
|
|
"script": {
|
|
"exec": [
|
|
"pm.test(\"Status code is 200\", function () {",
|
|
" pm.response.to.have.status(200);",
|
|
"});"
|
|
],
|
|
"type": "text/javascript"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"variable": [
|
|
{
|
|
"key": "temp_pharmacy_id",
|
|
"value": ""
|
|
},
|
|
{
|
|
"key": "temp_relation_id",
|
|
"value": ""
|
|
}
|
|
]
|
|
}
|