Skip to content

Commit

Permalink
Take care of PR comments #2
Browse files Browse the repository at this point in the history
  • Loading branch information
lijamie98 committed Nov 2, 2023
1 parent 34e530e commit 95cf596
Show file tree
Hide file tree
Showing 21 changed files with 77 additions and 67 deletions.
4 changes: 2 additions & 2 deletions integration-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ val enableTestConcurrency = extra["enableTestConcurrency"] as (Test) -> Unit
tasks.test {
enableTestConcurrency(this)
exclude("**/org/stellar/anchor/platform/*Test.class")
exclude("**/org/stellar/anchor/platform/subtest/**")
exclude("**/org/stellar/anchor/platform/e2e_test/**")
exclude("**/org/stellar/anchor/platform/integrationtest/**")
exclude("**/org/stellar/anchor/platform/e2etest/**")
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.stellar.anchor.platform.e2e_test
package org.stellar.anchor.platform.e2etest

import io.ktor.client.*
import io.ktor.client.plugins.*
Expand Down Expand Up @@ -32,7 +32,7 @@ import org.stellar.anchor.auth.JwtService
import org.stellar.anchor.auth.Sep24InteractiveUrlJwt
import org.stellar.anchor.platform.CLIENT_WALLET_SECRET
import org.stellar.anchor.platform.TestConfig
import org.stellar.anchor.platform.subtest.SepTests
import org.stellar.anchor.platform.suite.AbstractIntegrationTests
import org.stellar.anchor.util.Log.info
import org.stellar.reference.client.AnchorReferenceServerClient
import org.stellar.reference.wallet.WalletServerClient
Expand All @@ -55,7 +55,7 @@ const val DEPOSIT_FUND_CLIENT_SECRET_2 = "SCW2SJEPTL4K7FFPFOFABFEFZJCG6LHULWVJX6

@TestInstance(PER_CLASS)
@Execution(CONCURRENT)
class Sep24End2EndTests : SepTests(TestConfig(testProfileName = "default")) {
class Sep24End2EndTests : AbstractIntegrationTests(TestConfig(testProfileName = "default")) {
private val client = HttpClient {
install(HttpTimeout) {
requestTimeoutMillis = 300000
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.stellar.anchor.platform.subtest
package org.stellar.anchor.platform.integrationtest

import com.google.gson.Gson
import java.time.Instant
Expand All @@ -25,14 +25,15 @@ import org.stellar.anchor.platform.TestConfig
import org.stellar.anchor.platform.callback.RestCustomerIntegration
import org.stellar.anchor.platform.callback.RestFeeIntegration
import org.stellar.anchor.platform.callback.RestRateIntegration
import org.stellar.anchor.platform.subtest.Sep12Tests.Companion.testCustomer1Json
import org.stellar.anchor.platform.subtest.Sep12Tests.Companion.testCustomer2Json
import org.stellar.anchor.platform.integrationtest.Sep12Tests.Companion.testCustomer1Json
import org.stellar.anchor.platform.integrationtest.Sep12Tests.Companion.testCustomer2Json
import org.stellar.anchor.platform.suite.AbstractIntegrationTests
import org.stellar.anchor.util.GsonUtils

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@Execution(ExecutionMode.SAME_THREAD)
@TestMethodOrder(MethodOrderer.OrderAnnotation::class)
class CallbackApiTests : SepTests(TestConfig(testProfileName = "default")) {
class CallbackApiTests : AbstractIntegrationTests(TestConfig(testProfileName = "default")) {

companion object {
private const val JWT_EXPIRATION_MILLISECONDS: Long = 10000
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.stellar.anchor.platform.subtest
package org.stellar.anchor.platform.integrationtest

import org.junit.jupiter.api.Assertions.assertFalse
import org.junit.jupiter.api.Assertions.assertTrue
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package org.stellar.anchor.platform.subtest
package org.stellar.anchor.platform.integrationtest

import org.junit.jupiter.api.Test
import org.stellar.anchor.api.event.AnchorEvent
import org.stellar.anchor.event.EventService.EventQueue.TRANSACTION
import org.stellar.anchor.platform.TestConfig
import org.stellar.anchor.platform.config.PropertyEventConfig
import org.stellar.anchor.platform.event.DefaultEventService
import org.stellar.anchor.platform.suite.AbstractIntegrationTests
import org.stellar.anchor.util.GsonUtils

class EventProcessingServerTests : SepTests(TestConfig(testProfileName = "default")) {
class EventProcessingServerTests :
AbstractIntegrationTests(TestConfig(testProfileName = "default")) {
companion object {
val eventConfig =
GsonUtils.getInstance().fromJson(eventConfigJson, PropertyEventConfig::class.java)!!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.stellar.anchor.platform.subtest
package org.stellar.anchor.platform.integrationtest

import com.google.gson.reflect.TypeToken
import org.apache.http.HttpStatus
Expand All @@ -22,9 +22,10 @@ import org.stellar.anchor.platform.Sep12Client
import org.stellar.anchor.platform.Sep24Client
import org.stellar.anchor.platform.Sep31Client
import org.stellar.anchor.platform.TestConfig
import org.stellar.anchor.platform.suite.AbstractIntegrationTests
import org.stellar.anchor.util.GsonUtils

class PlatformApiTests : SepTests(TestConfig(testProfileName = "default")) {
class PlatformApiTests : AbstractIntegrationTests(TestConfig(testProfileName = "default")) {
private val gson = GsonUtils.getInstance()

private val platformApiClient =
Expand Down Expand Up @@ -2890,7 +2891,7 @@ class PlatformApiTests : SepTests(TestConfig(testProfileName = "default")) {
"id": "SENDER_ID"
},
"receiver": {
"id": "SENDER_ID"
"id": "RECEIVER_ID"
}
},
"creator": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package org.stellar.anchor.platform.subtest
package org.stellar.anchor.platform.integrationtest

import kotlin.test.assertFailsWith
import org.junit.jupiter.api.Test
import org.stellar.anchor.api.exception.SepNotAuthorizedException
import org.stellar.anchor.api.sep.sep10.ValidationRequest
import org.stellar.anchor.platform.*
import org.stellar.anchor.platform.suite.AbstractIntegrationTests

class Sep10Tests : SepTests(TestConfig(testProfileName = "default")) {
class Sep10Tests : AbstractIntegrationTests(TestConfig(testProfileName = "default")) {
lateinit var sep10Client: Sep10Client
lateinit var sep10ClientMultiSig: Sep10Client

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
package org.stellar.anchor.platform.subtest
package org.stellar.anchor.platform.integrationtest

import io.ktor.client.plugins.*
import kotlinx.coroutines.runBlocking
import kotlinx.serialization.json.Json
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.stellar.anchor.api.sep.sep12.Sep12Status
import org.stellar.anchor.platform.CLIENT_WALLET_ACCOUNT
import org.stellar.anchor.platform.TestConfig
import org.stellar.anchor.platform.printRequest
import org.stellar.anchor.platform.printResponse
import org.stellar.anchor.platform.suite.AbstractIntegrationTests
import org.stellar.sdk.KeyPair
import org.stellar.walletsdk.anchor.auth
import org.stellar.walletsdk.horizon.SigningKeyPair

class Sep12Tests : SepTests(TestConfig(testProfileName = "default")) {
class Sep12Tests : AbstractIntegrationTests(TestConfig(testProfileName = "default")) {
init {
runBlocking {
// We have to override the default CLIENT_WALLET_SECRET because the deletion of the customer
// will fail other tests that uses the same wallet.
walletKeyPair = SigningKeyPair(KeyPair.random())
token = anchor.auth().authenticate(walletKeyPair)
}
}

@Test
fun `test put, get customers`() = runBlocking {
Expand Down Expand Up @@ -47,14 +56,14 @@ class Sep12Tests : SepTests(TestConfig(testProfileName = "default")) {
assertEquals(pr.id, gr.id)
assertEquals(Sep12Status.ACCEPTED.name, gr.status!!.status)

// Delete the customer
printRequest("Calling DELETE /customer/$CLIENT_WALLET_ACCOUNT")
anchor.sep12(token).delete(CLIENT_WALLET_ACCOUNT)

val ex: ClientRequestException = assertThrows {
anchor.sep12(token).getByIdAndType(pr.id, "sep31-receiver")
}
println(ex)
// // Delete the customer
// printRequest("Calling DELETE /customer/$CLIENT_WALLET_ACCOUNT")
// anchor.sep12(token).delete(CLIENT_WALLET_ACCOUNT)
//
// val ex: ClientRequestException = assertThrows {
// anchor.sep12(token).getByIdAndType(pr.id, "sep31-receiver")
// }
// println(ex)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.stellar.anchor.platform.subtest
package org.stellar.anchor.platform.integrationtest

import com.google.gson.reflect.TypeToken
import kotlinx.coroutines.runBlocking
Expand All @@ -24,6 +24,7 @@ import org.stellar.anchor.platform.TestConfig
import org.stellar.anchor.platform.gson
import org.stellar.anchor.platform.printRequest
import org.stellar.anchor.platform.printResponse
import org.stellar.anchor.platform.suite.AbstractIntegrationTests
import org.stellar.anchor.util.GsonUtils
import org.stellar.anchor.util.StringHelper.json
import org.stellar.walletsdk.anchor.IncompleteDepositTransaction
Expand All @@ -35,7 +36,7 @@ import org.stellar.walletsdk.asset.IssuedAssetId
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@Execution(SAME_THREAD)
@TestMethodOrder(OrderAnnotation::class)
class Sep24Tests : SepTests(TestConfig(testProfileName = "default")) {
class Sep24Tests : AbstractIntegrationTests(TestConfig(testProfileName = "default")) {
private val jwtService: JwtService =
JwtService(
config.env["secret.sep10.jwt_secret"]!!,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.stellar.anchor.platform.subtest
package org.stellar.anchor.platform.integrationtest

import java.time.Instant
import kotlin.streams.toList
Expand Down Expand Up @@ -26,8 +26,9 @@ import org.stellar.anchor.apiclient.TransactionsOrderBy
import org.stellar.anchor.apiclient.TransactionsSeps
import org.stellar.anchor.auth.AuthHelper
import org.stellar.anchor.platform.*
import org.stellar.anchor.platform.subtest.Sep12Tests.Companion.testCustomer1Json
import org.stellar.anchor.platform.subtest.Sep12Tests.Companion.testCustomer2Json
import org.stellar.anchor.platform.integrationtest.Sep12Tests.Companion.testCustomer1Json
import org.stellar.anchor.platform.integrationtest.Sep12Tests.Companion.testCustomer2Json
import org.stellar.anchor.platform.suite.AbstractIntegrationTests
import org.stellar.anchor.util.GsonUtils
import org.stellar.anchor.util.StringHelper.json

Expand All @@ -36,7 +37,7 @@ lateinit var savedTxn: Sep31GetTransactionResponse
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@Execution(SAME_THREAD)
@TestMethodOrder(MethodOrderer.OrderAnnotation::class)
class Sep31Tests : SepTests(TestConfig(testProfileName = "default")) {
class Sep31Tests : AbstractIntegrationTests(TestConfig(testProfileName = "default")) {
private val sep12Client: Sep12Client
private val sep31Client: Sep31Client
private val sep38Client: Sep38Client
Expand Down Expand Up @@ -226,7 +227,6 @@ class Sep31Tests : SepTests(TestConfig(testProfileName = "default")) {
}

@Test
@Order(35)
fun testBadAsset() {
val customer =
GsonUtils.getInstance().fromJson(testCustomer1Json, Sep12PutCustomerRequest::class.java)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.stellar.anchor.platform.subtest
package org.stellar.anchor.platform.integrationtest

import java.time.Instant
import java.time.format.DateTimeFormatter
Expand All @@ -11,8 +11,9 @@ import org.stellar.anchor.platform.Sep38Client
import org.stellar.anchor.platform.TestConfig
import org.stellar.anchor.platform.printRequest
import org.stellar.anchor.platform.printResponse
import org.stellar.anchor.platform.suite.AbstractIntegrationTests

class Sep38Tests : SepTests(TestConfig(testProfileName = "default")) {
class Sep38Tests : AbstractIntegrationTests(TestConfig(testProfileName = "default")) {
private val sep38Client: Sep38Client =
Sep38Client(toml.getString("ANCHOR_QUOTE_SERVER"), this.token.token)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package org.stellar.anchor.platform.subtest
package org.stellar.anchor.platform.integrationtest

import org.junit.jupiter.api.Test
import org.skyscreamer.jsonassert.JSONAssert
import org.skyscreamer.jsonassert.JSONCompareMode
import org.stellar.anchor.platform.Sep6Client
import org.stellar.anchor.platform.TestConfig
import org.stellar.anchor.platform.gson
import org.stellar.anchor.platform.suite.AbstractIntegrationTests

class Sep6Tests : SepTests(TestConfig(testProfileName = "default")) {
class Sep6Tests : AbstractIntegrationTests(TestConfig(testProfileName = "default")) {
private val sep6Client = Sep6Client(toml.getString("TRANSFER_SERVER"))

private val expectedSep6Info =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.stellar.anchor.platform.subtest
package org.stellar.anchor.platform.integrationtest

import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.stellar.anchor.platform.subtest
package org.stellar.anchor.platform.integrationtest

import java.util.concurrent.TimeUnit
import okhttp3.OkHttpClient
Expand All @@ -7,8 +7,9 @@ import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import org.stellar.anchor.platform.TestConfig
import org.stellar.anchor.platform.gson
import org.stellar.anchor.platform.suite.AbstractIntegrationTests

class StellarObserverTests : SepTests(TestConfig(testProfileName = "default")) {
class StellarObserverTests : AbstractIntegrationTests(TestConfig(testProfileName = "default")) {
companion object {
const val OBSERVER_HEALTH_SERVER_PORT = 8083
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.stellar.anchor.platform.subtest
package org.stellar.anchor.platform.suite

import io.ktor.client.plugins.*
import io.ktor.http.*
Expand All @@ -13,16 +13,16 @@ import org.stellar.walletsdk.anchor.auth
import org.stellar.walletsdk.auth.AuthToken
import org.stellar.walletsdk.horizon.SigningKeyPair

abstract class SepTests(val config: TestConfig) {
val toml: TomlContent =
abstract class AbstractIntegrationTests(val config: TestConfig) {
var toml: TomlContent =
parse(resourceAsString("${config.env["anchor.domain"]}/.well-known/stellar.toml"))
val wallet =
var wallet =
Wallet(
StellarConfiguration.Testnet,
ApplicationConfiguration { defaultRequest { url { protocol = URLProtocol.HTTP } } }
)
val walletKeyPair = SigningKeyPair.fromSecret(CLIENT_WALLET_SECRET)
val anchor = wallet.anchor(config.env["anchor.domain"]!!)
var walletKeyPair = SigningKeyPair.fromSecret(CLIENT_WALLET_SECRET)
var anchor = wallet.anchor(config.env["anchor.domain"]!!)
var token: AuthToken

init {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ package org.stellar.anchor.platform.suite
import org.junit.platform.suite.api.SelectPackages
import org.junit.platform.suite.api.Suite

@Suite @SelectPackages("org.stellar.anchor.platform.e2e_test") class End2EndTests
@Suite @SelectPackages("org.stellar.anchor.platform.e2etest") class End2EndTests
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ package org.stellar.anchor.platform.suite
import org.junit.platform.suite.api.SelectPackages
import org.junit.platform.suite.api.Suite

@Suite @SelectPackages("org.stellar.anchor.platform.subtest") class IntegrationTests
@Suite @SelectPackages("org.stellar.anchor.platform.integrationtest") class IntegrationTests
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import org.stellar.anchor.api.sep.sep31.Sep31PostTransactionRequest
import org.stellar.anchor.apiclient.PlatformApiClient
import org.stellar.anchor.auth.AuthHelper
import org.stellar.anchor.platform.*
import org.stellar.anchor.platform.subtest.Sep12Tests.Companion.testCustomer1Json
import org.stellar.anchor.platform.subtest.Sep12Tests.Companion.testCustomer2Json
import org.stellar.anchor.platform.integrationtest.Sep12Tests.Companion.testCustomer1Json
import org.stellar.anchor.platform.integrationtest.Sep12Tests.Companion.testCustomer2Json
import org.stellar.anchor.util.GsonUtils
import org.stellar.anchor.util.Log.info
import org.stellar.anchor.util.MemoHelper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import org.stellar.anchor.api.sep.sep31.Sep31PostTransactionRequest
import org.stellar.anchor.apiclient.PlatformApiClient
import org.stellar.anchor.auth.AuthHelper
import org.stellar.anchor.platform.*
import org.stellar.anchor.platform.subtest.Sep12Tests.Companion.testCustomer1Json
import org.stellar.anchor.platform.subtest.Sep12Tests.Companion.testCustomer2Json
import org.stellar.anchor.platform.integrationtest.Sep12Tests.Companion.testCustomer1Json
import org.stellar.anchor.platform.integrationtest.Sep12Tests.Companion.testCustomer2Json
import org.stellar.anchor.util.GsonUtils
import org.stellar.anchor.util.Log.info
import org.stellar.anchor.util.MemoHelper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import java.nio.charset.StandardCharsets.UTF_8
import org.springframework.core.io.DefaultResourceLoader
import org.springframework.util.FileCopyUtils
import org.stellar.anchor.util.GsonUtils
import org.stellar.anchor.util.Log.debug
import org.stellar.anchor.util.StringHelper.json

val gson: Gson = GsonUtils.getInstance()
Expand All @@ -19,8 +20,7 @@ fun resourceAsString(path: String): String {
fun printRequest(title: String?, payload: Any? = null) {
if (title != null) println(title)
if (payload != null) {
print("request=")
println(if (payload is String) payload else json(payload))
debug("request=" + if (payload is String) payload else json(payload))
}
}

Expand All @@ -31,8 +31,7 @@ fun printResponse(payload: Any?) {
fun printResponse(title: String?, payload: Any?) {
if (title != null) println(title)
if (payload != null) {
print("response=")
println(if (payload is String) payload else json(payload))
debug("response=" + if (payload is String) payload else json(payload))
}
println()
}

0 comments on commit 95cf596

Please sign in to comment.