Behavior-Driven Development (BDD) test scenarios for TelemetryFlow Core IAM API.
This document describes the BDD test scenarios using Given-When-Then format for all IAM endpoints.
# Install Newman and HTML reporter
npm install -g newman newman-reporter-htmlextra
# Ensure backend is running
docker-compose up -d backend
# Wait for backend to be ready
curl http://localhost:3000/healthbash docs/postman/run-bdd-tests.shbash docs/postman/run-bdd-tests.sh --folder Users
bash docs/postman/run-bdd-tests.sh --folder Roles
bash docs/postman/run-bdd-tests.sh --folder Organizations# Verbose output
bash docs/postman/run-bdd-tests.sh --verbose
# Stop on first failure
bash docs/postman/run-bdd-tests.sh --bail
# Combine options
bash docs/postman/run-bdd-tests.sh --folder Users --verbose --bailGiven the TelemetryFlow Core backend is running
When I send a GET request to /health
Then the response status should be 200
And the response should contain status "ok"Given the TelemetryFlow Core backend is running
When I send a GET request to /metrics
Then the response status should be 200
And the response should contain Prometheus metricsGiven I am authenticated as Super Admin
When I send a GET request to /api/v2/users
Then the response status should be 200
And the response should contain an array of users
And each user should have id, email, firstName, lastNameGiven I am authenticated as Super Admin
And a user exists with ID "{{user_id}}"
When I send a GET request to /api/v2/users/{{user_id}}
Then the response status should be 200
And the response should contain user detailsGiven I am authenticated as Administrator
And I have valid user data
When I send a POST request to /api/v2/users with:
| email | john.doe@example.com |
| firstName | John |
| lastName | Doe |
| password | SecurePass@123 |
| organizationId | {{organization_id}} |
Then the response status should be 201
And the response should contain the created user
And the user should have a valid UUIDGiven I am authenticated as Administrator
And a user exists with ID "{{user_id}}"
When I send a PUT request to /api/v2/users/{{user_id}} with:
| firstName | Jane |
| lastName | Doe |
Then the response status should be 200
And the user firstName should be "Jane"Given I am authenticated as Administrator
And a user exists with ID "{{user_id}}"
And the user is inactive
When I send a POST request to /api/v2/users/{{user_id}}/activate
Then the response status should be 200
And the user isActive should be trueGiven I am authenticated as Administrator
And a user exists with ID "{{user_id}}"
And the user is active
When I send a POST request to /api/v2/users/{{user_id}}/deactivate
Then the response status should be 200
And the user isActive should be falseGiven I am authenticated as the user
And I have a valid current password
When I send a PUT request to /api/v2/users/{{user_id}}/password with:
| currentPassword | OldPass@123 |
| newPassword | NewPass@123 |
Then the response status should be 200
And I should be able to login with the new passwordGiven I am authenticated as Super Admin
When I send a GET request to /api/v2/roles
Then the response status should be 200
And the response should contain 5 roles
And the roles should include "Super Administrator", "Administrator", "Developer", "Viewer", "Demo"Given I am authenticated as Super Admin
And a role exists with ID "{{role_id}}"
When I send a GET request to /api/v2/roles/{{role_id}}
Then the response status should be 200
And the response should contain role detailsGiven I am authenticated as Super Admin
When I send a POST request to /api/v2/roles with:
| name | Custom Role |
| description | Custom role desc |
| tier | 3 |
Then the response status should be 201
And the response should contain the created roleGiven I am authenticated as Super Admin
And a role exists with ID "{{role_id}}"
And a permission exists with ID "{{permission_id}}"
When I send a POST request to /api/v2/roles/{{role_id}}/permissions/{{permission_id}}
Then the response status should be 200
And the role should have the permission assignedGiven I am authenticated as Super Admin
And a role exists with ID "{{role_id}}"
When I send a GET request to /api/v2/roles/{{role_id}}/users
Then the response status should be 200
And the response should contain an array of users with that roleGiven I am authenticated as Super Admin
When I send a GET request to /api/v2/permissions
Then the response status should be 200
And the response should contain at least 22 permissions
And each permission should have resource and actionGiven I am authenticated as Super Admin
And a permission exists with ID "{{permission_id}}"
When I send a GET request to /api/v2/permissions/{{permission_id}}
Then the response status should be 200
And the response should contain permission detailsGiven I am authenticated as Super Admin
When I send a GET request to /api/v2/organizations
Then the response status should be 200
And the response should contain at least 3 organizations
And the organizations should include "DEVOPSCORNER", "TELEMETRYFLOW", "DEMO"Given I am authenticated as Super Admin
And an organization exists with ID "{{organization_id}}"
When I send a GET request to /api/v2/organizations/{{organization_id}}
Then the response status should be 200
And the response should contain organization detailsGiven I am authenticated as Super Admin
And a region exists with ID "{{region_id}}"
When I send a GET request to /api/v2/organizations?regionId={{region_id}}
Then the response status should be 200
And all organizations should belong to the specified regionGiven I am authenticated as Super Admin
When I send a GET request to /api/v2/iam/tenants
Then the response status should be 200
And the response should contain an array of tenantsGiven I am authenticated as Administrator
When I send a POST request to /api/v2/iam/tenants with:
| name | New Tenant |
| organizationId | {{organization_id}} |
Then the response status should be 201
And the response should contain the created tenantGiven I am authenticated as Developer
When I send a GET request to /api/v2/iam/workspaces
Then the response status should be 200
And the response should contain an array of workspacesGiven I am authenticated as Developer
When I send a POST request to /api/v2/iam/workspaces with:
| name | Development Workspace |
| tenantId | {{tenant_id}} |
Then the response status should be 201
And the response should contain the created workspaceGiven I am authenticated as Administrator
When I send a GET request to /api/v2/iam/groups
Then the response status should be 200
And the response should contain an array of groupsGiven I am authenticated as Administrator
When I send a POST request to /api/v2/iam/groups with:
| name | Engineering Team |
| description | Engineering group |
| organizationId | {{organization_id}} |
Then the response status should be 201
And the response should contain the created groupGiven I am authenticated as Administrator
And a group exists with ID "{{group_id}}"
And a user exists with ID "{{user_id}}"
When I send a POST request to /api/v2/iam/groups/{{group_id}}/users/{{user_id}}
Then the response status should be 200
And the user should be a member of the groupGiven I am authenticated as Administrator
And a group exists with ID "{{group_id}}"
And a user is a member of the group
When I send a DELETE request to /api/v2/iam/groups/{{group_id}}/users/{{user_id}}
Then the response status should be 200
And the user should no longer be a member of the groupGiven I am authenticated as Super Admin
When I send a GET request to /api/v2/iam/regions
Then the response status should be 200
And the response should contain at least 1 region
And each region should have code and nameGiven I am authenticated as Super Admin
And a region exists with ID "{{region_id}}"
When I send a GET request to /api/v2/iam/regions/{{region_id}}
Then the response status should be 200
And the response should contain region detailsGiven I am authenticated as Super Admin
When I send a GET request to /api/v2/audit/logs?limit=50&offset=0
Then the response status should be 200
And the response should contain an array of audit logs
And each log should have eventType, userId, timestampGiven I am authenticated as Super Admin
When I send a GET request to /api/v2/audit/logs?eventType=USER_CREATED
Then the response status should be 200
And all logs should have eventType "USER_CREATED"Given I am authenticated as Super Admin
When I send a GET request to /api/v2/audit/statistics
Then the response status should be 200
And the response should contain event counts by typeGiven I am authenticated as Super Admin
When I send a GET request to /api/v2/audit/export?format=csv
Then the response status should be 200
And the response should be in CSV format| Module | Scenarios | Requests | Coverage |
|---|---|---|---|
| Health | 2 | 4 | 100% |
| Users | 7 | 14 | 100% |
| Roles | 5 | 9 | 100% |
| Permissions | 2 | 3 | 100% |
| Organizations | 3 | 4 | 100% |
| Tenants | 2 | 3 | 100% |
| Workspaces | 2 | 3 | 100% |
| Groups | 4 | 8 | 100% |
| Regions | 2 | 3 | 100% |
| Audit | 4 | 5 | 100% |
| Total | 33 | 56 | 100% |
After running tests, reports are generated in docs/postman/reports/:
- HTML Report: Interactive dashboard with test results, response times, and assertions
- JSON Report: Machine-readable format for CI/CD integration
open docs/postman/reports/report-YYYYMMDD_HHMMSS.html- name: Run BDD Tests
run: |
bash docs/postman/run-bdd-tests.sh --bail
- name: Upload Test Reports
uses: actions/upload-artifact@v3
with:
name: test-reports
path: docs/postman/reports/test:
script:
- bash docs/postman/run-bdd-tests.sh --bail
artifacts:
paths:
- docs/postman/reports/
when: alwaysdocker-compose up -d backend
sleep 10
curl http://localhost:3000/healthnpm install -g newman newman-reporter-htmlextra# Run with verbose output
bash docs/postman/run-bdd-tests.sh --verbose
# Run specific folder
bash docs/postman/run-bdd-tests.sh --folder Users --verbose- Last Updated: 2025-12-03
- Total BDD Scenarios: 33
- API Coverage: 100%