Conversation
… coverage - Change CryptoRandomBytes parameter type from int64 to int, removing unnecessary casts at call sites - Migrate context_test.go and url_test.go to use testify assertions for consistency - Add edge case tests for zero length, odd length, empty token/salt, and invalid URLs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors internal/util.CryptoRandomBytes to accept an int length (aligning with Go slice sizing) and expands/standardizes internal/util tests (testify assert/require) to improve coverage around crypto helpers and redirect URL safety.
Changes:
- Change
CryptoRandomBytessignature fromint64→intand update call sites. - Migrate util tests to testify
assert/requirestyle for consistency. - Add edge-case tests for crypto helpers and
IsRedirectSafe(including invalid URLs and non-http schemes).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/util/crypto.go | Simplifies CryptoRandomBytes signature and removes unnecessary casts in util crypto helpers. |
| internal/store/sqlite.go | Updates password generation to use new CryptoRandomBytes(int) signature. |
| internal/handlers/oauth_handler.go | Updates OAuth state generation to use new CryptoRandomBytes(int) signature. |
| internal/util/crypto_test.go | Adds edge-case coverage for random bytes/strings and HashToken. |
| internal/util/context_test.go | Converts tests to testify assertions for consistency. |
| internal/util/url_test.go | Adds redirect safety edge cases and converts to testify assertions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CryptoRandomBytesparameter type fromint64toint, removing unnecessary casts at all call sites (oauth_handler.go,sqlite.go)context_test.goandurl_test.gofrom rawt.Errorf/t.Fatalto testifyassert/requirefor consistency with codebase conventionHashToken, invalid/unparseable URLs and non-http schemes forIsRedirectSafeinternal/util/improved from 92.3% to 97.4%Test plan
go build ./...compiles successfullygo test ./internal/util/ -v— all tests passIsRedirectSafe90.9% → 100%, overall 92.3% → 97.4%🤖 Generated with Claude Code