Remove deprecated Cookie usage

Remove usage of comment and verison usage

Signed-off-by: M-Faheem-Khan <faheem5948@gmail.com>
This commit is contained in:
M-Faheem-Khan
2025-04-27 23:53:19 -04:00
committed by Rob Winch
parent d52289bd7a
commit 241c3cd35a
10 changed files with 4 additions and 75 deletions

View File

@@ -362,17 +362,6 @@ public class AbstractRememberMeServicesTests {
assertThat(cookie.isHttpOnly()).isTrue();
}
// SEC-2791
@Test
public void setCookieMaxAge1VersionSet() {
MockRememberMeServices services = new MockRememberMeServices();
MockHttpServletRequest request = new MockHttpServletRequest();
MockHttpServletResponse response = new MockHttpServletResponse();
services.setCookie(new String[] { "value" }, 1, request, response);
Cookie cookie = response.getCookie(AbstractRememberMeServices.SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY);
assertThat(cookie.getVersion()).isZero();
}
@Test
public void setCookieDomainValue() {
MockRememberMeServices services = new MockRememberMeServices();

View File

@@ -93,7 +93,6 @@ public class FirewalledResponseTests {
Cookie cookie = new Cookie("foo", "bar");
cookie.setPath("/foobar");
cookie.setDomain("foobar");
cookie.setComment("foobar");
this.fwResponse.addCookie(cookie);
verify(this.response).addCookie(cookie);
}

View File

@@ -45,11 +45,9 @@ public class DefaultSavedRequestMixinTests extends AbstractMixinTests {
+ "\"@class\": \"org.springframework.security.web.savedrequest.SavedCookie\", "
+ "\"name\": \"SESSION\", "
+ "\"value\": \"123456789\", "
+ "\"comment\": null, "
+ "\"maxAge\": -1, "
+ "\"path\": null, "
+ "\"secure\":false, "
+ "\"version\": 0, "
+ "\"domain\": null"
+ "}]]";
// @formatter:on

View File

@@ -42,11 +42,9 @@ public class SavedCookieMixinTests extends AbstractMixinTests {
+ "\"@class\": \"org.springframework.security.web.savedrequest.SavedCookie\", "
+ "\"name\": \"SESSION\", "
+ "\"value\": \"123456789\", "
+ "\"comment\": null, "
+ "\"maxAge\": -1, "
+ "\"path\": null, "
+ "\"secure\":false, "
+ "\"version\": 0, "
+ "\"domain\": null"
+ "}";
// @formatter:on
@@ -90,13 +88,11 @@ public class SavedCookieMixinTests extends AbstractMixinTests {
@Test
public void deserializeSavedCookieJsonTest() throws IOException {
SavedCookie savedCookie = (SavedCookie) this.mapper.readValue(COOKIE_JSON, Object.class);
SavedCookie savedCookie = this.mapper.readValue(COOKIE_JSON, SavedCookie.class);
assertThat(savedCookie).isNotNull();
assertThat(savedCookie.getName()).isEqualTo("SESSION");
assertThat(savedCookie.getValue()).isEqualTo("123456789");
assertThat(savedCookie.isSecure()).isEqualTo(false);
assertThat(savedCookie.getVersion()).isZero();
assertThat(savedCookie.getComment()).isNull();
}
}

View File

@@ -33,12 +33,10 @@ public class SavedCookieTests {
@BeforeEach
public void setUp() {
this.cookie = new Cookie("name", "value");
this.cookie.setComment("comment");
this.cookie.setDomain("domain");
this.cookie.setMaxAge(100);
this.cookie.setPath("path");
this.cookie.setSecure(true);
this.cookie.setVersion(11);
this.savedCookie = new SavedCookie(this.cookie);
}
@@ -52,11 +50,6 @@ public class SavedCookieTests {
assertThat(this.savedCookie.getValue()).isEqualTo(this.cookie.getValue());
}
@Test
public void testGetComment() {
assertThat(this.savedCookie.getComment()).isEqualTo(this.cookie.getComment());
}
@Test
public void testGetDomain() {
assertThat(this.savedCookie.getDomain()).isEqualTo(this.cookie.getDomain());
@@ -72,22 +65,15 @@ public class SavedCookieTests {
assertThat(this.savedCookie.getPath()).isEqualTo(this.cookie.getPath());
}
@Test
public void testGetVersion() {
assertThat(this.savedCookie.getVersion()).isEqualTo(this.cookie.getVersion());
}
@Test
public void testGetCookie() {
Cookie other = this.savedCookie.getCookie();
assertThat(other.getComment()).isEqualTo(this.cookie.getComment());
assertThat(other.getDomain()).isEqualTo(this.cookie.getDomain());
assertThat(other.getMaxAge()).isEqualTo(this.cookie.getMaxAge());
assertThat(other.getName()).isEqualTo(this.cookie.getName());
assertThat(other.getPath()).isEqualTo(this.cookie.getPath());
assertThat(other.getSecure()).isEqualTo(this.cookie.getSecure());
assertThat(other.getValue()).isEqualTo(this.cookie.getValue());
assertThat(other.getVersion()).isEqualTo(this.cookie.getVersion());
}
@Test