Aligned exception message for httpOnly
Issue: SPR-15488
This commit is contained in:
@@ -199,12 +199,13 @@ public class CookieResultMatchers {
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert whether the cookie must be httpOnly.
|
||||
* Assert whether the cookie must be HTTP only.
|
||||
* @since 4.3.9
|
||||
*/
|
||||
public ResultMatcher httpOnly(final String name, final boolean httpOnly) {
|
||||
return result -> {
|
||||
Cookie cookie = result.getResponse().getCookie(name);
|
||||
assertEquals("Response cookie httpOnly", httpOnly, cookie.isHttpOnly());
|
||||
assertEquals("Response cookie '" + name + "' httpOnly", httpOnly, cookie.isHttpOnly());
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -34,6 +34,7 @@ import static org.springframework.test.web.servlet.setup.MockMvcBuilders.*;
|
||||
* Examples of expectations on response cookies values.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Nikola Yovchev
|
||||
*/
|
||||
public class CookieAssertionTests {
|
||||
|
||||
@@ -47,6 +48,7 @@ public class CookieAssertionTests {
|
||||
CookieLocaleResolver localeResolver = new CookieLocaleResolver();
|
||||
localeResolver.setCookieDomain("domain");
|
||||
localeResolver.setCookieHttpOnly(true);
|
||||
|
||||
this.mockMvc = standaloneSetup(new SimpleController())
|
||||
.addInterceptors(new LocaleChangeInterceptor())
|
||||
.setLocaleResolver(localeResolver)
|
||||
@@ -55,6 +57,7 @@ public class CookieAssertionTests {
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testExists() throws Exception {
|
||||
this.mockMvc.perform(get("/")).andExpect(cookie().exists(COOKIE_NAME));
|
||||
@@ -106,6 +109,7 @@ public class CookieAssertionTests {
|
||||
this.mockMvc.perform(get("/")).andExpect(cookie().httpOnly(COOKIE_NAME, true));
|
||||
}
|
||||
|
||||
|
||||
@Controller
|
||||
private static class SimpleController {
|
||||
|
||||
@@ -114,4 +118,5 @@ public class CookieAssertionTests {
|
||||
return "home";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user