package core.auth;

import controllers.routes;
import static org.junit.Assert.*;
import org.junit.*;
import java.util.*;
import play.mvc.*;
import play.libs.*;
import play.test.*;
import static play.test.Helpers.*;
import com.avaje.ebean.Ebean;
import com.google.common.collect.ImmutableMap;

import java.util.List;

public class AuthenticationTest extends WithApplication {

    @Before
    public void setUp() throws Exception {
        start(fakeApplication(inMemoryDatabase(), fakeGlobal()));
        Ebean.save((List) Yaml.load("initial-data.yml"));
    }

    @Test
    public void testValidate() throws Exception {
        Result result = callAction(
            routes.ref.Application.authenticate(),
            fakeRequest().withFormUrlEncodedBody(
                ImmutableMap.of("username", "Karin", "password", "password")
            )
        );

        assertEquals(303, status(result));
        assertEquals("Karin", session(result).get("username"));

        result = callAction(
                routes.ref.Application.authenticate(),
                fakeRequest().withFormUrlEncodedBody(
                        ImmutableMap.of("username", "Karin", "password", "wrongpassword")
                )
        );

        assertEquals(400, status(result));
        assertNull(session(result).get("username"));
    }
}
@@ -593,16 +593,23 @@
 Validate
+Success
 () throw
@@ -969,16 +969,89 @@
 ame%22));%0A
+    %7D%0A%0A    @Test%0A    public void testValidateFailure() throws Exception %7B
 %0A       
@@ -1051,16 +1051,23 @@
         
+Result 
 result =

Split auth test into success and failure