I'm trying to assert that the SameSite attribute is being set correctly using the MockMvcWebTestClient but I noticed that it wasn't being populated correctly.

https://github.com/spring-projects/spring-framework/blob/9b38e43c1754563465c275c253fb4b6fd1cf9345/spring-test/src/main/java/org/springframework/test/web/servlet/client/MockMvcHttpConnector.java#L192-L202

The actual cookie in question is of type MockCookie

https://github.com/spring-projects/spring-framework/blob/19cf5035343922111e7c03b60933bf178170f9d4/spring-test/src/main/java/org/springframework/mock/web/MockCookie.java#L80-L89

I think that the MockMvcHttpConnector should be updated to use the new Servlet 6 Cookie.getAttribute to get the SameSite attribute.

At the same time I notice that the MockCookie doesn't have the SameSite attribute in the attribute map. I think the Cookie implementation on Servlet 6 generally delegate the setters to setAttributeInternal. So I think that MockCookie also needs a corresponding update to set the SameSite as an attribute.

Comment From: sbrannen

  • Superseded by #30260