Skip to content

Commit

Permalink
test: fix integration tests (#57)
Browse files Browse the repository at this point in the history
Signed-off-by: Anton <Baliasnikov>
  • Loading branch information
Anton Baliasnikov authored and Anton committed Apr 30, 2024
1 parent 2d9f7b5 commit 547555b
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 60 deletions.
24 changes: 6 additions & 18 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ jobs:
name: "Run integration tests"
runs-on: ubuntu-latest
env:
GITHUB_ACTOR: ${{ secrets.ATALA_GITHUB_ACTOR }}
GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}
ATALA_GITHUB_ACTOR: ${{ secrets.ATALA_GITHUB_ACTOR }}
ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}
REPORTS_DIR: "tests/mediator-integration-tests/target/site/serenity"
steps:
- name: Checkout
Expand Down Expand Up @@ -55,11 +59,10 @@ jobs:
- name: Build local version of Mediator Agent
env:
MEDIATOR_PATH: "../.."
GITHUB_ACTOR: ${{ secrets.ATALA_GITHUB_ACTOR }}
GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}
NODE_OPTIONS: "--openssl-legacy-provider"
run: |
cd "${MEDIATOR_PATH}" || exit 129
NODE_OPTIONS=--openssl-legacy-provider sbt -mem 2048 -J-Xmx5120m docker:publishLocal
sbt -mem 2048 -J-Xmx5120m docker:publishLocal
MEDIATOR_VERSION=$(cut version.sbt -d '=' -f2 | tr -d '" ')
echo "MEDIATOR_VERSION=${MEDIATOR_VERSION}" >> $GITHUB_ENV
echo ${MEDIATOR_VERSION}
Expand All @@ -71,26 +74,11 @@ jobs:
up-flags: "--wait"
down-flags: "--volumes"
- name: Run e2e tests
env:
GITHUB_ACTOR: ${{ secrets.ATALA_GITHUB_ACTOR }}
GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}
ATALA_GITHUB_ACTOR: ${{ secrets.ATALA_GITHUB_ACTOR }}
ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}
MEDIATOR_PEER_DID: "did:peer:2.Ez6LSghwSE437wnDE1pt3X6hVDUQzSjsHzinpX3XFvMjRAm7y.Vz6Mkhh1e5CEYYq6JBUcTZ6Cp2ranCWRrv7Yax3Le4N59R6dd.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9rOHMtaW50LmF0YWxhcHJpc20uaW8vbWVkaWF0b3IiLCJyIjpbXSwiYSI6WyJkaWRjb21tL3YyIl19"
continue-on-error: true
run: |
./gradlew test || true
./gradlew reports
# - name: Update X-Ray test execution
# uses: ./.github/actions/upload-to-xray
# if: github.ref_name == 'main'
# with:
# username: ${{ secrets.XRAY_CLIENT_ID }}
# password: ${{ secrets.XRAY_CLIENT_SECRET }}
# json: "tests/e2e-tests/target/serenity-reports/cucumber_report.json"
# execution_tag: ${{ env.XRAY_EXECUTION_TAG_LOCALHOST }}

- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
Expand Down
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ lazy val mediator = project
Docker / maintainer := "[email protected]",
Docker / dockerUsername := Some("input-output-hk"),
Docker / dockerRepository := Some("ghcr.io"),
Docker / packageName := "atala-prism-mediator",
dockerExposedPorts := Seq(8080),
dockerBaseImage := "openjdk:11",
)
Expand Down
19 changes: 7 additions & 12 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,28 @@ services:
- MONGO_INITDB_DATABASE=mediator
volumes:
- ./initdb.js:/docker-entrypoint-initdb.d/initdb.js
# - ./:/opt/keyfile/
# healthcheck:
# test: test $$(echo "rs.initiate().ok || rs.status().ok" | mongo -u $${MONGO_INITDB_ROOT_USERNAME} -p $${MONGO_INITDB_ROOT_PASSWORD} --quiet) -eq 1
# interval: 10s
# start_period: 30s

atalaprism-mediator:
image: ghcr.io/input-output-hk/mediator:${MEDIATOR_VERSION:-0.2.0-SNAPSHOT}
image: ghcr.io/input-output-hk/atala-prism-mediator:${MEDIATOR_VERSION:-0.2.0-SNAPSHOT}
ports:
- 8080:8080
network_mode: host #hash on mac remove this the default is bridge we can use host.docker.internal
environment:
# Creates the identity: "did:peer:2.Ez6LSghwSE437wnDE1pt3X6hVDUQzSjsHzinpX3XFvMjRAm7y.Vz6Mkhh1e5CEYYq6JBUcTZ6Cp2ranCWRrv7Yax3Le4N59R6dd.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9rOHMtaW50LmF0YWxhcHJpc20uaW8vbWVkaWF0b3IiLCJyIjpbXSwiYSI6WyJkaWRjb21tL3YyIl19"
# Creates the identity:
- KEY_AGREEMENT_D=Z6D8LduZgZ6LnrOHPrMTS6uU2u5Btsrk1SGs4fn8M7c
- KEY_AGREEMENT_X=Sr4SkIskjN_VdKTn0zkjYbhGTWArdUNE4j_DmUpnQGw
- KEY_AUTHENTICATION_D=INXCnxFEl0atLIIQYruHzGd5sUivMRyQOzu87qVerug
- KEY_AUTHENTICATION_X=MBjnXZxkMcoQVVL21hahWAw43RuAG-i64ipbeKKqwoA
- SERVICE_ENDPOINT=https://k8s-int.atalaprism.io/mediator
# Config storage
#- DB_URL=mongodb://admin:admin@localhost:27017
# - SERVICE_ENDPOINT=https://k8s-int.atalaprism.io/mediator
- MONGODB_USER=admin
- MONGODB_PASSWORD=admin
- MONGODB_PROTOCOL=mongodb
- MONGODB_HOST=localhost
- MONGODB_HOST=mongo
- MONGODB_PORT=27017
- MONGODB_DB_NAME=mediator
depends_on:
- "mongo"
extra_hosts:
- "host.docker.internal:host-gateway"


# RUN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ object HttpListener {
post("/") {
val json = call.receiveText()
receivedResponse = json
call.respond(HttpStatusCode.OK, "Data received")
call.respond(HttpStatusCode.OK)
}
}
}
Expand All @@ -35,7 +35,7 @@ object HttpListener {
}

fun endpoint(): String {
return "http://${Environments.RECIPIENT_LISTENER_HOST}:${Environments.RECIPIENT_LISTENER_PORT}"
return "http://host.docker.internal:${Environments.RECIPIENT_LISTENER_PORT}"
}

fun receivedResponse(): String? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package common
import io.iohk.atala.prism.walletsdk.domain.models.DID

object Environments {
val MEDIATOR_PEER_DID = DID(System.getenv("MEDIATOR_PEER_DID") ?: "did:peer:2.Ez6LSfKLqi2VZj2p84qE2AnHCv4YQtJoZXG7SmxoFGiqLuqa8.Vz6Mkf92NMfWKgLWYpGUfmsGiuEQfQSoLCuKDmFAhxQgkCUFY.SeyJ0IjoiZG0iLCJzIjoiaHR0cDovL2xvY2FsaG9zdDo4MDgwIiwiciI6W10sImEiOlsiZGlkY29tbS92MiJdfQ")
val MEDIATOR_PEER_DID = DID(System.getenv("MEDIATOR_PEER_DID") ?: "did:peer:2.Ez6LSghwSE437wnDE1pt3X6hVDUQzSjsHzinpX3XFvMjRAm7y.Vz6Mkhh1e5CEYYq6JBUcTZ6Cp2ranCWRrv7Yax3Le4N59R6dd.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9tZWRpYXRvci10ZXN0LWVudi5hdGFsYXByaXNtLmlvL21lZGlhdG9yIiwiciI6W10sImEiOlsiZGlkY29tbS92MiJdfQ")
val MEDIATOR_URL = System.getenv("MEDIATOR_URL") ?: "http://localhost:8080"
val RECIPIENT_LISTENER_HOST = System.getenv("RECIPIENT_LISTENER_URL") ?: "0.0.0.0"
val RECIPIENT_LISTENER_PORT = (System.getenv("RECIPIENT_LISTENER_PORT") ?: "9999").toInt()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,26 +95,28 @@ class MediationCoordinationSteps {

@When("{actor} sends a keylist query message to the mediator")
fun recipientSendsAKeylistQueryMessageToTheMediator(recipient: Actor) {
TODO("Not supported by the PRISM Mediator yet")
// val keylistUpdateMessage = Message(
// piuri = DidcommMessageTypes.MEDIATE_KEYLIST_QUERY,
// from = EdgeAgent.peerDID,
// to = Environments.MEDIATOR_PEER_DID,
// body = MediationKeylistQueryRequest(
// paginate = Paginate(
// limit = 2,
// offset = 0
// )
// ).toJsonString()
// )
// recipient.attemptsTo(
// SendDidcommMessage(keylistUpdateMessage)
// )
val keyListQueryMessage = Message(
piuri = DidcommMessageTypes.MEDIATE_KEYLIST_QUERY,
from = EdgeAgent.peerDID,
to = Environments.MEDIATOR_PEER_DID,
body = MediationKeylistQueryRequest(
paginate = Paginate(
limit = 2,
offset = 0
)
).toJsonString()
)
recipient.attemptsTo(
SendDidcommMessage(keyListQueryMessage)
)
}

@Then("Mediator responds to {actor} with keylist message containing the current list of keys")
fun mediatorRespondsToRecipientWithKeylistMessageContainingTheCurrentListOfKeys(recipient: Actor) {
TODO("Not supported by the PRISM Mediator yet")
val didcommMessage = EdgeAgent.unpackLastDidcommMessage()
recipient.attemptsTo(
Ensure.that(didcommMessage.piuri).isEqualTo(DidcommMessageTypes.MEDIATE_KEYLIST_RESPONSE)
)
}

@When("{actor} sends a keylist update message to the mediator to remove the last alias")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ class PingProtocolSteps {

@Then("{actor} gets trusted ping message back")
fun recipientGetTrustedPingMessageBack(recipient: Actor) {

println(HttpListener.receivedResponse()!!)

val didcommResponse: Message = EdgeAgent.unpackMessage(
HttpListener.receivedResponse()!!
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ Scenario: Successful Mediation Request
When Recipient sends a mediate request message to the mediator
Then Mediator responds to Recipient with mediate grant message

# BUG: field should be called recipient_did instead of routing_did, Fabio to fix soon
# https://input-output.atlassian.net/browse/ATL-4845
Scenario: Recipient adds new key to keylist
Given Recipient successfully set up a connection with the mediator
When Recipient sends a keylist update message to the mediator with a new peer did
Expand All @@ -17,22 +15,17 @@ Scenario: Recipient removes alias from keylist
When Recipient sends a keylist update message to the mediator to remove added alias
Then Mediator responds to Recipient with a correct keylist update remove message

# BUG: server-error is returned, lets change to no_change
# https://input-output.atlassian.net/browse/ATL-4847
Scenario: Recipient removes not existing alias
Given Recipient successfully set up a connection with the mediator
When Recipient sends a keylist update message to the mediator to remove not existing alias
Then Mediator responds to Recipient with a message with no_change status

# https://input-output.atlassian.net/browse/ATL-4848
# https://input-output.atlassian.net/browse/ATL-5020
@BUG_ATL-5020
Scenario: Recipient removes the last alias from keylist
Given Recipient successfully set up a connection with the mediator
When Recipient sends a keylist update message to the mediator to remove the last alias
Then Mediator responds to Recipient with a correct keylist update remove message

# NOT IMPLEMENTED YET
# NOT SUPPORTED YET
#Scenario: Recipient query keylist
# Given Recipient successfully set up a connection with the mediator
# When Recipient sends a keylist query message to the mediator
Expand Down

0 comments on commit 547555b

Please sign in to comment.