Skip to content

Commit

Permalink
test: fix multi-agent config support (#799)
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Baliasnikov <[email protected]>
  • Loading branch information
Anton Baliasnikov authored Nov 27, 2023
1 parent 5e249bb commit 6c6b129
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import java.time.Duration
import java.util.*

object TestConstants {
val TESTS_CONFIG = System.getenv("TESTS_CONFIG") ?: "/configs/basic.conf"
val TESTS_CONFIG = System.getenv("TESTS_CONFIG") ?: "/configs/two_agents_basic.conf"
val TEST_VERIFICATION_POLICY = VerificationPolicyInput(
name = "Trusted Issuer and SchemaID",
description = "Verification Policy with trusted issuer and schemaId",
Expand Down
22 changes: 16 additions & 6 deletions tests/integration-tests/src/test/kotlin/features/Init.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import com.sksamuel.hoplite.ConfigLoader
import common.ListenToEvents
import common.TestConstants
import config.Config
import interactions.Post
import io.cucumber.java.AfterAll
import io.cucumber.java.BeforeAll
import io.iohk.atala.prism.models.CreateWalletRequest
import io.iohk.atala.prism.models.CreateWebhookNotification
import io.restassured.RestAssured
import io.restassured.builder.RequestSpecBuilder
import net.serenitybdd.screenplay.Actor
import net.serenitybdd.screenplay.actors.Cast
import net.serenitybdd.screenplay.actors.OnStage
Expand Down Expand Up @@ -43,8 +44,10 @@ fun initActors() {
* @param actor The actor for which the wallet should be initialized.
*/
fun initializeWallet(actor: Actor) {
Post("")
.specWithAuthHeaders(actor)
RestAssured
.given()
.baseUri(actor.usingAbilityTo(CallAnApi::class.java).resolve("/"))
.auth().oauth2(actor.recall("BEARER_TOKEN"))
.body(
CreateWalletRequest(
name = UUID.randomUUID().toString()
Expand All @@ -61,8 +64,16 @@ fun initActors() {
* @param webhookUrl The url of the webhook.
*/
fun registerWebhook(actor: Actor, webhookUrl: String) {
Post("")
.specWithAuthHeaders(actor)
val spec = RequestSpecBuilder()
.setBaseUri(actor.usingAbilityTo(CallAnApi::class.java).resolve("/"))
if (actor.recall<String>("AUTH_KEY") != null) {
spec.addHeader(actor.recall("AUTH_HEADER"), actor.recall("AUTH_KEY"))
}
if (actor.recall<String>("BEARER_TOKEN") != null) {
spec.addHeader("Authorization", "Bearer ${actor.recall<String>("BEARER_TOKEN")}")
}
RestAssured
.given().spec(spec.build())
.body(CreateWebhookNotification(url = webhookUrl))
.post("/events/webhooks")
.then().statusCode(HttpStatus.SC_OK)
Expand All @@ -86,7 +97,6 @@ fun initActors() {
}
}
config.roles.forEach { role ->
println(role.name)
val actor = cast.actorNamed(role.name)
if (role.apikey != null) {
actor.remember("AUTH_KEY", role.apikey)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Specify shared services that are used by all agents (if any)
services = {
prism_node = {
http_port = 50053
version = "${PRISM_NODE_VERSION}"
}
}

# Specify agents that are required to be created before running tests
agents = [
{
version = "${OPEN_ENTERPRISE_AGENT_VERSION}"
http_port = 8080
didcomm_port = 7080
auth_enabled = true
prism_node = ${services.prism_node}
},
{
version = "${OPEN_ENTERPRISE_AGENT_VERSION}"
http_port = 8090
didcomm_port = 7090
auth_enabled = true
prism_node = ${services.prism_node}
}
]

roles = [
{
name = "Admin"
url = "${ADMIN_AGENT_URL:-http://localhost:8080}"
apikey = "${ADMIN_API_KEY:-admin}"
auth_header = "x-admin-api-key"
}
{
name = "Issuer"
url = "${ISSUER_AGENT_URL:-http://localhost:8080}"
apikey = "${ISSUER_API_KEY:-${random.string(16)}}"
webhook = {
url = "${ISSUER_WEBHOOK_URL:-http://host.docker.internal:9955}"
init_required = true
}
},
{
name = "Holder"
url = "${HOLDER_AGENT_URL:-http://localhost:8090}"
apikey = "${HOLDER_API_KEY:-${random.string(16)}}"
webhook = {
url = "${HOLDER_WEBHOOK_URL:-http://host.docker.internal:9956}"
init_required = true
}
},
{
name = "Verifier"
url = "${VERIFIER_AGENT_URL:-http://localhost:8080}"
apikey = "${VERIFIER_API_KEY:-${random.string(16)}}"
webhook = {
url = "${VERIFIER_WEBHOOK_URL:-http://host.docker.internal:9957}"
init_required = true
}
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ agents = [
version = "${OPEN_ENTERPRISE_AGENT_VERSION}"
http_port = 8080
didcomm_port = 7080
auth_enabled = true
auth_enabled = false
prism_node = ${services.prism_node}
keycloak = ${services.keycloak}
},
{
version = "${OPEN_ENTERPRISE_AGENT_VERSION}"
http_port = 8090
didcomm_port = 7090
auth_enabled = true
auth_enabled = false
prism_node = ${services.prism_node}
keycloak = ${services.keycloak}
}
Expand Down

0 comments on commit 6c6b129

Please sign in to comment.