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

[py] remove xfail_remote for cookie test #14995

Merged
merged 5 commits into from
Jan 2, 2025

Conversation

Delta456
Copy link
Contributor

@Delta456 Delta456 commented Dec 31, 2024

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

Removes @pytest.mark.xfail_remote from cookie tests as it asserts now

Motivation and Context

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

Bug fix


Description

  • Removed xfail_remote markers from three cookie-related test functions as they now pass in remote execution:
    • test_add_cookie_same_site_strict
    • test_add_cookie_same_site_lax
    • test_add_cookie_same_site_none
  • These tests verify the proper handling of sameSite cookie attributes, which was previously not implemented in remote execution

Changes walkthrough 📝

Relevant files
Tests
cookie_tests.py
Enable previously skipped sameSite cookie tests                   

py/test/selenium/webdriver/common/cookie_tests.py

  • Removed @pytest.mark.xfail_remote decorators from three cookie-related
    test functions
  • Tests for sameSite cookie attributes (Strict, Lax, None) are now
    expected to pass in remote execution
  • +0/-3     

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Test Coverage

    The test_add_cookie_same_site_none function should validate the actual sameSite=None attribute value, similar to how the Strict and Lax tests do. Currently it only checks if the cookie can be set.

    def test_add_cookie_same_site_none(same_site_cookie_none, driver):
        driver.add_cookie(same_site_cookie_none)
        # Note that insecure sites (http:) can't set cookies with the Secure directive.
        # driver.get_cookie would return None

    Copy link
    Contributor

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Add proper assertion handling for SameSite=None cookies considering secure/insecure contexts

    Add an assertion to verify that the cookie was actually set when sameSite is None,
    as the comment suggests it might return None for insecure sites.

    py/test/selenium/webdriver/common/cookie_tests.py [95-98]

     def test_add_cookie_same_site_none(same_site_cookie_none, driver):
         driver.add_cookie(same_site_cookie_none)
         # Note that insecure sites (http:) can't set cookies with the Secure directive.
    -    # driver.get_cookie would return None
    +    returned = driver.get_cookie("foo")
    +    if returned is not None:
    +        assert "sameSite" in returned and returned["sameSite"] == "None"
    • Apply this suggestion
    Suggestion importance[1-10]: 9

    Why: The suggestion addresses a critical gap in test coverage by adding proper assertions for SameSite=None cookies, handling both secure and insecure contexts. This is particularly important as the test currently lacks any verification logic despite having a known edge case with insecure sites.

    9

    @diemol diemol merged commit 513c221 into SeleniumHQ:trunk Jan 2, 2025
    1 check passed
    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