[rb] Fix credential issue with private key#17188
[rb] Fix credential issue with private key#17188aguspe wants to merge 3 commits intoSeleniumHQ:trunkfrom
Conversation
This commit fix the bug SeleniumHQ#16916 where the type of private key is wrong, I also updated the test
Review Summary by QodoFix private key decoding in credential from_json method
WalkthroughsDescription• Fix private key type handling in credential deserialization • Decode base64-encoded private key from JSON input • Update test expectations to match decoded value File Changes1. rb/lib/selenium/webdriver/common/virtual_authenticator/credential.rb
|
Code Review by Qodo
1. Non-defensive privateKey decode
|
There was a problem hiding this comment.
Pull request overview
This PR fixes Ruby Virtual Authenticator credential deserialization so Credential#private_key is returned as a byte array (as expected by Credential.encode and by callers), aligning behavior with how credentials are serialized and with the reported issue.
Changes:
- Decode
privateKeyinCredential.from_jsonso the in-memory type is anArray<Integer>(bytes) rather than a Base64 string. - Update the unit spec to assert the decoded
private_keyvalue.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
rb/lib/selenium/webdriver/common/virtual_authenticator/credential.rb |
Fixes deserialization by decoding privateKey when constructing a Credential from JSON. |
rb/spec/unit/selenium/webdriver/common/credentials_spec.rb |
Updates expectation to match the corrected private_key type returned by from_json. |
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
You can also share your feedback on Copilot code review. Take the survey.
| expect(credential.rp_id).to eq('localhost') | ||
| expect(credential.user_handle).to eq(user_handle) | ||
| expect(credential.private_key).to eq(base64_encoded_pk) | ||
| expect(credential.private_key).to eq(described_class.decode(base64_encoded_pk)) |
There was a problem hiding this comment.
This expectation re-decodes base64_encoded_pk inline even though the spec already defines let(:private_key) { described_class.decode(base64_encoded_pk) }. Reusing private_key here would avoid duplication and keep the test aligned with the other examples in this file.
| expect(credential.private_key).to eq(described_class.decode(base64_encoded_pk)) | |
| expect(credential.private_key).to eq(private_key) |
🔗 Related Issues
#16916
💥 What does this PR do?
This commit fix the bug #16916 where the type of private key is wrong, I also updated the test
🔧 Implementation Notes
I did it this way because the actual type should be an array of bytes, not a string
🔄 Types of changes