robolectric/robolectric

Investigate the better completed backend for RoboCookieManager

Open

#6,568 opened on Jun 24, 2021

View on GitHub
 (2 comments) (0 reactions) (0 assignees)Java (1,356 forks)batch import
help wanted

Repository metrics

Stars
 (5,755 stars)
PR merge metrics
 (Avg merge 16h 48m) (64 merged PRs in 30d)

Description

Description

As we discussed at https://github.com/robolectric/robolectric/pull/6517, RoboCookieManager supports partial cookie header, not completed now. I have shown some potential backend for RoboCookieManager at comment https://github.com/robolectric/robolectric/pull/6517#issuecomment-860077886, including JDK's HttpCookie and java-cookie. This issue is created to track the progress or thoughts about the better completed backend for RoboCookieManager.

Steps to Reproduce

There is a simple test that succeeds on official emulator, but fails on Robolectric:

  @Test
  public void setCookie_shouldReturnsNullForNonEqualsURL() {
    final String httpsUrl = "https://robolectric.org/";
    final CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.setCookie(httpsUrl, "ID=test-id; path=/some/path; domain=.other.org");
    String cookie = cookieManager.getCookie(httpsUrl);
    assertThat(cookie).isNull();
  }

CTS' CookieManagerTest has more completed test cases for cookie header.

Robolectric & Android Version

All

Link to a public git repo demonstrating the problem:

None

Contributor guide