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) {
|
public ResultMatcher httpOnly(final String name, final boolean httpOnly) {
|
||||||
return result -> {
|
return result -> {
|
||||||
Cookie cookie = result.getResponse().getCookie(name);
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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.
|
* Examples of expectations on response cookies values.
|
||||||
*
|
*
|
||||||
* @author Rossen Stoyanchev
|
* @author Rossen Stoyanchev
|
||||||
|
* @author Nikola Yovchev
|
||||||
*/
|
*/
|
||||||
public class CookieAssertionTests {
|
public class CookieAssertionTests {
|
||||||
|
|
||||||
@@ -47,6 +48,7 @@ public class CookieAssertionTests {
|
|||||||
CookieLocaleResolver localeResolver = new CookieLocaleResolver();
|
CookieLocaleResolver localeResolver = new CookieLocaleResolver();
|
||||||
localeResolver.setCookieDomain("domain");
|
localeResolver.setCookieDomain("domain");
|
||||||
localeResolver.setCookieHttpOnly(true);
|
localeResolver.setCookieHttpOnly(true);
|
||||||
|
|
||||||
this.mockMvc = standaloneSetup(new SimpleController())
|
this.mockMvc = standaloneSetup(new SimpleController())
|
||||||
.addInterceptors(new LocaleChangeInterceptor())
|
.addInterceptors(new LocaleChangeInterceptor())
|
||||||
.setLocaleResolver(localeResolver)
|
.setLocaleResolver(localeResolver)
|
||||||
@@ -55,6 +57,7 @@ public class CookieAssertionTests {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExists() throws Exception {
|
public void testExists() throws Exception {
|
||||||
this.mockMvc.perform(get("/")).andExpect(cookie().exists(COOKIE_NAME));
|
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));
|
this.mockMvc.perform(get("/")).andExpect(cookie().httpOnly(COOKIE_NAME, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
private static class SimpleController {
|
private static class SimpleController {
|
||||||
|
|
||||||
@@ -114,4 +118,5 @@ public class CookieAssertionTests {
|
|||||||
return "home";
|
return "home";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user