title: In a functional test, how can I fake an authenticated user using Secure module in Play Framework?
body: <p>How would you fake a session value in functional test in Play Framework 1.2.3? </p>
  
  <p>I'm doing a simple test like:</p>
  
  <p>Before running the test, I set up a blank session, hoping it will make part of the test:</p>
  
  <pre>
  @Before
  public void setupHTTP() {
     Session.current.set(new Session());
  }
  </pre>
  
  <pre>
  @Test
  public void testRedirectToUserHomeForAuthenticatedUserWhenBlankAction() {
      authenticateUser("test@user.com");
      Response response = GET("/user/blank");
      assertRedirected(response, "/user/home");
  }
  </pre>
  
  <p>The method <pre>authenticate(String userEmail)</pre> just put the key "username" in the session map:</p>
  
  <pre>
  protected void authenticateUser(String userEmail) {
          // Put in session the email
          Session.current.get().put(USERNAME, userEmail);
  }
  </pre>
  
  <p>But the test runs in a different thread, as long as I could understand, and don't see the session I've set up... </p>
  
  <p>How to fake session values in functional tests?</p>