FunctionalTest : session problem

Bug #497408 reported by Gaetan Renaudeau
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
play framework
Status tracked in 1.0
1.0
Fix Released
Undecided
Erwan Loisant
1.1
Fix Committed
Undecided
Erwan Loisant

Bug Description

In a FunctionalTest, sessions aren't restore between 2 requests.
For instance, after a login request, and a homepage get,
the login response will contains a different session of the homepage get response.

This is a use case in the Chat sample application :

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import org.junit.*;

import play.Logger;
import play.mvc.Http.*;
import play.test.*;

public class BugUseCase extends FunctionalTest {

 private void displayCookies(Map<String,Cookie> cookies) {
  for (String key : cookies.keySet())
   Logger.info("%s = %s",key, cookies.get(key).value);
 }

 @Test
 public void usecase () {
  GET("/logout"); // clear session

  Map<String, String> args = new HashMap<String, String>();
  args.put("nick", "toto");

  Response loginResponse = POST("/signin", args, new HashMap<String,File>()); // Login
  displayCookies(loginResponse.cookies);

  Response r = GET("/"); // Get main page
  displayCookies(r.cookies);

  assertEquals(loginResponse.cookies.get("PLAY_SESSION").value, r.cookies.get("PLAY_SESSION").value); // fail !
  assertIsOk(r); // Failure, Response status expected:<200> but was:<302> (in fact the login has failed)
 }
}

log :

14:26:14,145 INFO ~ PLAY_FLASH =
14:26:14,145 INFO ~ PLAY_ERRORS =
14:26:14,145 INFO ~ PLAY_SESSION = d94b6eaa6b58710ef950f0bb4943fb335c8c2a3b-%00___ID%3A3a336fa4-fcc7-42a1-ba97-792ed3d8f5df%00%00nick%3Atoto%00
14:26:14,154 INFO ~ PLAY_FLASH =
14:26:14,154 INFO ~ PLAY_ERRORS =
14:26:14,154 INFO ~ PLAY_SESSION = e6ff5f33bfc19e35727688654b69c8818e6a3734-%00___ID%3Af36df216-9154-4690-832c-62e01c444211%00

in the test page :

Failure, expected:<[d94b6eaa6b58710ef950f0bb4943fb335c8c2a3b-%00___ID%3A3a336fa4-fcc7-42a1-ba97-792ed3d8f5df%00%00nick%3Atoto]%00> but was:<[e6ff5f33bfc19e35727688654b69c8818e6a3734-%00___ID%3Af36df216-9154-4690-832c-62e01c444211]%00>

Best regards,
Gaetan Renaudeau

Revision history for this message
Gaetan Renaudeau (gre) wrote :
Revision history for this message
Guillaume Bort (guillaume-bort) wrote : Re: [Bug 497408] Re: FunctionalTest : session problem

Yes I know. Cookie support is not yet implemented.

On Wed, Dec 16, 2009 at 2:29 PM, Gaetan Renaudeau <email address hidden> wrote:
>
> ** Attachment added: "use case of the bug in chat sample application."
>   http://launchpadlibrarian.net/36868353/BugUseCase.java
>
> --
> FunctionalTest : session problem
> https://bugs.launchpad.net/bugs/497408
> You received this bug notification because you are a member of play
> framework developers, which is subscribed to play framework.
>

Changed in play:
status: New → Fix Committed
Revision history for this message
Gaetan Renaudeau (gre) wrote :

Despite of the fix committed status, my use case still not works.

I have two different cookies between the two requests, is a method need to call ?

Revision history for this message
Guillaume Bort (guillaume-bort) wrote :

Can you add your exact test case and and mark the bug as incomplete ?

On Mon, Dec 28, 2009 at 9:41 AM, Gaetan Renaudeau <email address hidden> wrote:
> Despite of the fix committed status, my use case still not works.
>
> I have two different cookies between the two requests, is a method need
> to call ?
>
> --
> FunctionalTest : session problem
> https://bugs.launchpad.net/bugs/497408
> You received this bug notification because you are a member of play
> framework developers, which is subscribed to play framework.
>

Revision history for this message
Gaetan Renaudeau (gre) wrote :

The test case doesn't change :

On Wed, Dec 16, 2009 at 2:29 PM, Gaetan Renaudeau <email address hidden> wrote:
>
> ** Attachment added: "use case of the bug in chat sample application."
> http://launchpadlibrarian.net/36868353/BugUseCase.java
>

Best regards,
Gaëtan

Changed in play:
status: Fix Committed → Incomplete
Revision history for this message
tomas (gugljafa) wrote :

Looking at the revision 754, line FunctionalTest:235
if (savedCookies != null) request.cookies = savedCookies;
should probably be in newRequest method instead of DELETE

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.