t2v / play2-auth

Play2.x Authentication and Authorization module

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I want to test when user has no authority.

mt-sito opened this issue · comments

I want to test authorize with FakeRequest.

val Some(result) = route(app, FakeRequest(GET, "/path1").withLoggedIn(config)(1)) 
// "1" user is logged in but it has no authority.
assert(status(result) === UNAUTHORIZED)  // Returned OK

val Some(result) = route(app, FakeRequest(GET, "/path1").withLoggedIn(config)(2)) 
// "2" user is logged in and it has authority.
assert(status(result) === OK)

Sorry.It was a misunderstanding. I was able to do it.