-
Notifications
You must be signed in to change notification settings - Fork 98
test(protocol): add test cases to authenticator_test #423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test(protocol): add test cases to authenticator_test #423
Conversation
Change-Id: Ie3459891e5ee08ceffc8d0939cbe60e2ecde3333
…errors Change-Id: I6a146c9114550fa6bad9e3376602f3fd06fa0270
WalkthroughThe changes update error message formatting in the Changes
Poem
Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. ✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (5)
protocol/authenticator.go (2)
400-401
: Avoid unnecessaryfmt.Sprintf
call for constant string
fmt.Sprintf
is only useful when you need string interpolation.
Here we interpolate nothing, so the extra allocation is wasted.- return ErrVerification.WithInfo(fmt.Sprintf("User presence flag not set by authenticator")) + return ErrVerification.WithInfo("User presence flag not set by authenticator")
407-408
: Same optimisation opportunity as above- return ErrVerification.WithInfo(fmt.Sprintf("User verification required but flag not set by authenticator")) + return ErrVerification.WithInfo("User verification required but flag not set by authenticator")protocol/authenticator_test.go (3)
206-237
: Duplicate test-case name makes failures harder to traceTwo separate scenarios are both labelled
"Attested credential missing"
.
When a failure is reported it will be ambiguous which branch failed.- { - name: "Attested credential missing", + { + name: "Attested credential data flag missing",(or pick any distinctive wording)
262-283
: Consider running table-driven sub-tests in parallelThese sub-tests are independent and fairly compute-heavy (base64 decode + validation).
Addingt.Parallel()
at the beginning of eacht.Run
body reduces overall test time without side-effects.t.Run(tt.name, func(t *testing.T) { t.Parallel() // safe: test cases share no mutable state a := &AuthenticatorData{ ... } ... })
373-393
: Same parallelisation opportunity forunmarshalAttestedData
testsFor symmetry and faster CI, add
t.Parallel()
here as well.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
protocol/authenticator.go
(1 hunks)protocol/authenticator_test.go
(7 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
protocol/authenticator.go (1)
protocol/errors.go (1)
ErrVerification
(63-66)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks! Also for future reference I'm slowly renaming all subtests to use CamelCase and no spaces and use the name
value to specify the full subtest name. This makes them easy to target withgo test
.
Hi @james-d-elliott, just to clarify, the plan is to rename something like
|
Mostly correct. I can be very specific. I'm not very precious about this because I can just fix it later, I have a lot of tests to improve in this module. General Rules:
Test Function Name Format:
Test Function Name Examples:
Sub-test Rules:
Example: https://github.com/go-webauthn/webauthn/blob/master/webauthn/login_test.go#L33-L135 |
Add test cases for
AuthenticatorData
's functionsErrVerification
to be consistent with other errors