Skip to content

Commit

Permalink
Make test routes configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
philipliu committed Aug 30, 2023
1 parent 8cb2948 commit a927c5b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,5 @@ fun Route.customer(customerService: CustomerService) {
call.respond(HttpStatusCode.NoContent)
}
}
route("/invalidate_clabe") {
// TODO: Consider to enable this endpoint only when testing
get("{id}") {
val id = call.parameters["id"]!!
customerService.invalidateClabe(id)
call.respond(HttpStatusCode.OK)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.stellar.reference.callbacks.test

import io.ktor.http.*
import io.ktor.server.application.*
import io.ktor.server.auth.*
import io.ktor.server.response.*
import io.ktor.server.routing.*
import org.stellar.reference.callbacks.customer.CustomerService
import org.stellar.reference.plugins.AUTH_CONFIG_ENDPOINT

fun Route.testCustomer(customerService: CustomerService) {
authenticate(AUTH_CONFIG_ENDPOINT) {
route("/invalidate_clabe") {
get("{id}") {
val id = call.parameters["id"]!!
customerService.invalidateClabe(id)
call.respond(HttpStatusCode.OK)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ data class Sep24(val enableTest: Boolean, val secret: String, val interactiveJwt

data class AppSettings(
val version: String,
val isTest: Boolean,
val port: Int,
val horizonEndpoint: String,
val platformApiEndpoint: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import org.stellar.reference.callbacks.fee.fee
import org.stellar.reference.callbacks.interactive.sep24Interactive
import org.stellar.reference.callbacks.rate.RateService
import org.stellar.reference.callbacks.rate.rate
import org.stellar.reference.callbacks.test.testCustomer
import org.stellar.reference.callbacks.uniqueaddress.UniqueAddressService
import org.stellar.reference.callbacks.uniqueaddress.uniqueAddress
import org.stellar.reference.dao.JdbcCustomerRepository
Expand Down Expand Up @@ -53,4 +54,7 @@ fun Application.configureRouting(cfg: Config) = routing {
if (cfg.sep24.enableTest) {
testSep24(helper, depositService, withdrawalService, cfg.sep24.interactiveJwtKey)
}
if (cfg.appSettings.isTest) {
testCustomer(customerService)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
app:
version: 0.0.1
# Enables test endpoints.
isTest: true
# The port on which the server will listen for requests.
port: 8091
# The URL of the Stellar network to which the Anchor will connect.
Expand Down

0 comments on commit a927c5b

Please sign in to comment.