Skip to content

Commit

Permalink
test: enable testing remote environments with auth header (#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
abalias authored Dec 13, 2022
1 parent 2490f73 commit 784ef50
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
29 changes: 29 additions & 0 deletions infrastructure/multi/run-e2e-tests-local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

set -e

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

echo "--------------------------------------"
echo "Starting issuer using local/run.sh"
echo "--------------------------------------"

${SCRIPT_DIR}/../local/run.sh -p 8080 -n issuer -b

echo "--------------------------------------"
echo "Starting holder using local/run.sh"
echo "--------------------------------------"

${SCRIPT_DIR}/../local/run.sh -p 8090 -n holder -b

echo "--------------------------------------"
echo "Starting verifier using local/run.sh"
echo "--------------------------------------"

${SCRIPT_DIR}/../local/run.sh -p 8100 -n verifier -b

echo "--------------------------------------"
echo "Run e2e tests"
echo "--------------------------------------"

(cd ${SCRIPT_DIR}/../../tests/e2e-tests/; ./gradlew test reports)
15 changes: 15 additions & 0 deletions infrastructure/multi/run-e2e-tests-remote.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

set -e

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

echo "--------------------------------------"
echo "Run e2e tests"
echo "--------------------------------------"

export ACME_AGENT_URL=https://agent-df56h.atalaprism.io/prism-agent
export BOB_AGENT_URL=https://agent-kj46b.atalaprism.io/prism-agent
export MALLORY_AGENT_URL=https://agent-sd98k.atalaprism.io/prism-agent

(cd ${SCRIPT_DIR}/../../tests/e2e-tests/; AGENT_AUTH_REQUIRED=true ./gradlew test reports)
13 changes: 13 additions & 0 deletions tests/e2e-tests/src/test/kotlin/common/Agents.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package common

import io.restassured.builder.RequestSpecBuilder
import net.serenitybdd.rest.SerenityRest
import net.serenitybdd.screenplay.Actor
import net.serenitybdd.screenplay.rest.abilities.CallAnApi

Expand All @@ -11,6 +13,17 @@ object Agents {
lateinit var Mallory: Actor
private set

init {
if (Environments.AGENT_AUTH_REQUIRED) {
SerenityRest.setDefaultRequestSpecification(
RequestSpecBuilder().addHeader(
Environments.AGENT_AUTH_HEADER,
Environments.AGENT_AUTH_KEY)
.build()
)
}
}

fun createAgents() {
Acme = Actor.named("Acme").whoCan(CallAnApi.at(Environments.ACME_AGENT_URL))
Bob = Actor.named("Bob").whoCan(CallAnApi.at(Environments.BOB_AGENT_URL))
Expand Down
3 changes: 3 additions & 0 deletions tests/e2e-tests/src/test/kotlin/common/Environments.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package common

object Environments {
val AGENT_AUTH_REQUIRED: Boolean = System.getenv("AGENT_AUTH_REQUIRED").toBoolean()
val AGENT_AUTH_HEADER = System.getenv("AGENT_AUTH_HEADER") ?: "apikey"
val AGENT_AUTH_KEY = System.getenv("AGENT_AUTH_KEY") ?: ""
val ACME_AGENT_URL = System.getenv("ACME_AGENT_URL") ?: "http://localhost:8080/prism-agent"
val BOB_AGENT_URL = System.getenv("BOB_AGENT_URL") ?: "http://localhost:8090/prism-agent"
val MALLORY_AGENT_URL = System.getenv("MALLORY_AGENT_URL") ?: "http://localhost:8100/prism-agent"
Expand Down

0 comments on commit 784ef50

Please sign in to comment.