This repository was archived by the owner on Apr 4, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
project-code/integration-tests/src/test/scala Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -285,6 +285,33 @@ abstract class AbstractPlay2WarTests extends FeatureSpec with GivenWhenThen with
285285 fail(" Page not found" )
286286 }
287287 }
288+
289+ scenario(" Container set and remove flash cookie" ) {
290+
291+ // no flash cookie before test :)
292+ var maybeFlashCookie = Option (webClient.getCookieManager.getCookie(" PLAY_FLASH" ))
293+ maybeFlashCookie should be (None )
294+
295+ // still no flash cookie after this request
296+ webClient.getPage(rootUrl + " /redirectLanding" )
297+ maybeFlashCookie = Option (webClient.getCookieManager.getCookie(" PLAY_FLASH" ))
298+ maybeFlashCookie should be (None )
299+
300+ // Call page which sets Flash cookie, then redirect to redirectLanding page which removes cookie
301+ val page = givenWhenGet(" a page" , " /flashing" , " load a page which sets flash cookie" )
302+
303+ Then (" page body should contain 'Flash cookie: found'" )
304+ page.map { p =>
305+ p.getWebResponse.getContentAsString should include(" Flash cookie: found" )
306+ }.getOrElse {
307+ fail(" Page not found" )
308+ }
309+
310+ // no flash cookie after redirecting
311+ maybeFlashCookie = Option (webClient.getCookieManager.getCookie(" PLAY_FLASH" ))
312+ maybeFlashCookie should be (None )
313+
314+ }
288315 }
289316
290317 /*
Original file line number Diff line number Diff line change @@ -46,8 +46,9 @@ object Application extends Controller {
4646 Ok (views.html.getCookies(mapCookies))
4747 }
4848
49- def redirectLanding = Action {
50- Ok (views.html.redirectLanding())
49+ def redirectLanding = Action { implicit request =>
50+ val flashResult = flash.get(" success" ).getOrElse(" not found" )
51+ Ok (views.html.redirectLanding(flashResult))
5152 }
5253
5354 def redirect = Action {
@@ -181,4 +182,11 @@ object Application extends Controller {
181182 Thread .sleep(java.util.concurrent.TimeUnit .SECONDS .toMillis(duration))
182183 Ok (" " )
183184 }
185+
186+ def flashing = Action {
187+ Redirect (routes.Application .redirectLanding).flashing(
188+ " success" -> " found"
189+ )
190+ }
191+
184192}
Original file line number Diff line number Diff line change 1- @()
1+ @(flashResult: String )
22
33@main("Redirect landing") {
44 < p > redirect landing</ p >
5+ < p > Flash cookie: @flashResult</ p >
56}
Original file line number Diff line number Diff line change @@ -34,5 +34,7 @@ GET /clock controllers.Application.liveClock
3434GET /longRequest/:duration controllers.JavaApplication.longRequest(duration: Long)
3535GET /slongRequest/:duration controllers.Application.longRequest(duration: Long)
3636
37+ GET /flashing controllers.Application.flashing
38+
3739# Map static resources from the /public folder to the /assets URL path
3840GET /assets/*file controllers.Assets.at(path="/public", file)
You can’t perform that action at this time.
0 commit comments