My talk at Scala Bay Meetup at Netflix about Powering the Partner APIs with Scalatra and Netflix OSS. This talk was delivered on September 9th 2013, at Netflix, Los Gatos.
support a method called login(user:String,pass:String) that returns an Option[String]. */ class LoginManagerSpec extends FlatSpec with ShouldMatchers { }
support a method called login(user:String,pass:String) that returns an Option[String]. */ class LoginManagerSpec extends FlatSpec with ShouldMatchers { it should " Be able to login a valid user and get a token " in { fail() } }
support a method called login(user:String,pass:String) that returns an Option[String]. */ class LoginManagerSpec extends FlatSpec with ShouldMatchers { it should " Be able to login a valid user and get a token " in { val token = LoginManager.login("someuser", "somepassword") token should not be None } }
support a method called login(user:String,pass:String) that returns an Option[String]. */ class LoginManagerSpec extends FlatSpec with ShouldMatchers { it should " Be able to login a valid user and get a token " in { val token = LoginManager.login("someuser", "somepassword") token should not be None } it should " Fail to login an invalid user " in { fail } }
support a method called login(user:String,pass:String) that returns an Option[String]. */ class LoginManagerSpec extends FlatSpec with ShouldMatchers { it should " Be able to login a valid user and get a token " in { val token = LoginManager.login("someuser", "somepassword") token should not be None } it should " Fail to login an invalid user " in { val token = LoginManager.login("fail", "fail") token should be (None) } }
in valid users" in { post("/", body = """user=gooduser&password=goodpassword""") { status should equal(200) body should include "token" } } it should "not allow invalid users to log in" in { post("/", body = """user=baduser&password=badpassword""") { status should equal(401) body should include "message" } } }
Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: src/main/scala/com/netflix/nrdportal/http/DpiService.scala # modified: src/test/scala/com/netflix/nrdportal/http/DpiServiceSpec.scala
match { case Some(userName) => f(userName) case None => Unauthorized("You are not logged in!") } } def printCurrentUserName = { withAuthenticatedUser { userName => Ok(s"Your username is ${userName}") } }