Skip to content

Add an non-CI integration test for KeyVault#615

Open
sprucely wants to merge 2 commits into
mainfrom
swe/KeyVaultIntegrationTest
Open

Add an non-CI integration test for KeyVault#615
sprucely wants to merge 2 commits into
mainfrom
swe/KeyVaultIntegrationTest

Conversation

@sprucely

@sprucely sprucely commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Documentation

    • Updated README with instructions for running optional Key Vault integration smoke tests via environment variable configuration
  • Tests

    • Added conditional integration smoke tests that validate Key Vault secret operations (write, read, and delete functionality)

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@sprucely, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 39 minutes and 23 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 21cc3f48-166b-4ad6-b500-7a4a4849529e

📥 Commits

Reviewing files that changed from the base of the PR and between e6368f8 and 064b145.

📒 Files selected for processing (1)
  • Test/KeyVaultSmokeTests.cs
📝 Walkthrough

Walkthrough

This PR introduces a conditional Azure Key Vault integration smoke test. The test project gains user secrets support via configuration; a new smoke test class writes, reads, and deletes Key Vault secrets when explicitly enabled; and documentation explains how to opt in to running the test.

Changes

Key Vault Smoke Test Feature

Layer / File(s) Summary
Project configuration for user secrets
Test/Test.csproj
Test project adds UserSecretsId property and Microsoft.Extensions.Configuration.UserSecrets package reference to enable .NET user secrets support.
Key Vault smoke test implementation
Test/KeyVaultSmokeTests.cs
Integration test class conditionally runs based on RUN_KEYVAULT_SMOKE_TESTS environment variable, loads Azure credentials from user secrets, instantiates SecretsService, writes a uniquely named secret, reads and asserts the value, then deletes the secret in a finally block. Helper method validates required settings (ClientId, ClientSecret, KeyVaultUrl) before test execution.
Integration test documentation
README.md
Documentation describes the opt-in Key Vault smoke test, the dotnet test command with RUN_KEYVAULT_SMOKE_TESTS=true environment variable, and clarifies the test skips Key Vault contact when the variable is not set.

Sequence Diagram

sequenceDiagram
  participant Test as KeyVaultSmokeTests
  participant Config as UserSecrets
  participant Service as SecretsService
  participant KeyVault as Azure Key Vault
  Test->>Config: Load AzureSettings from user secrets
  Config-->>Test: Return ClientId, ClientSecret, KeyVaultUrl
  Test->>Test: Validate required settings
  Test->>Service: Instantiate with Azure credentials
  Service->>KeyVault: Write secret with unique name
  KeyVault-->>Service: Secret created
  Service->>KeyVault: Read secret by name
  KeyVault-->>Service: Secret value returned
  Service-->>Test: Assert value matches
  Test->>KeyVault: Delete secret (finally block)
  KeyVault-->>Test: Secret deleted
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A new test hops through Key Vault gates,
Writing secrets, reading fates.
With user secrets tucked away,
This smoke test runs on special days!
🔐✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding an integration test for KeyVault that is non-CI (opt-in via environment variable).
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch swe/KeyVaultIntegrationTest

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
README.md (1)

38-40: ⚡ Quick win

Document shell-specific command variants for broader developer usability.

Line 39 is POSIX-style env assignment; it won’t run as-is in Windows cmd or PowerShell. Add shell-specific examples to reduce setup friction.

🤖 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 `@README.md` around lines 38 - 40, The README shows a POSIX-style env
assignment for the test command (RUN_KEYVAULT_SMOKE_TESTS=true dotnet test ...),
which won't work in Windows cmd/PowerShell; add equivalent Windows variants: a
cmd.exe form that uses setlocal && set RUN_KEYVAULT_SMOKE_TESTS=1 && dotnet test
... and a PowerShell form that uses $env:RUN_KEYVAULT_SMOKE_TESTS = 'true';
dotnet test ... (and mention reverting/unsetting if needed), so developers on
different shells can run the KeyVaultSmokeTests easily.
🤖 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 `@Test/KeyVaultSmokeTests.cs`:
- Around line 44-58: The cleanup is fragile because secretWasCreated can remain
false if SetSecret persisted remotely but threw; change the finally block to
always attempt to delete the secret (call DeleteSecret(secretName)) and swallow
only "not found" errors so legitimate missing secrets don't fail the test—i.e.,
remove the secretWasCreated guard and wrap await
secretsService.DeleteSecret(secretName) in its own try/catch that ignores
not-found exceptions (but surfaces other errors); reference SetSecret,
GetSecret, DeleteSecret and the secretWasCreated flag when making the change.

---

Nitpick comments:
In `@README.md`:
- Around line 38-40: The README shows a POSIX-style env assignment for the test
command (RUN_KEYVAULT_SMOKE_TESTS=true dotnet test ...), which won't work in
Windows cmd/PowerShell; add equivalent Windows variants: a cmd.exe form that
uses setlocal && set RUN_KEYVAULT_SMOKE_TESTS=1 && dotnet test ... and a
PowerShell form that uses $env:RUN_KEYVAULT_SMOKE_TESTS = 'true'; dotnet test
... (and mention reverting/unsetting if needed), so developers on different
shells can run the KeyVaultSmokeTests easily.
🪄 Autofix (Beta)

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: defaults

Review profile: CHILL

Plan: Pro

Run ID: fb4ac8ae-bdeb-4db0-ab9f-1377fd5e1d18

📥 Commits

Reviewing files that changed from the base of the PR and between 0f117bf and e6368f8.

📒 Files selected for processing (3)
  • README.md
  • Test/KeyVaultSmokeTests.cs
  • Test/Test.csproj

Comment thread Test/KeyVaultSmokeTests.cs
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.

1 participant