Skip to content

Commit

Permalink
Merge branch 'develop' into main-to-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Ifropc authored Aug 4, 2023
2 parents 78b4648 + 7fa8cb2 commit 050d85b
Show file tree
Hide file tree
Showing 37 changed files with 989 additions and 101 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/sub_gradle_test_and_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ jobs:
sudo echo "127.0.0.1 db" | sudo tee -a /etc/hosts
sudo echo "127.0.0.1 zookeeper" | sudo tee -a /etc/hosts
sudo echo "127.0.0.1 kafka" | sudo tee -a /etc/hosts
sudo echo "127.0.0.1 reference-server" | sudo tee -a /etc/hosts
sudo echo "127.0.0.1 sep24-reference-ui" | sudo tee -a /etc/hosts
sudo echo "127.0.0.1 reference-server" | sudo tee -a /etc/hosts
sudo echo "127.0.0.1 wallet-server" | sudo tee -a /etc/hosts
sudo echo "127.0.0.1 platform" | sudo tee -a /etc/hosts
sudo echo "127.0.0.1 host.docker.internal" | sudo tee -a /etc/hosts
- name: Build and run the stack with docker compose
env:
TEST_PROFILE_NAME: default
Expand All @@ -47,7 +47,7 @@ jobs:
- name: Gradle test and build. (unit tests, integration tests, end-2-end tests and build)
env:
run_docker: false
run: ./gradlew clean build --no-daemon --stacktrace
run: ./gradlew clean build --no-daemon --stacktrace -x test

- name: Stop docker containers
env:
Expand All @@ -62,6 +62,17 @@ jobs:
- name: Run sep server, observer, java reference server and kotlin reference server
env:
run_docker: false
run_all_servers: false
run_sep_server: true
run_platform_server: true
run_reference_server: true
run_observer: true
run_kotlin_reference_server: true
# Running wallet server is not required for sep tests. However, running wallet server
# and kotlin reference server at the same time causes `ktor` to block the JVM.
# If we need to run both `ktor` servers, we will need to run them in separate JVMs.
run_wallet_server: false

SEP1_TOML_VALUE: service-runner/src/main/resources/config/stellar.host.docker.internal.toml
SEP10_HOME_DOMAIN: host.docker.internal:8080
run: |
Expand Down
3 changes: 3 additions & 0 deletions .run/Run - All Servers - no Docker.run.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run - All Servers - no Docker" type="JetRunConfigurationType">
<envs>
<env name="sep24.enableTest" value="true" />
</envs>
<option name="MAIN_CLASS_NAME" value="org.stellar.anchor.platform.run_profiles.RunAllServers" />
<module name="java-stellar-anchor-sdk.service-runner.main" />
<shortenClasspath name="ARGS_FILE" />
Expand Down
3 changes: 0 additions & 3 deletions .run/Run - Event Processing Server - no Docker .run.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run - Event Processing Server - no Docker " type="JetRunConfigurationType">
<envs>
<env name="TEST_PROFILE_NAME" value="sep24" />
</envs>
<option name="MAIN_CLASS_NAME" value="org.stellar.anchor.platform.run_profiles.RunEventProcessingServer" />
<module name="java-stellar-anchor-sdk.service-runner.main" />
<shortenClasspath name="ARGS_FILE" />
Expand Down
3 changes: 2 additions & 1 deletion .run/Run - Kotlin Reference Server - no Docker.run.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run - Kotlin Reference Server - no Docker" type="JetRunConfigurationType">
<envs>
<env name="sep24.enableTest" value="false" />
<env name="TEST_PROFILE_NAME" value="sep24" />
<env name="sep24.enableTest" value="true" />
</envs>
<option name="MAIN_CLASS_NAME" value="org.stellar.anchor.platform.run_profiles.RunKotlinReferenceServer" />
<module name="java-stellar-anchor-sdk.service-runner.main" />
Expand Down
10 changes: 10 additions & 0 deletions .run/Run - Wallet Reference Server - no Docker.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run - Wallet Reference Server - no Docker" type="JetRunConfigurationType">
<option name="MAIN_CLASS_NAME" value="org.stellar.anchor.platform.run_profiles.RunWalletServer" />
<module name="java-stellar-anchor-sdk.service-runner.main" />
<shortenClasspath name="ARGS_FILE" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
4 changes: 2 additions & 2 deletions core/src/main/java/org/stellar/anchor/util/OkHttpUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static Request buildGetRequest(String url) {
return new Request.Builder().url(url).get().build();
}

public static RequestBody buildJsonRequestBody(String requestBody) {
return RequestBody.create(requestBody, TYPE_JSON);
public static RequestBody buildJsonRequestBody(String payload) {
return RequestBody.create(payload, TYPE_JSON);
}
}
5 changes: 3 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ commons-codec = { module = "commons-codec:commons-codec", version.ref = "commons
commons-io = { module = "commons-io:commons-io", version.ref = "commons-io" }
commons-validator = { module = "commons-validator:commons-validator", version.ref = "commons-validator" }
coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
docker-compose-rule = {module = "com.palantir.docker.compose:docker-compose-junit-jupiter", version.ref = "docker-compose-rule" }
docker-compose-rule = { module = "com.palantir.docker.compose:docker-compose-junit-jupiter", version.ref = "docker-compose-rule" }
dotenv = { module = "io.github.cdimascio:dotenv-java", version.ref = "dotenv" }
findbugs-jsr305 = { module = "com.google.code.findbugs:jsr305", version.ref = "findbugs-jsr305" }
flyway-core = { module = "org.flywaydb:flyway-core", version.ref = "flyway-core" }
Expand Down Expand Up @@ -110,6 +110,7 @@ ktor-client-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version
ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" }
ktor-netty = { module = "io.ktor:ktor-server-netty-jvm", version.ref = "ktor" }
ktor-yaml = { module = "io.ktor:ktor-server-config-yaml", version.ref = "ktor" }
ktor-server-call-logging = { module = "io.ktor:ktor-server-call-logging", version.ref = "ktor" }
log4j2-slf4j = { module = "org.apache.logging.log4j:log4j-slf4j-impl", version.ref = "log4j" }
log4j2-core = { module = "org.apache.logging.log4j:log4j-core", version.ref = "log4j" }
log4j2-api = { module = "org.apache.logging.log4j:log4j-api", version.ref = "log4j" }
Expand All @@ -130,7 +131,7 @@ servlet-api = { module = "javax.servlet:servlet-api", version.ref = "servlet-api
sqlite-jdbc = { module = "org.xerial:sqlite-jdbc", version.ref = "sqlite-jdbc" }
slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }
slf4j-log4j12 = { module = "org.slf4j:slf4j-log4j12", version.ref = "slf4j" }
stellar-wallet-sdk = { module = "org.stellar:wallet-sdk", version.ref = "stellar-wallet-sdk"}
stellar-wallet-sdk = { module = "org.stellar:wallet-sdk", version.ref = "stellar-wallet-sdk" }
toml4j = { module = "com.moandjiezana.toml:toml4j", version.ref = "toml4j" }
spring-kafka = { module = "org.springframework.kafka:spring-kafka", version.ref = "spring-kafka" }
spring-data-commons = { module = "org.springframework.data:spring-data-commons", version.ref = "spring-boot" }
Expand Down
1 change: 1 addition & 0 deletions integration-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ dependencies {
implementation(project(":platform"))
implementation(project(":anchor-reference-server"))
implementation(project(":kotlin-reference-server"))
implementation(project(":wallet-reference-server"))
implementation(project(":service-runner"))

annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.stellar.anchor.platform

import org.junit.jupiter.api.Assertions.assertFalse
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
import org.stellar.anchor.platform.event.ClientStatusCallbackHandler
import org.stellar.reference.wallet.CallbackService.Companion.verifySignature
import org.stellar.sdk.KeyPair
import org.stellar.sdk.KeyPair.*

val signerSecret: KeyPair =
fromSecretSeed("SAX3AH622R2XT6DXWWSRIDCMMUCCMATBZ5U6XKJWDO7M2EJUBFC3AW5X")
val signerPublic: KeyPair =
fromAccountId("GCHLHDBOKG2JWMJQBTLSL5XG6NO7ESXI2TAQKZXCXWXB5WI2X6W233PR")

class CallbackSignatureTest {
@Test
fun `test the SEP24 callback signature creation and verification`() {
// create the request with the secret-key signer
val request =
ClientStatusCallbackHandler.buildHttpRequest(
signerSecret,
"test_payload",
"http://localhost:8092/callbacks"
)

val signature = request.header("Signature")
// verify the signature with the public-key signer
assertTrue(verifySignature(signature, "test_payload", "localhost:8092", signerPublic))
assertFalse(verifySignature(signature, "test_payload_bad", "localhost:8092", random()))
}
}
Loading

0 comments on commit 050d85b

Please sign in to comment.