This document explains the architecture of the Postman test collection located at api/Conduit.postman_collection.json The collection provides comprehensive API validation for RealWorld implementations, ensuring compliance with the OpenAPI specification. It covers the collection's hierarchical structure, test script organization, stateful execution model, and assertion patterns.
For information about running these tests, see Running API Tests. For details on what the tests validate, see Test Coverage & Validation. For the API specification being tested, see API Specification.
The Postman collection follows the Postman Collection v2.1.0 schema. The root structure contains metadata and a hierarchical array of test items organized into functional folders.
| Property | Description | Location |
|---|---|---|
info | Collection metadata including ID, name, description | api/Conduit.postman_collection.json2-7 |
info.name | Collection name: "Conduit" | api/Conduit.postman_collection.json4 |
info.schema | Schema version: "v2.1.0" | api/Conduit.postman_collection.json6 |
item[] | Array of top-level folders containing test requests | api/Conduit.postman_collection.json8 |
The collection contains no collection-level variables, pre-request scripts, or authentication settings. All configuration is managed through environment variables and global variables set during test execution.
Sources: api/Conduit.postman_collection.json1-7
The collection organizes tests into seven top-level folders, each focusing on a specific API domain. Tests within folders execute sequentially, with later tests often depending on state established by earlier tests.
| Folder | Purpose | Request Count | Key Functionality |
|---|---|---|---|
| Auth | User authentication and management | 6 | Registration, login, token management, profile updates |
| Articles | Article retrieval with filters | 4 | Filtering by author, tags, favorites |
| Articles, Favorite, Comments | Article CRUD and interactions | 28 | Create, update, delete, favorite, comment operations |
| Profiles | User profile operations | 3 | View profiles, follow/unfollow users |
| Comments | Comment operations | 3 | Create, retrieve, delete comments |
| Favorites | Article favoriting | 4 | Favorite and unfavorite articles |
| Tags | Tag retrieval | 1 | Get all tags |
Sources: api/Conduit.postman_collection.json8-344 api/Conduit.postman_collection.json345-654 api/Conduit.postman_collection.json656-3200
Each request in the collection follows a consistent structure with five main components: HTTP method, headers, request body, URL templating, and test scripts.
The Register request demonstrates the standard pattern used throughout the collection:
POST {{APIURL}}/users
Headers:
- Content-Type: application/json
- X-Requested-With: XMLHttpRequest
Body:
{
"user": {
"email": "{{EMAIL}}",
"password": "{{PASSWORD}}",
"username": "{{USERNAME}}"
}
}
Test Script:
- Parse responseBody
- Assert response contains "user" property
- Assert user has required properties (email, username, bio, image, token)
Key Patterns:
| Pattern | Description | Example |
|---|---|---|
| Resource Wrapping | Request/response bodies wrap data in resource key | {"user": {...}}, {"article": {...}} |
| Variable Templating | Environment/global variables in {{VAR}} format | {{APIURL}}, {{token}}, {{slug}} |
| Standard Headers | Consistent headers across requests | Content-Type, X-Requested-With |
| Auth Header Format | JWT token in specific format | Authorization: Token {{token}} |
Sources: api/Conduit.postman_collection.json38-64 api/Conduit.postman_collection.json90-117
Test scripts execute in the test event listener after each request completes. Scripts are written in JavaScript and stored as arrays of string statements in the event[].script.exec property.
1. Response Parsing
All test scripts begin by parsing the JSON response:
Location: api/Conduit.postman_collection.json21 repeated in all test scripts
2. Property Assertions
The tests[] object stores test results with descriptive keys:
Location: api/Conduit.postman_collection.json23-31
3. Type Validation
Type checks ensure correct data structures:
Location: api/Conduit.postman_collection.json378 api/Conduit.postman_collection.json365
4. Format Validation
Regex patterns validate timestamp formats:
Location: api/Conduit.postman_collection.json373
5. Modern pm.test() Syntax
Newer tests use the pm.test() API for assertions:
Location: api/Conduit.postman_collection.json331-336
Sources: api/Conduit.postman_collection.json14-36 api/Conduit.postman_collection.json120-148 api/Conduit.postman_collection.json350-389
The collection maintains state across requests using Postman's global variables. This enables sequential test flows where later requests depend on data created by earlier requests.
| Variable Name | Scope | Set By | Used By | Purpose |
|---|---|---|---|---|
token | Global | Login and Remember Token | All authenticated requests | JWT authentication token |
slug | Global | Create Article | Article operations | Article identifier for CRUD |
slug2 | Global | Create Second Article | Pagination tests, delete | Second article identifier |
commentId | Global | Create Comment | Delete Comment | Comment identifier |
APIURL | Environment | Test runner | All requests | Base API URL |
EMAIL | Environment | Test runner | Register, Login, Update | User email |
PASSWORD | Environment | Test runner | Register, Login | User password |
USERNAME | Environment | Test runner | Register, queries | Username |
The "Login and Remember Token" request stores the JWT token for all subsequent authenticated requests:
Location: api/Conduit.postman_collection.json140-144
After creating an article, the slug is stored for future operations:
Location: api/Conduit.postman_collection.json675-676
Sources: api/Conduit.postman_collection.json120-148 api/Conduit.postman_collection.json660-726 api/Conduit.postman_collection.json728-780
The collection uses environment variables for configuration that varies between test runs. These variables must be provided by the test runner (Newman CLI or Postman GUI).
| Variable | Type | Purpose | Example Value |
|---|---|---|---|
APIURL | String | Base API URL (without trailing slash) | http://localhost:3000/api |
EMAIL | String | User email for registration/login | [email protected] |
PASSWORD | String | User password | securepassword123 |
USERNAME | String | Username for registration | testuser |
URL Construction:
{{APIURL}}/users/login
{{APIURL}}/articles/{{slug}}
{{APIURL}}/profiles/{{USERNAME}}
Location: api/Conduit.postman_collection.json107-115
Request Body Templating:
Location: api/Conduit.postman_collection.json52
Query Parameters:
{{APIURL}}/articles?author=johnjacob
{{APIURL}}/articles?favorited={{USERNAME}}
{{APIURL}}/articles?tag=dragons
Location: api/Conduit.postman_collection.json481 api/Conduit.postman_collection.json559
The collection supports an integration test mode that skips certain assertions:
Location: api/Conduit.postman_collection.json20-32
Sources: api/Conduit.postman_collection.json50-62 api/Conduit.postman_collection.json102-115 api/README.md5-9
The collection employs several assertion patterns to validate API responses comprehensively. Assertions check response structure, data types, value formats, and business logic.
Tests verify the presence of nested properties in a top-down manner:
Location: api/Conduit.postman_collection.json23-31
For collection responses (articles, comments), tests validate both container and item properties:
Location: api/Conduit.postman_collection.json363-386
Special tests ensure correct pagination behavior where articlesCount represents total count, not page size:
Location: api/Conduit.postman_collection.json800-847
Tests verify appropriate status codes for different operations:
Location: api/Conduit.postman_collection.json356 api/Conduit.postman_collection.json884 api/Conduit.postman_collection.json331-333
ISO 8601 timestamp format validation:
Location: api/Conduit.postman_collection.json373 api/Conduit.postman_collection.json680
Tests verify that updates persist across requests:
Location: api/Conduit.postman_collection.json292-342
Sources: api/Conduit.postman_collection.json350-389 api/Conduit.postman_collection.json782-847 api/Conduit.postman_collection.json660-690
The collection is designed for sequential execution where tests build upon each other. Dependencies are managed through global variable state and folder organization.
| Dependent Request | Depends On | Dependency Type | Required Data |
|---|---|---|---|
| All authenticated requests | Login and Remember Token | State | pm.globals.token |
| Get Current User | Login and Remember Token | State | pm.globals.token |
| Create Article | Login and Remember Token | State | pm.globals.token |
| Get Article | Create Article | State | pm.globals.slug |
| Update Article | Create Article | State | pm.globals.slug, pm.globals.token |
| Delete Article | Create Article | State | pm.globals.slug, pm.globals.token |
| Pagination tests | Create Second Article | State | pm.globals.slug2 |
| Delete Second Article | Pagination tests | Execution order | Must run after pagination |
| Create Comment | Create Article | State | pm.globals.slug, pm.globals.token |
| Delete Comment | Create Comment | State | pm.globals.commentId, pm.globals.token |
| Favorite Article | Create Article | State | pm.globals.slug, pm.globals.token |
The collection expects folders to execute in this order:
Important: Running tests out of order will cause failures due to missing global variables or non-existent resources.
Sources: api/Conduit.postman_collection.json8-3200 api/Conduit.postman_collection.json120-148 api/Conduit.postman_collection.json660-780
The Postman collection validates that API implementations conform to the OpenAPI specification. Each request in the collection corresponds to an operation defined in api/openapi.yml
| OpenAPI Operation | operationId | Collection Request | Validates |
|---|---|---|---|
POST /users | CreateUser | Auth > Register | User creation, response schema |
POST /users/login | Login | Auth > Login and Remember Token | Authentication, token format |
GET /user | GetCurrentUser | Auth > Current User | Authenticated user retrieval |
PUT /user | UpdateCurrentUser | Auth > Update User | User modification |
GET /articles | GetArticles | Articles > All Articles | Article list, query filters |
POST /articles | CreateArticle | Create Article | Article creation schema |
GET /articles/{slug} | GetArticle | Single Article by slug | Article retrieval |
PUT /articles/{slug} | UpdateArticle | Update Article | Article modification |
DELETE /articles/{slug} | DeleteArticle | Delete Article | Article deletion (204/200) |
GET /articles/feed | GetArticlesFeed | Feed | Authenticated feed |
POST /articles/{slug}/favorite | CreateArticleFavorite | Favorite Article | Favoriting logic |
GET /profiles/{username} | GetProfileByUsername | Profiles > Get Profile | Profile retrieval |
The test scripts validate response schemas match the OpenAPI definitions:
OpenAPI User Schema (api/openapi.yml481-503):
Postman Validation (api/Conduit.postman_collection.json23-31):
The collection validates the Token authentication scheme defined in api/openapi.yml909-918:
Authorization: Token xxxxxx.yyyyyyy.zzzzzz
Implemented in requests as: Authorization: Token {{token}}
Location: api/Conduit.postman_collection.json215-217 api/Conduit.postman_collection.json270-273
Sources: api/openapi.yml22-453 api/Conduit.postman_collection.json8-3200
Refresh this wiki