Skip to content

Commit

Permalink
PR feedback: variable naming
Browse files Browse the repository at this point in the history
  • Loading branch information
davidangb committed May 22, 2017
1 parent 0021bf7 commit f503601
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,18 @@ import scala.concurrent.ExecutionContext

trait MockAgoraDirectives extends AgoraDirectives {
def commonNameFromRequest(magnet: ImplicitMagnet[ExecutionContext]): Directive1[String] = {


provide(AgoraConfig.mockAuthenticatedUserEmail)
}

// allow unit tests to specify the user making the request; if they don't, use the default
def usernameFromRequest(magnet: ImplicitMagnet[ExecutionContext]): Directive1[String] = {
optionalHeaderValueByName(MockAgoraDirectives.mockUserHeader) map {
case Some(mockuser) => mockuser
optionalHeaderValueByName(MockAgoraDirectives.mockAuthenticatedUserEmailHeader) map {
case Some(mockAuthenticatedUserEmail) => mockAuthenticatedUserEmail
case None => AgoraConfig.mockAuthenticatedUserEmail
}
}
}

object MockAgoraDirectives extends MockAgoraDirectives {
val mockUserHeader = "X-UnitTest-ImpersonateUser"
val mockAuthenticatedUserEmailHeader = "X-UnitTest-MockAuthenticatedUserEmail"
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class EntityCreationPermissionSpec extends ApiServiceSpec {
val randomEntity = createRandomMethod(namespace, name)

Post(ApiUtil.Methods.withLeadingVersion, randomEntity) ~>
addHeader(MockAgoraDirectives.mockUserHeader, asUser) ~>
addHeader(MockAgoraDirectives.mockAuthenticatedUserEmailHeader, asUser) ~>
methodsService.postRoute ~> check {
assert(status == expectedStatus, response.message)
if (expectedStatus == Created) {
Expand Down

0 comments on commit f503601

Please sign in to comment.