test: add e2e tests for virtual key budget override set/remove - #6017
Conversation
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe Postman collection captures virtual-key budget data and tests setting and removing a permanent ChangesVirtual-key budget override testing
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/e2e/api/collections/bifrost-api-management.postman_collection.json`:
- Around line 1941-1948: Set the Postman collection defaults for vk_id,
vk_budget_id, and vk_budget_max_limit to empty values, and update both
prerequest scripts to require all three variables before sending lifecycle
requests. Preserve the existing skip behavior when budget capture does not run
or fails, preventing override calls with placeholder data.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 41d4b18b-f3fe-4c59-b361-7f231160b844
📒 Files selected for processing (1)
tests/e2e/api/collections/bifrost-api-management.postman_collection.json
7983237 to
ad97b5a
Compare
4ef9e2f to
da4482a
Compare
ad97b5a to
8a5147f
Compare
4ef9e2f to
da4482a
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tests/e2e/api/collections/collection-scripts.test.mjs (1)
1-3: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winAdd
node tests/e2e/api/collections/collection-scripts.test.mjsto a CI API test step. Current API workflows invoke Newman runners only, so this standalone test does not run before merge.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/e2e/api/collections/collection-scripts.test.mjs` around lines 1 - 3, Update the CI API test workflow to add a step that executes collection-scripts.test.mjs with Node before merge, alongside the existing Newman API runners. Preserve the standalone command and ensure the step runs in the tests/e2e/api/collections context or references the correct script path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/e2e/api/collections/collection-scripts.test.mjs`:
- Around line 260-266: Update the test case “Set Virtual Key Budget Override
still builds its request body” to assert the raw serialized request body from
ctx.pm.request.body.raw, including the required "amount" then "mode" field
order, instead of parsing it with JSON.parse. Keep the existing variable
assertion unchanged.
---
Outside diff comments:
In `@tests/e2e/api/collections/collection-scripts.test.mjs`:
- Around line 1-3: Update the CI API test workflow to add a step that executes
collection-scripts.test.mjs with Node before merge, alongside the existing
Newman API runners. Preserve the standalone command and ensure the step runs in
the tests/e2e/api/collections context or references the correct script path.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 6e18d71c-3304-41b0-8092-7425d07c69e9
📒 Files selected for processing (2)
tests/e2e/api/collections/bifrost-api-management.postman_collection.jsontests/e2e/api/collections/collection-scripts.test.mjs
🚧 Files skipped from review as they are similar to previous changes (1)
- tests/e2e/api/collections/bifrost-api-management.postman_collection.json
da4482a to
8b37c78
Compare
3f10187 to
943dbee
Compare
8b37c78 to
0953e1d
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
Merge activity
|
The base branch was changed.
0953e1d to
e17e47a
Compare
## Summary
Adds end-to-end API tests for the virtual key budget override endpoints, covering both applying and removing a budget override on a virtual key.
## Changes
- Added `vk_budget_id` and `vk_budget_max_limit` as collection variables, populated dynamically from the first budget returned when fetching a virtual key.
- Added a **Set Virtual Key Budget Override** test (`PUT /api/governance/virtual-keys/{vk_id}/budgets/{vk_budget_id}/override`) that applies an override of `7.5` with mode `forever` and asserts the response contains the correct `override_mode`, `override_amount`, and that the `effective_max_limit` is raised above the base budget.
- Added a **Remove Virtual Key Budget Override** test (`DELETE /api/governance/virtual-keys/{vk_id}/budgets/{vk_budget_id}/override`) that clears the override and asserts `override_mode` and `override_amount` are empty/zero, and that `effective_max_limit` falls back to the original base budget value.
## Type of change
- [ ] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Documentation
- [x] Chore/CI
## Affected areas
- [ ] Core (Go)
- [x] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [ ] UI (React)
- [ ] Docs
## How to test
Run the Postman collection against a running Bifrost instance:
```sh
newman run tests/e2e/api/collections/bifrost-api-management.postman_collection.json \
--env-var base_url=http://localhost:8080
```
The **Set Virtual Key Budget Override** and **Remove Virtual Key Budget Override** requests will execute after the virtual key fetch step, which populates `vk_budget_id` and `vk_budget_max_limit`. Both requests will be skipped automatically if no budget ID is available.
## Breaking changes
- [ ] Yes
- [x] No
## Related issues
## Security considerations
No security implications. Tests exercise existing governance endpoints using collection-scoped variables only.
## Checklist
- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [x] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
## Summary
Adds end-to-end API tests for the virtual key budget override endpoints, covering both applying and removing a budget override on a virtual key.
## Changes
- Added `vk_budget_id` and `vk_budget_max_limit` as collection variables, populated dynamically from the first budget returned when fetching a virtual key.
- Added a **Set Virtual Key Budget Override** test (`PUT /api/governance/virtual-keys/{vk_id}/budgets/{vk_budget_id}/override`) that applies an override of `7.5` with mode `forever` and asserts the response contains the correct `override_mode`, `override_amount`, and that the `effective_max_limit` is raised above the base budget.
- Added a **Remove Virtual Key Budget Override** test (`DELETE /api/governance/virtual-keys/{vk_id}/budgets/{vk_budget_id}/override`) that clears the override and asserts `override_mode` and `override_amount` are empty/zero, and that `effective_max_limit` falls back to the original base budget value.
## Type of change
- [ ] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Documentation
- [x] Chore/CI
## Affected areas
- [ ] Core (Go)
- [x] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [ ] UI (React)
- [ ] Docs
## How to test
Run the Postman collection against a running Bifrost instance:
```sh
newman run tests/e2e/api/collections/bifrost-api-management.postman_collection.json \
--env-var base_url=http://localhost:8080
```
The **Set Virtual Key Budget Override** and **Remove Virtual Key Budget Override** requests will execute after the virtual key fetch step, which populates `vk_budget_id` and `vk_budget_max_limit`. Both requests will be skipped automatically if no budget ID is available.
## Breaking changes
- [ ] Yes
- [x] No
## Related issues
## Security considerations
No security implications. Tests exercise existing governance endpoints using collection-scoped variables only.
## Checklist
- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [x] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
## Summary
Adds end-to-end API tests for the virtual key budget override endpoints, covering both applying and removing a budget override on a virtual key.
## Changes
- Added `vk_budget_id` and `vk_budget_max_limit` as collection variables, populated dynamically from the first budget returned when fetching a virtual key.
- Added a **Set Virtual Key Budget Override** test (`PUT /api/governance/virtual-keys/{vk_id}/budgets/{vk_budget_id}/override`) that applies an override of `7.5` with mode `forever` and asserts the response contains the correct `override_mode`, `override_amount`, and that the `effective_max_limit` is raised above the base budget.
- Added a **Remove Virtual Key Budget Override** test (`DELETE /api/governance/virtual-keys/{vk_id}/budgets/{vk_budget_id}/override`) that clears the override and asserts `override_mode` and `override_amount` are empty/zero, and that `effective_max_limit` falls back to the original base budget value.
## Type of change
- [ ] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Documentation
- [x] Chore/CI
## Affected areas
- [ ] Core (Go)
- [x] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [ ] UI (React)
- [ ] Docs
## How to test
Run the Postman collection against a running Bifrost instance:
```sh
newman run tests/e2e/api/collections/bifrost-api-management.postman_collection.json \
--env-var base_url=http://localhost:8080
```
The **Set Virtual Key Budget Override** and **Remove Virtual Key Budget Override** requests will execute after the virtual key fetch step, which populates `vk_budget_id` and `vk_budget_max_limit`. Both requests will be skipped automatically if no budget ID is available.
## Breaking changes
- [ ] Yes
- [x] No
## Related issues
## Security considerations
No security implications. Tests exercise existing governance endpoints using collection-scoped variables only.
## Checklist
- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [x] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
## Summary
Adds end-to-end API tests for the virtual key budget override endpoints, covering both applying and removing a budget override on a virtual key.
## Changes
- Added `vk_budget_id` and `vk_budget_max_limit` as collection variables, populated dynamically from the first budget returned when fetching a virtual key.
- Added a **Set Virtual Key Budget Override** test (`PUT /api/governance/virtual-keys/{vk_id}/budgets/{vk_budget_id}/override`) that applies an override of `7.5` with mode `forever` and asserts the response contains the correct `override_mode`, `override_amount`, and that the `effective_max_limit` is raised above the base budget.
- Added a **Remove Virtual Key Budget Override** test (`DELETE /api/governance/virtual-keys/{vk_id}/budgets/{vk_budget_id}/override`) that clears the override and asserts `override_mode` and `override_amount` are empty/zero, and that `effective_max_limit` falls back to the original base budget value.
## Type of change
- [ ] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Documentation
- [x] Chore/CI
## Affected areas
- [ ] Core (Go)
- [x] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [ ] UI (React)
- [ ] Docs
## How to test
Run the Postman collection against a running Bifrost instance:
```sh
newman run tests/e2e/api/collections/bifrost-api-management.postman_collection.json \
--env-var base_url=http://localhost:8080
```
The **Set Virtual Key Budget Override** and **Remove Virtual Key Budget Override** requests will execute after the virtual key fetch step, which populates `vk_budget_id` and `vk_budget_max_limit`. Both requests will be skipped automatically if no budget ID is available.
## Breaking changes
- [ ] Yes
- [x] No
## Related issues
## Security considerations
No security implications. Tests exercise existing governance endpoints using collection-scoped variables only.
## Checklist
- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [x] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable

Summary
Adds end-to-end API tests for the virtual key budget override endpoints, covering both applying and removing a budget override on a virtual key.
Changes
vk_budget_idandvk_budget_max_limitas collection variables, populated dynamically from the first budget returned when fetching a virtual key.PUT /api/governance/virtual-keys/{vk_id}/budgets/{vk_budget_id}/override) that applies an override of7.5with modeforeverand asserts the response contains the correctoverride_mode,override_amount, and that theeffective_max_limitis raised above the base budget.DELETE /api/governance/virtual-keys/{vk_id}/budgets/{vk_budget_id}/override) that clears the override and assertsoverride_modeandoverride_amountare empty/zero, and thateffective_max_limitfalls back to the original base budget value.Type of change
Affected areas
How to test
Run the Postman collection against a running Bifrost instance:
The Set Virtual Key Budget Override and Remove Virtual Key Budget Override requests will execute after the virtual key fetch step, which populates
vk_budget_idandvk_budget_max_limit. Both requests will be skipped automatically if no budget ID is available.Breaking changes
Related issues
Security considerations
No security implications. Tests exercise existing governance endpoints using collection-scoped variables only.
Checklist
docs/contributing/README.mdand followed the guidelines