test(security): cover credential auto-lock session purge#860
test(security): cover credential auto-lock session purge#860bhavyajain0810 wants to merge 1 commit into
Conversation
🚀 Thank You for Contributing to Late-MeetPlease ensure that:
Thank you for contributing 💙 |
|
👋 Thank you @bhavyajain0810 for your contribution to Late-Meet! ✅ Verified: You are assigned to the linked issue #654. Please review any automated suggestions or code review comments that may appear below! We will review your PR as soon as possible! Please consider starring the repository ⭐ to show your support! |
|
Warning Review limit reached
Next review available in: 38 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThree new test cases are added to the credentials test suite validating that locking credentials or triggering inactivity auto-lock purges plaintext API keys from session storage and updates unlocked state, plus a test confirming credential access refreshes the inactivity lock timer. ChangesCredential lock and auto-lock test coverage
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/utils/credentials.test.ts (1)
312-342: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winConsider verifying the auto-lock delay argument.
The test correctly verifies that
getApiCredentials()triggers timer rescheduling, but it doesn't capture thedelayargument passed tosetTimeout. Issue#654specifies a 30-minute inactivity timeout. Capturing and asserting the delay would strengthen the regression coverage for that requirement.♻️ Optional: capture and assert the auto-lock delay
test("credential access refreshes the inactivity lock timer", async () => { const originalSetTimeout = globalThis.setTimeout; const originalClearTimeout = globalThis.clearTimeout; let setTimeoutCalls = 0; let clearTimeoutCalls = 0; + let lastDelay: number | undefined; - (globalThis as any).setTimeout = () => { + (globalThis as any).setTimeout = (_cb: () => void, delay?: number) => { setTimeoutCalls += 1; + lastDelay = delay; return setTimeoutCalls; };Then add an assertion after
unlockCredentials:await unlockCredentials("test-passphrase"); assert.equal(setTimeoutCalls, 1); + assert.equal(lastDelay, 30 * 60 * 1000);🤖 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 `@src/utils/credentials.test.ts` around lines 312 - 342, The inactivity-lock test in getApiCredentials()/unlockCredentials() verifies timer rescheduling but not the actual timeout value. Update the test to capture the delay argument passed to the mocked globalThis.setTimeout and assert it matches the expected 30-minute auto-lock interval, while keeping the existing checks for rescheduling and clearTimeout behavior.
🤖 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.
Nitpick comments:
In `@src/utils/credentials.test.ts`:
- Around line 312-342: The inactivity-lock test in
getApiCredentials()/unlockCredentials() verifies timer rescheduling but not the
actual timeout value. Update the test to capture the delay argument passed to
the mocked globalThis.setTimeout and assert it matches the expected 30-minute
auto-lock interval, while keeping the existing checks for rescheduling and
clearTimeout behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0f5abf4d-b440-49f8-94a8-2c13c4425538
📒 Files selected for processing (1)
src/utils/credentials.test.ts
48da75a to
500a314
Compare
|
|
Hi @shouri123, Current validation:
The PR #860 is now only waiting for maintainer/code owner review. Thank you! |
|
This PR has been marked as stale due to inactivity. |
|
Hi @shouri123 , |



Description
Fixes #654
This PR adds regression coverage for credential auto-lock security behavior.
The tests verify that plaintext API credentials stored in
chrome.storage.sessionare purged when the credential vault is locked, including both manual lock and inactivity auto-lock flows. It also verifies that credential access refreshes the inactivity timer, so the auto-lock behavior is based on actual inactivity.This strengthens the security guarantee that decrypted API keys do not remain available in session storage after the vault is locked.
Type of Change
Security impact
chrome.storage.sessionValidation
git diff --check→ passednpm test -- src/utils/credentials.test.ts→ passednpx tsx --test src/utils/credentials.test.ts→ passedChecklist:
Summary by CodeRabbit