Skip to content
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

[dotnet] [bidi] Decouple AuthCredentials in Network module #15491

Merged

Conversation

nvborisenko
Copy link
Member

@nvborisenko nvborisenko commented Mar 23, 2025

User description

Following spec: https://w3c.github.io/webdriver-bidi/#type-network-AuthCredentials

Motivation and Context

Contributes to #15407

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

PR Type

Enhancement, Tests


Description

  • Refactored AuthCredentials to a single record with properties.

  • Removed nested Basic record and added Type property.

  • Updated tests to use the new AuthCredentials structure.


Changes walkthrough 📝

Relevant files
Enhancement
AuthCredentials.cs
Refactor `AuthCredentials` to simplify structure                 

dotnet/src/webdriver/BiDi/Modules/Network/AuthCredentials.cs

  • Refactored AuthCredentials to a single record with Username and
    Password.
  • Removed nested Basic record.
  • Added Type property with a default value of "password".
  • +3/-4     
    Tests
    NetworkTest.cs
    Update tests for refactored `AuthCredentials`                       

    dotnet/test/common/BiDi/Network/NetworkTest.cs

  • Updated test to use the new AuthCredentials structure.
  • Replaced usage of AuthCredentials.Basic with AuthCredentials.
  • +1/-1     

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    🎫 Ticket compliance analysis ✅

    15407 - PR Code Verified

    Compliant requirements:

    • Don't use nested DTO types in the .NET implementation
    • Replace nested types with standalone types

    Requires further human verification:

    • Verify if all similar nested types in the codebase have been identified and refactored
    ⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Serialization Change

    The PR removes JsonPolymorphic and JsonDerivedType attributes which may affect serialization behavior. Verify that the new implementation correctly serializes to the expected JSON format required by the WebDriver BiDi protocol.

    public record AuthCredentials(string Username, string Password)
    {
        [JsonInclude]
        internal string Type { get; } = "password";
    }

    Copy link
    Contributor

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Add missing JSON property name

    The Type property should be marked with [JsonPropertyName("type")] to ensure it
    serializes correctly to match the expected "type" discriminator name in the
    JSON.

    dotnet/src/webdriver/BiDi/Modules/Network/AuthCredentials.cs [26-27]

     [JsonInclude]
    +[JsonPropertyName("type")]
     internal string Type { get; } = "password";
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    __

    Why: The suggestion correctly identifies that the "Type" property needs a [JsonPropertyName("type")] attribute to ensure it serializes to the expected JSON field name. This is important because the PR removed the [JsonPolymorphic] and [JsonDerivedType] attributes that previously handled the type discrimination.

    Medium
    • More

    @nvborisenko nvborisenko merged commit d92e71e into SeleniumHQ:trunk Mar 23, 2025
    10 checks passed
    @nvborisenko nvborisenko deleted the bidi-nested-authcredentials branch March 23, 2025 20:19
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants