Add support remember-me cookie customization
Closes gh-14990
This commit is contained in:
committed by
Marcus Hert Da Coregio
parent
3acd2c65d9
commit
44f9396bad
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -402,6 +402,17 @@ public class AbstractRememberMeServicesTests {
|
||||
verify(source).getMessage(eq(code), any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setCookieCustomAttribute() {
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
MockRememberMeServices services = new MockRememberMeServices(this.uds);
|
||||
services.setCookieCustomizer((cookie) -> cookie.setAttribute("attr1", "value1"));
|
||||
services.setCookie(new String[] { "mycookie" }, 1000, request, response);
|
||||
Cookie cookie = response.getCookie(AbstractRememberMeServices.SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY);
|
||||
assertThat(cookie.getAttribute("attr1")).isEqualTo("value1");
|
||||
}
|
||||
|
||||
private Cookie[] createLoginCookie(String cookieToken) {
|
||||
MockRememberMeServices services = new MockRememberMeServices(this.uds);
|
||||
Cookie cookie = new Cookie(AbstractRememberMeServices.SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY,
|
||||
|
||||
Reference in New Issue
Block a user