diff options
author | vlad <vlad@drivergrp.com> | 2016-09-09 15:15:04 -0700 |
---|---|---|
committer | vlad <vlad@drivergrp.com> | 2016-09-09 15:15:04 -0700 |
commit | 135c38f390da1a2faf983d9b2b2f0fea6a5e74b5 (patch) | |
tree | 37090c7f7eec45cf581538e42385c413a15fd237 /src/test/scala/com/drivergrp/core/AuthTest.scala | |
parent | 968a702c359cd1de3359109edda6af5dd26fc74a (diff) | |
download | driver-core-135c38f390da1a2faf983d9b2b2f0fea6a5e74b5.tar.gz driver-core-135c38f390da1a2faf983d9b2b2f0fea6a5e74b5.tar.bz2 driver-core-135c38f390da1a2faf983d9b2b2f0fea6a5e74b5.zip |
Scalacheck properties check inside of scalatest + code formatting
Diffstat (limited to 'src/test/scala/com/drivergrp/core/AuthTest.scala')
-rw-r--r-- | src/test/scala/com/drivergrp/core/AuthTest.scala | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/src/test/scala/com/drivergrp/core/AuthTest.scala b/src/test/scala/com/drivergrp/core/AuthTest.scala index 7725a45..0e4841b 100644 --- a/src/test/scala/com/drivergrp/core/AuthTest.scala +++ b/src/test/scala/com/drivergrp/core/AuthTest.scala @@ -13,11 +13,13 @@ class AuthTest extends FlatSpec with Matchers with MockitoSugar with ScalatestRo "'authorize' directive" should "throw error is auth token is not in the request" in { Get("/naive/attempt") ~> - auth.directives.authorize(CanSignOutReport) { authToken => complete("Never going to be here") } ~> - check { - handled shouldBe false - rejections should contain (MissingHeaderRejection("WWW-Authenticate")) - } + auth.directives.authorize(CanSignOutReport) { authToken => + complete("Never going to be here") + } ~> + check { + handled shouldBe false + rejections should contain(MissingHeaderRejection("WWW-Authenticate")) + } } it should "throw error is authorized user is not having the requested permission" in { @@ -25,13 +27,15 @@ class AuthTest extends FlatSpec with Matchers with MockitoSugar with ScalatestRo val referenceAuthToken = AuthToken(Base64("I am a pathologist's token")) Post("/administration/attempt").addHeader( - RawHeader(auth.directives.AuthenticationTokenHeader, s"Macaroon ${referenceAuthToken.value.value}") + RawHeader(auth.directives.AuthenticationTokenHeader, s"Macaroon ${referenceAuthToken.value.value}") ) ~> - auth.directives.authorize(CanAssignRoles) { authToken => complete("Never going to get here") } ~> - check { - handled shouldBe false - rejections should contain (ValidationRejection("User does not have the required permission CanAssignRoles", None)) - } + auth.directives.authorize(CanAssignRoles) { authToken => + complete("Never going to get here") + } ~> + check { + handled shouldBe false + rejections should contain(ValidationRejection("User does not have the required permission CanAssignRoles", None)) + } } it should "pass and retrieve the token to client code, if token is in request and user has permission" in { @@ -39,14 +43,14 @@ class AuthTest extends FlatSpec with Matchers with MockitoSugar with ScalatestRo val referenceAuthToken = AuthToken(Base64("I am token")) Get("/valid/attempt/?a=2&b=5").addHeader( - RawHeader(auth.directives.AuthenticationTokenHeader, s"Macaroon ${referenceAuthToken.value.value}") + RawHeader(auth.directives.AuthenticationTokenHeader, s"Macaroon ${referenceAuthToken.value.value}") ) ~> - auth.directives.authorize(CanSignOutReport) { authToken => - complete("Alright, \"" + authToken.value.value + "\" is handled") - } ~> - check { - handled shouldBe true - responseAs[String] shouldBe "Alright, \"Macaroon I am token\" is handled" - } + auth.directives.authorize(CanSignOutReport) { authToken => + complete("Alright, \"" + authToken.value.value + "\" is handled") + } ~> + check { + handled shouldBe true + responseAs[String] shouldBe "Alright, \"Macaroon I am token\" is handled" + } } } |