I've found a workaround to this issue. To preserve the cookies from a
previous request in a FunctionalTest, you have to manually build the
request. There is a helper method in FunctionTest to get you started:
// Make the login request
Map<String, String> loginUserParams = new HashMap<String,
String>();
loginUserParams.put("username", "admin");
loginUserParams.put("password", "admin");
Response loginResponse = POST("/login", loginUserParams);
Request request = newRequest(); // helper method from
FunctionalTest superclass
request.cookies = loginResponse.cookies; // this makes the request
authenticated for secure module
request.url = "/some/secured/action";
request.method = "POST";
request.params.put("someparam", "somevalue");
Response response = makeRequest(request);
assertIsOk(response); // Passes!
On Apr 23, 1:50 pm, Mark Schaake <
mark.scha...@gmail.com> wrote:
> Yes, I know about the org.junit.Before annotation. This doesn't work
> in that cookies from previous call are not being placed in subsequent
> calls (even though looking at FunctionalTest this is what is supposed
> to happen). Looks like bughttps://
bugs.launchpad.net/play/+bug/497408
> as pointed out by Havoc P on stackoverflow.comhttp://
stackoverflow.com/questions/5762246/playframework-secure-modul...