Repository: square/okhttp
File: okhttp/src/jvmTest/java/okhttp3/CookieTest.kt (Kotlin)

Code before:
    assertThrows<IllegalArgumentException> {
      cookieBuilder.sameSite(" a").build()
    }
    assertThrows<IllegalArgumentException> {
      cookieBuilder.sameSite("a ").build()
    }
    assertThrows<IllegalArgumentException> {
      cookieBuilder.sameSite(" a ").build()
    }

    cookieBuilder.sameSite("a").build()
  }

  @ParameterizedTest(name = "{displayName}({arguments})")
  @ValueSource(strings = ["Lax", "Strict", "UnrecognizedButValid"])
  fun builderSameSite(sameSite: String) {
    val cookie = Cookie.Builder()
      .name("a")
      .value("b")
      .domain("example.com")
      .sameSite(sameSite)
      .build()
    assertThat(cookie.sameSite).isEqualTo(sameSite)
  }

  @Test fun builderSameSiteNoneRequiresSecure() {
    val cookieBuilder = Cookie.Builder()
      .name("a")
      .value("b")
      .domain("example.com")
      .sameSite("None")

    // assertThrows<IllegalArgumentException> {
    //   cookieBuilder.build()
    // }

    val cookie = cookieBuilder.secure().build()
    assertThat(cookie.sameSite).isEqualTo("None")
  }

  @Test fun equalsAndHashCode() {
    val cookieStrings = Arrays.asList(
      "a=b; Path=/c; Domain=example.com; Max-Age=5; Secure; HttpOnly",
      "a= ; Path=/c; Domain=example.com; Max-Age=5; Secure; HttpOnly",
      "a=b;          Domain=example.com; Max-Age=5; Secure; HttpOnly",
      "a=b; Path=/c;                     Max-Age=5; Secure; HttpOnly",
      "a=b; Path=/c; Domain=example.com;            Secure; HttpOnly",
      "a=b; Path=/c; Domain=example.com; Max-Age=5;         HttpOnly",
      "a=b; Path=/c; Domain=example.com; Max-Age=5; Secure;         ",
      "a=b; Path=/c; Domain=example.com; Max-Age=5; Secure; HttpOnly; SameSite=Lax",
      "a= ; Path=/c; Domain=example.com; Max-Age=5; Secure; HttpOnly; SameSite=Lax",

Review comment (suggestion):
```suggestion
    /** Note that we permit building a cookie that doesn’t follow the rules. */
    @Test fun builderSameSiteNoneDoesNotRequireSecure() {
```

Code after:
    assertThrows<IllegalArgumentException> {
      cookieBuilder.sameSite(" a").build()
    }
    assertThrows<IllegalArgumentException> {
      cookieBuilder.sameSite("a ").build()
    }
    assertThrows<IllegalArgumentException> {
      cookieBuilder.sameSite(" a ").build()
    }

    cookieBuilder.sameSite("a").build()
  }

  @ParameterizedTest(name = "{displayName}({arguments})")
  @ValueSource(strings = ["Lax", "Strict", "UnrecognizedButValid"])
  fun builderSameSite(sameSite: String) {
    val cookie = Cookie.Builder()
      .name("a")
      .value("b")
      .domain("example.com")
      .sameSite(sameSite)
      .build()
    assertThat(cookie.sameSite).isEqualTo(sameSite)
  }

    /** Note that we permit building a cookie that doesn’t follow the rules. */
    @Test fun builderSameSiteNoneDoesNotRequireSecure() {
    val cookieBuilder = Cookie.Builder()
      .name("a")
      .value("b")
      .domain("example.com")
      .sameSite("None")

    val cookie = cookieBuilder.build()
    assertThat(cookie.sameSite).isEqualTo("None")
  }

  @Test fun equalsAndHashCode() {
    val cookieStrings = Arrays.asList(
      "a=b; Path=/c; Domain=example.com; Max-Age=5; Secure; HttpOnly",
      "a= ; Path=/c; Domain=example.com; Max-Age=5; Secure; HttpOnly",
      "a=b;          Domain=example.com; Max-Age=5; Secure; HttpOnly",
      "a=b; Path=/c;                     Max-Age=5; Secure; HttpOnly",
      "a=b; Path=/c; Domain=example.com;            Secure; HttpOnly",
      "a=b; Path=/c; Domain=example.com; Max-Age=5;         HttpOnly",
      "a=b; Path=/c; Domain=example.com; Max-Age=5; Secure;         ",
      "a=b; Path=/c; Domain=example.com; Max-Age=5; Secure; HttpOnly; SameSite=Lax",
      "a= ; Path=/c; Domain=example.com; Max-Age=5; Secure; HttpOnly; SameSite=Lax",
      "a=b;          Domain=example.com; Max-Age=5; Secure; HttpOnly; SameSite=Lax",
      "a=b; Path=/c;                     Max-Age=5; Secure; HttpOnly; SameSite=Lax",
      "a=b; Path=/c; Domain=example.com;            Secure; HttpOnly; SameSite=Lax",