diff --git a/tests/integration-tests/src/test/kotlin/common/TestConstants.kt b/tests/integration-tests/src/test/kotlin/common/TestConstants.kt index 694049f6e1..059862eec6 100644 --- a/tests/integration-tests/src/test/kotlin/common/TestConstants.kt +++ b/tests/integration-tests/src/test/kotlin/common/TestConstants.kt @@ -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", diff --git a/tests/integration-tests/src/test/kotlin/features/Init.kt b/tests/integration-tests/src/test/kotlin/features/Init.kt index bc525f245b..62300490d6 100644 --- a/tests/integration-tests/src/test/kotlin/features/Init.kt +++ b/tests/integration-tests/src/test/kotlin/features/Init.kt @@ -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 @@ -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() @@ -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("AUTH_KEY") != null) { + spec.addHeader(actor.recall("AUTH_HEADER"), actor.recall("AUTH_KEY")) + } + if (actor.recall("BEARER_TOKEN") != null) { + spec.addHeader("Authorization", "Bearer ${actor.recall("BEARER_TOKEN")}") + } + RestAssured + .given().spec(spec.build()) .body(CreateWebhookNotification(url = webhookUrl)) .post("/events/webhooks") .then().statusCode(HttpStatus.SC_OK) @@ -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) diff --git a/tests/integration-tests/src/test/resources/configs/two_agents_basic.conf b/tests/integration-tests/src/test/resources/configs/two_agents_basic.conf new file mode 100644 index 0000000000..e0872d258c --- /dev/null +++ b/tests/integration-tests/src/test/resources/configs/two_agents_basic.conf @@ -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 + } + } +] diff --git a/tests/integration-tests/src/test/resources/configs/two_agents_sharing_keycloak.conf b/tests/integration-tests/src/test/resources/configs/two_agents_sharing_keycloak.conf index 5740b2789b..e628606fa3 100644 --- a/tests/integration-tests/src/test/resources/configs/two_agents_sharing_keycloak.conf +++ b/tests/integration-tests/src/test/resources/configs/two_agents_sharing_keycloak.conf @@ -15,7 +15,7 @@ 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} }, @@ -23,7 +23,7 @@ agents = [ 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} }