Skip to content

Commit

Permalink
/wallet/seed api method protected by api key
Browse files Browse the repository at this point in the history
  • Loading branch information
gagarin55 committed Jun 3, 2016
1 parent 47f8766 commit 9c5391e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ case class WalletApiRoute(override val application: Application)(implicit val co
@ApiOperation(value = "Seed", notes = "Export wallet seed", httpMethod = "GET")
def seed: Route = {
path("wallet" / "seed") {
getJsonRoute {
lazy val seedJs = Json.obj("seed" -> Base58.encode(wallet.seed))
walletNotExists(wallet).getOrElse(seedJs)
withAuth {
getJsonRoute {
lazy val seedJs = Json.obj("seed" -> Base58.encode(wallet.seed))
walletNotExists(wallet).getOrElse(seedJs)
}
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ class WalletAPISpecification extends FunSuite with Matchers {
}

test("/wallet/seed API route") {
(GET.request("/wallet/seed") \ "seed").as[String] shouldBe Base58.encode(application.settings.walletSeed.get)
GET.incorrectApiKeyTest("/wallet/seed")

val response = GET.request("/wallet/seed", headers = Map("api_key" -> "test"))
(response \ "seed").as[String] shouldBe Base58.encode(application.settings.walletSeed.get)
}

}

0 comments on commit 9c5391e

Please sign in to comment.