Skip to content

Commit

Permalink
Merge pull request #477 from ergoplatform/i476
Browse files Browse the repository at this point in the history
Authentication on wallet api route.
  • Loading branch information
oskin1 authored Oct 5, 2018
2 parents 6e50c52 + 15d9117 commit 547b7a7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/it/resources/template.conf
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ scorex {
}
restApi {
bindAddress = "0.0.0.0:9051"
apiKeyHash = null
}
}
1 change: 1 addition & 0 deletions src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,6 @@ scorex {
}
restApi {
bindAddress = "0.0.0.0:9052"
apiKeyHash = "1111"
}
}
2 changes: 1 addition & 1 deletion src/main/scala/org/ergoplatform/api/WalletApiRoute.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ case class WalletApiRoute(readersHolder: ActorRef, nodeViewActorRef: ActorRef, e
withWalletOp(op)(ApiResponse.apply[T])
}

override val route: Route = (pathPrefix("wallet") & withCors) {
override val route: Route = (pathPrefix("wallet") & withCors & withAuth) {
balancesRoute ~
unconfirmedBalanceRoute ~
addressesRoute ~
Expand Down
6 changes: 6 additions & 0 deletions src/test/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ ergo {
}
}

scorex {
restApi {
apiKeyHash = null
}
}

akka {
test {
timefactor = 2 # duration scale factor to prevent spurious test failures on the heavily loaded CI servers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.ergoplatform.api.routes

import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.server.Route
import akka.http.scaladsl.testkit.ScalatestRouteTest
import de.heikoseeberger.akkahttpcirce.FailFastCirceSupport
import io.circe.syntax._
Expand All @@ -19,11 +20,11 @@ class WalletApiRouteSpec extends FlatSpec

val prefix = "/wallet"

val ergoSettings = ErgoSettings.read(None)
implicit val requestEncoder = new PaymentRequestEncoder(ergoSettings)
val route = WalletApiRoute(readersRef, nodeViewRef, settings).route
val ergoSettings: ErgoSettings = ErgoSettings.read(Some("src/test/resources/application.conf"))
val route: Route = WalletApiRoute(readersRef, nodeViewRef, settings).route

private implicit val ergoAddressEncoder = new ErgoAddressEncoder(ergoSettings)
implicit val requestEncoder: PaymentRequestEncoder = new PaymentRequestEncoder(ergoSettings)
implicit val ergoAddressEncoder: ErgoAddressEncoder = new ErgoAddressEncoder(ergoSettings)

it should "generate transaction" in {
val amount = 100L
Expand Down

0 comments on commit 547b7a7

Please sign in to comment.