Skip to content

test: add e2e tests for virtual key budget override set/remove - #6017

Merged
akshaydeo merged 1 commit into
devfrom
08-10-feat_adds_missing_endpoints_from_e2e_api_test_suite
Aug 11, 2026
Merged

test: add e2e tests for virtual key budget override set/remove#6017
akshaydeo merged 1 commit into
devfrom
08-10-feat_adds_missing_endpoints_from_e2e_api_test_suite

Conversation

@impoiler

@impoiler impoiler commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

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
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (React)
  • Docs

How to test

Run the Postman collection against a running Bifrost instance:

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
  • 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
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • Tests
    • Added end-to-end coverage for setting and removing virtual-key budget overrides.
    • Added validation for override values and effective budget limits.
    • Added safeguards to skip tests when required setup data is unavailable.
    • Added coverage for default budget variables and request payload construction.

Walkthrough

The Postman collection captures virtual-key budget data and tests setting and removing a permanent 7.5 override. Script tests cover missing-variable skips, request construction, and override capture.

Changes

Virtual-key budget override testing

Layer / File(s) Summary
Budget setup and capture
tests/e2e/api/collections/bifrost-api-management.postman_collection.json, tests/e2e/api/collections/collection-scripts.test.mjs
Adds budget variables, captures the created budget ID and base maximum limit, and validates empty defaults.
Override lifecycle requests
tests/e2e/api/collections/bifrost-api-management.postman_collection.json
Adds PUT and DELETE requests for a permanent 7.5 override. Assertions verify override and effective-limit values before and after removal.
Prerequest validation
tests/e2e/api/collections/collection-scripts.test.mjs
Verifies skip behavior when setup values are missing and validates request-body construction when values are present.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: akshaydeo, sammaji

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the addition of end-to-end tests for setting and removing virtual key budget overrides.
Description check ✅ Passed The description covers the purpose, changes, test command, affected area, breaking changes, security, and checklist items adequately.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 08-10-feat_adds_missing_endpoints_from_e2e_api_test_suite

Comment @coderabbitai help to get the list of available commands.

@impoiler impoiler self-assigned this Aug 10, 2026
@impoiler impoiler changed the title feat: adds missing endpoints from e2e api test suite test: add e2e tests for virtual key budget override set/remove Aug 10, 2026
@impoiler
impoiler marked this pull request as ready for review August 10, 2026 12:44
@coderabbitai
coderabbitai Bot requested review from akshaydeo and sammaji August 10, 2026 12:45

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7983237 and 95a8698.

📒 Files selected for processing (1)
  • tests/e2e/api/collections/bifrost-api-management.postman_collection.json

@impoiler
impoiler force-pushed the 07-29-refactor_api_structure branch from 7983237 to ad97b5a Compare August 10, 2026 12:48
@impoiler
impoiler force-pushed the 08-10-feat_adds_missing_endpoints_from_e2e_api_test_suite branch 2 times, most recently from 4ef9e2f to da4482a Compare August 10, 2026 13:29
@impoiler
impoiler force-pushed the 07-29-refactor_api_structure branch from ad97b5a to 8a5147f Compare August 10, 2026 13:29
@impoiler
impoiler force-pushed the 08-10-feat_adds_missing_endpoints_from_e2e_api_test_suite branch from 4ef9e2f to da4482a Compare August 10, 2026 13:29

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Add node tests/e2e/api/collections/collection-scripts.test.mjs to 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

📥 Commits

Reviewing files that changed from the base of the PR and between 4ef9e2f and da4482a.

📒 Files selected for processing (2)
  • tests/e2e/api/collections/bifrost-api-management.postman_collection.json
  • tests/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

Comment thread tests/e2e/api/collections/collection-scripts.test.mjs
coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 10, 2026
@impoiler
impoiler force-pushed the 08-10-feat_adds_missing_endpoints_from_e2e_api_test_suite branch from da4482a to 8b37c78 Compare August 10, 2026 17:51
@impoiler
impoiler force-pushed the 07-29-refactor_api_structure branch 2 times, most recently from 3f10187 to 943dbee Compare August 11, 2026 04:20
@impoiler
impoiler force-pushed the 08-10-feat_adds_missing_endpoints_from_e2e_api_test_suite branch from 8b37c78 to 0953e1d Compare August 11, 2026 04:20
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

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.

akshaydeo commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Merge activity

  • Aug 11, 7:01 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Aug 11, 7:10 AM UTC: Graphite rebased this pull request as part of a merge.
  • Aug 11, 7:11 AM UTC: @akshaydeo merged this pull request with Graphite.

@akshaydeo
akshaydeo changed the base branch from 07-29-refactor_api_structure to graphite-base/6017 August 11, 2026 07:06
@akshaydeo
akshaydeo changed the base branch from graphite-base/6017 to dev August 11, 2026 07:08
@akshaydeo
akshaydeo dismissed coderabbitai[bot]’s stale review August 11, 2026 07:08

The base branch was changed.

@akshaydeo
akshaydeo requested a review from a team as a code owner August 11, 2026 07:08
@akshaydeo
akshaydeo force-pushed the 08-10-feat_adds_missing_endpoints_from_e2e_api_test_suite branch from 0953e1d to e17e47a Compare August 11, 2026 07:09
@akshaydeo
akshaydeo merged commit 0f8eea3 into dev Aug 11, 2026
15 checks passed
@akshaydeo
akshaydeo deleted the 08-10-feat_adds_missing_endpoints_from_e2e_api_test_suite branch August 11, 2026 07:11
akshaydeo pushed a commit that referenced this pull request Aug 13, 2026
## 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
akshaydeo pushed a commit that referenced this pull request Aug 13, 2026
## 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
akshaydeo pushed a commit that referenced this pull request Aug 14, 2026
## 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
akshaydeo pushed a commit that referenced this pull request Aug 19, 2026
## 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants