September 2018
Intermediate to advanced
398 pages
9h 43m
English
When the client calls the login URL, the server responds with a Set-Cookie header. In this header, the encrypted session data can be obtained by using the PLAY_SESSION key.
The following is the unit test for the new login endpoint:
"return a cookie when a user logins" in {
val cookieFuture = wsClient.url(login).post("myID").map { response => response.headers.get("Set-Cookie").map( header => header.head.split(";") .filter(_.startsWith("PLAY_SESSION")).head) } }
val loginCookies = Await.result(cookieFuture, 1 seconds)
val play_session_Key = loginCookies.get.split("=").head
play_session_Key must equal("PLAY_SESSION")
}
The test sends a POST request to the login endpoint. For now, we send a dummy payload, myID, which represents a user ...
Read now
Unlock full access