You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here are some key observations to aid the review process:
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review
Parameter Validation The RemoveVirtualAuthenticator method takes an authenticatorId parameter but ignores it, using this.AuthenticatorId instead. This could lead to removing the wrong authenticator if the parameter value differs.
Null Check Methods using AuthenticatorId property should validate that it's not null before using it. Otherwise, operations could fail with NullReferenceException.
public void AddCredential(Credential credential)
{
+ if (this.AuthenticatorId == null)+ throw new InvalidOperationException("No active authenticator. Call AddVirtualAuthenticator first.");
Dictionary<string, object> parameters = new Dictionary<string, object>(credential.ToDictionary());
parameters.Add("authenticatorId", this.AuthenticatorId);
this.Execute(driverCommandToExecute: DriverCommand.AddCredential, parameters);
}
Apply this suggestion
Suggestion importance[1-10]: 9
Why: This is a critical defensive programming suggestion that would prevent runtime errors by validating the authenticator state before operations. The improved error message would help developers identify the root cause quickly.
9
General
Remove unused parameter that is inconsistent with the method implementation
The RemoveVirtualAuthenticator method ignores its authenticatorId parameter and uses the instance's AuthenticatorId property instead. Either remove the unused parameter or use the provided parameter value.
Why: The method's parameter is misleading as it's never used, which could cause confusion and maintenance issues. The suggestion correctly identifies a design inconsistency that should be fixed for better API clarity.
RemoveVirtualAuthenticator does not even use its parameter
There's no validation to make sure a virtual authenticator is in place (unhelpful exception message)
I want to fix these, but I don't want this to become a singular "improve virtual authenticator" PR. This PR fixes a bug, and a follow-up PR can improve anything else that could use improvement.
Funny. The one test I changed for this, is the only one passing.
This is because the test teardown removes the VA, an operation which is guarded by webDriver.AuthenticatorId != null and only now has begun to work. Let me fix this.
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
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.
User description
Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it
Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.
Description
This fixes the
WebDriver.AuthenticatorIdID to reflect the currently active authenticator ID.Motivation and Context
The property is currently completely broken, returning
nullexclusively. Another victim of the non-auto property typo.Types of changes
Checklist
PR Type
Bug fix, Tests
Description
WebDriver.AuthenticatorIdto correctly reflect the active authenticator ID by replacing the field with a property.WebDriverto use the newAuthenticatorIdproperty.VirtualAuthenticatorTestto verify thatAuthenticatorIdis set correctly and is null after removal.Changes walkthrough 📝
WebDriver.cs
Fix and refactor `AuthenticatorId` handling in WebDriverdotnet/src/webdriver/WebDriver.cs
authenticatorIdfield with a propertyAuthenticatorId.AuthenticatorIdproperty.AuthenticatorIdis set and retrieved correctly.VirtualAuthenticatorTest.cs
Add test for `AuthenticatorId` functionality in WebDriverdotnet/test/common/VirtualAuthn/VirtualAuthenticatorTest.cs
AuthenticatorIdis set correctly.