API Testing with Postman
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
API Testing with Postman provides a structured environment for verifying the functional integrity of the Outmanage Backend API. It encompasses complete test coverage for core logistics operations, including user management, role-based access control (RBAC), inventory tracking, and shipment processing. The testing suite is designed to validate both successful operations and error-handling scenarios, ensuring robust API performance.
The testing infrastructure utilizes a Postman collection and environment variables to facilitate seamless transitions between development and production environments. Key features include automated token-based authentication handling, pre-request scripts for header management, and specialized testing for AI-powered features like vehicle plate verification.
Sources: README.md:120-130, outmanage_api_tests.postman_collection.json:1-10
Testing Infrastructure
The testing suite consists of a JSON-based collection containing organized request folders and an environment configuration for variable management.
Environment Configuration
The testing environment relies on dynamic variables to maintain flexibility across different server instances.
| Variable | Description | Default/Example |
|---|---|---|
baseUrl | The root URL of the API server | http://localhost:3000 |
accessToken | JWT used for authenticating requests | Set automatically after login |
userId | UUID for testing specific user logs | {{userId}} |
Sources: README.md:154-158, outmanage_api_tests.postman_collection.json:2078-2083
Authentication Flow
The collection uses an automated lifecycle to manage security tokens. When a user logs in via the "Login - Valid Credentials" request, a test script extracts the access token and updates the environment. A collection-level pre-request script then injects this token into the x-outmanage-token header for all subsequent requests.
The diagram shows the automated token handling process where the login response triggers an environment update used by future requests.
Sources: README.md:139-152, outmanage_api_tests.postman_collection.json:2058-2070
Core Module Coverage
User and Role Management
Tests for the user module cover the full CRUD lifecycle, including soft-deletion (archiving) and restoration. The RBAC system is tested by verifying permission assignments to specific roles and validating that unauthorized requests are blocked.
| Feature | Tested Scenarios | Endpoint Example |
|---|---|---|
| User Creation | Valid data, invalid email, missing fields | POST /api/users |
| Role Assignment | Valid role, non-existent role ID | PUT /api/users/:id |
| Archiving | Soft delete, restoration, fetching archived list | PATCH /api/users/:id/unarchived |
Sources: outmanage_api_tests.postman_collection.json:15-450, comprehensive-swagger-api.json:520-560
Shipment and Weighing Operations
The shipment module includes complex testing for logistics workflows, including the bulk weighing system which distributes weight proportionally across delivery order items.
The flow represents the sequence of requests required to move a shipment from creation to completion in the Postman collection.
Sources: outmanage_api_tests.postman_collection.json:1540-1650, CLAUDE.md:46-51
Advanced Feature Testing
AI Plate Verification
The system integrates Google Gemini AI for vehicle plate recognition. Testing this requires a multi-step request sequence:
- Upload Photo: A
PATCHrequest to/shipment/:id/upload-plate-photousingform-datato send an image file. - Trigger AI: A
PATCHrequest to/shipment/:id/verify-platewhich invokes the Gemini AI model to extract and compare the plate number.
Sources: README.md:162-192, outmanage_api_tests.postman_collection.json:1615-1635
Comprehensive Documentation Reference
For deeper technical details on specific endpoint schemas and status codes, the project provides several documentation endpoints that can be verified during testing:
/api-docs: Complete Swagger/OpenAPI documentation./weighing-docs: Specialized documentation for weighing endpoints./health: System health check providing Jakarta timezone timestamps.
Sources: src/index.ts:52-70, CLAUDE.md:21-25
Summary
API Testing with Postman in the Outmanage project ensures the reliability of the logistics management system through automated authentication, detailed scenario coverage (from RBAC to AI verification), and centralized environment management. This setup allows developers to maintain code quality while scaling the backend services.