- 
 
- 
  Notifications
 You must be signed in to change notification settings 
- Fork 1.5k
Add VirtualAuthenticator tests to Ruby examples #2429
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
Add VirtualAuthenticator tests to Ruby examples #2429
Conversation
* Adding these tests helps document how the Selenium library can be used with virtual authenticators
| 👷 Deploy request for selenium-dev pending review.Visit the deploys page to approve it 
 | 
PR Reviewer Guide 🔍
Here are some key observations to aid the review process:
Possible Assertion Mismatch
The test compares the stored credential's private key to the Base64-encoded string source, but the credential was created from decoded bytes. Verify whether credential.private_key returns Base64 or raw bytes and align the assertion accordingly.
credential.private_key returns Base64 or raw bytes and align the assertion accordingly.expect(credential_id).to eq(credential_list[0].id) expect(private_key).to eq(credential_list[0].private_key) end
Key Format/Algorithm
Credentials for WebAuthn/U2F/CTAP2 typically use EC (P-256) keys, not RSA. Using an RSA DER may not match expected private key format. Confirm that Selenium::WebDriver::Credential expects an EC key (PKCS#8 or raw) and adjust key generation/encoding.
Selenium::WebDriver::Credential expects an EC key (PKCS#8 or raw) and adjust key generation/encoding.let(:private_key) { Base64.strict_encode64(OpenSSL::PKey::RSA.generate(2048).private_to_der) }
Base64 Handling
The tests decode a Base64 string to bytes for creation but later expect Base64 on retrieval; ensure consistent encode/decode and consider using Base64.strict_encode64(credential.private_key_bytes) or comparing byte arrays directly.
Base64.strict_encode64(credential.private_key_bytes) or comparing byte arrays directly.decoded_private_key = Base64.strict_decode64(private_key).bytes resident_credential = Selenium::WebDriver::Credential.non_resident( id: credential_id, private_key: decoded_private_key, rp_id: "localhost"
| PR Code Suggestions ✨Explore these optional code suggestions: 
 | |||||||||||
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.
@tcannonfodder, could you please check the failures?
Uh oh!
There was an error while loading. Please reload this page.
User description
Description
Motivation and Context
Types of changes
Checklist
This is a new attempt of #1536, using the latest trunk
PR Type
Tests
Description
Add comprehensive VirtualAuthenticator test suite for Ruby
Test authenticator options configuration and JSON serialization
Test credential management (resident/non-resident keys)
Test protocol-specific behaviors (U2F vs CTAP2)
Diagram Walkthrough
File Walkthrough
virtual_authenticator_options_spec.rb
VirtualAuthenticatorOptions configuration testsexamples/ruby/spec/virtual_authenticator/virtual_authenticator_options_spec.rb
as_jsonmethodvirtual_authenticator_spec.rb
VirtualAuthenticator API comprehensive testsexamples/ruby/spec/virtual_authenticator/virtual_authenticator_spec.rb