diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 498e5619..42d801da 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -14,7 +14,6 @@ on: defaults: run: shell: bash - working-directory: "tests/mediator-integration-tests" jobs: run-integration-tests: @@ -25,11 +24,17 @@ jobs: 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" + REPORTS_DIR: "didcomm-v2-mediator-test-suite/target/site/serenity" steps: - - name: Checkout + - name: Checkout mediator uses: actions/checkout@v3 + - name: Checkout tests + uses: actions/checkout@v3 + with: + repository: input-output-hk/didcomm-v2-mediator-test-suite + path: './didcomm-v2-mediator-test-suite' + - name: Setup Java and Scala uses: olafurpg/setup-scala@v13 with: @@ -58,10 +63,8 @@ jobs: - name: Build local version of Mediator Agent env: - MEDIATOR_PATH: "../.." NODE_OPTIONS: "--openssl-legacy-provider" run: | - cd "${MEDIATOR_PATH}" || exit 129 sbt -mem 2048 -J-Xmx5120m docker:publishLocal MEDIATOR_VERSION=$(cut version.sbt -d '=' -f2 | tr -d '" ') echo "MEDIATOR_VERSION=${MEDIATOR_VERSION}" >> $GITHUB_ENV @@ -73,9 +76,10 @@ jobs: compose-flags: "" up-flags: "--wait" down-flags: "--volumes" - - name: Run e2e tests - continue-on-error: true + + - name: Run tests run: | + cd ./didcomm-v2-mediator-test-suite ./gradlew test || true ./gradlew reports diff --git a/tests/mediator-integration-tests/.gitignore b/tests/mediator-integration-tests/.gitignore deleted file mode 100644 index b63da455..00000000 --- a/tests/mediator-integration-tests/.gitignore +++ /dev/null @@ -1,42 +0,0 @@ -.gradle -build/ -!gradle/wrapper/gradle-wrapper.jar -!**/src/main/**/build/ -!**/src/test/**/build/ - -### IntelliJ IDEA ### -.idea/modules.xml -.idea/jarRepositories.xml -.idea/compiler.xml -.idea/libraries/ -*.iws -*.iml -*.ipr -out/ -!**/src/main/**/out/ -!**/src/test/**/out/ - -### Eclipse ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache -bin/ -!**/src/main/**/bin/ -!**/src/test/**/bin/ - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ - -### VS Code ### -.vscode/ - -### Mac OS ### -.DS_Store \ No newline at end of file diff --git a/tests/mediator-integration-tests/build.gradle.kts b/tests/mediator-integration-tests/build.gradle.kts deleted file mode 100644 index 9d97c93c..00000000 --- a/tests/mediator-integration-tests/build.gradle.kts +++ /dev/null @@ -1,84 +0,0 @@ -plugins { - kotlin("jvm") version "1.8.21" - kotlin("plugin.serialization") version "1.8.21" - idea - jacoco - id("net.serenity-bdd.serenity-gradle-plugin") version "3.4.2" -} - -group = "io.iog.mediator.tests" -version = "0.1.0-SNAPSHOT" - -repositories { - mavenLocal() - mavenCentral() - maven { - this.url = uri("https://maven.pkg.github.com/input-output-hk/atala-prism-wallet-sdk-kmm") - credentials { - this.username = System.getenv("ATALA_GITHUB_ACTOR") - this.password = System.getenv("ATALA_GITHUB_TOKEN") - } - } - maven { - this.url = uri("https://maven.pkg.github.com/input-output-hk/atala-prism-apollo") - credentials { - this.username = System.getenv("ATALA_GITHUB_ACTOR") - this.password = System.getenv("ATALA_GITHUB_TOKEN") - } - } - maven { - url = uri("https://maven.pkg.jetbrains.space/public/p/kotlinx-coroutines/maven") - } -} - -dependencies { - // Logging - implementation("org.slf4j:slf4j-log4j12:2.0.5") - // Beautify async waits - implementation("org.awaitility:awaitility-kotlin:4.2.0") - // Test engines and reports - testImplementation("junit:junit:4.13.2") - implementation("net.serenity-bdd:serenity-core:3.4.3") - implementation("net.serenity-bdd:serenity-cucumber:3.4.3") - implementation("net.serenity-bdd:serenity-screenplay-rest:3.4.3") - // https://mvnrepository.com/artifact/net.serenity-bdd/serenity-ensure - testImplementation("net.serenity-bdd:serenity-ensure:3.4.3") - // Beautify exceptions handling assertions - testImplementation("org.assertj:assertj-core:3.23.1") - // Navigate through Json with xpath - testImplementation("com.jayway.jsonpath:json-path:2.7.0") - implementation("io.iohk.atala.prism.walletsdk:atala-prism-sdk:0.1.1") - implementation("org.didcommx:didcomm:0.3.0") - implementation("org.didcommx:peerdid:0.3.0") - implementation("io.ktor:ktor-server-netty:2.3.0") - implementation("io.ktor:ktor-client-apache:2.3.0") - - // https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp - implementation("com.squareup.okhttp3:okhttp:4.11.0") - - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0") - -} - -buildscript { - dependencies { - classpath("net.serenity-bdd:serenity-single-page-report:3.4.3") - classpath("net.serenity-bdd:serenity-json-summary-report:3.4.3") - } -} - -/** - * Add HTML one-pager and JSON summary report to be produced - */ -serenity { - reports = listOf("single-page-html", "json-summary") -} - -tasks.test { - testLogging.showStandardStreams = true - systemProperty("cucumber.filter.tags", System.getProperty("cucumber.filter.tags")) -} - -kotlin { - jvmToolchain(11) -} diff --git a/tests/mediator-integration-tests/gradle.properties b/tests/mediator-integration-tests/gradle.properties deleted file mode 100644 index 55d63569..00000000 --- a/tests/mediator-integration-tests/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -kotlin.code.style=official -org.gradle.parallel=false -org.gradle.workers.max=1 diff --git a/tests/mediator-integration-tests/gradle/wrapper/gradle-wrapper.jar b/tests/mediator-integration-tests/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 249e5832..00000000 Binary files a/tests/mediator-integration-tests/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/tests/mediator-integration-tests/gradle/wrapper/gradle-wrapper.properties b/tests/mediator-integration-tests/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index aa991fce..00000000 --- a/tests/mediator-integration-tests/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/tests/mediator-integration-tests/gradlew b/tests/mediator-integration-tests/gradlew deleted file mode 100755 index 1b6c7873..00000000 --- a/tests/mediator-integration-tests/gradlew +++ /dev/null @@ -1,234 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" -APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/tests/mediator-integration-tests/gradlew.bat b/tests/mediator-integration-tests/gradlew.bat deleted file mode 100644 index 107acd32..00000000 --- a/tests/mediator-integration-tests/gradlew.bat +++ /dev/null @@ -1,89 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/tests/mediator-integration-tests/serenity.properties b/tests/mediator-integration-tests/serenity.properties deleted file mode 100644 index ba6c4806..00000000 --- a/tests/mediator-integration-tests/serenity.properties +++ /dev/null @@ -1,10 +0,0 @@ -serenity.project.name=PRISM Mediator integration tests -serenity.reports.show.step.details=true -serenity.verbose.steps=true -serenity.console.colors=true -simplified.stack.traces=false -jira.url=https://input-output.atlassian.net -jira.project=ATL -serenity.logging=VERBOSE -serenity.console.headings=normal - diff --git a/tests/mediator-integration-tests/settings.gradle.kts b/tests/mediator-integration-tests/settings.gradle.kts deleted file mode 100644 index c163ba96..00000000 --- a/tests/mediator-integration-tests/settings.gradle.kts +++ /dev/null @@ -1,3 +0,0 @@ - -rootProject.name = "mediator-integration-tests" - diff --git a/tests/mediator-integration-tests/src/main/kotlin/models/JsonEncoded.kt b/tests/mediator-integration-tests/src/main/kotlin/models/JsonEncoded.kt deleted file mode 100644 index e3ec6217..00000000 --- a/tests/mediator-integration-tests/src/main/kotlin/models/JsonEncoded.kt +++ /dev/null @@ -1,12 +0,0 @@ -package models - -import kotlinx.serialization.Serializable -import kotlinx.serialization.encodeToString -import kotlinx.serialization.json.Json - -@Serializable -sealed interface JsonEncoded { - fun toJsonString(): String { - return Json.encodeToString(this) - } -} diff --git a/tests/mediator-integration-tests/src/main/kotlin/models/MediationCoordination.kt b/tests/mediator-integration-tests/src/main/kotlin/models/MediationCoordination.kt deleted file mode 100644 index aeeaac66..00000000 --- a/tests/mediator-integration-tests/src/main/kotlin/models/MediationCoordination.kt +++ /dev/null @@ -1,52 +0,0 @@ -package models - -import kotlinx.serialization.Serializable - -@Serializable -data class MediationGrantResponse( - val routing_did: String -): JsonEncoded - -@Serializable -data class MediationKeylistRequest( - val updates: List -): JsonEncoded - -@Serializable -data class MediationKeylistUpdateResponse( - val updated: List -): JsonEncoded - -@Serializable -data class MediationKeylistResponse( - val keys: List -): JsonEncoded - -@Serializable -data class MediationKeylistKey( - val recipient_did: String -): JsonEncoded - -@Serializable -data class MediationKeylistRequestMessage( - val action: String, - val recipient_did: String -): JsonEncoded - -@Serializable -data class MediationKeylistResponseMessage( - val result: String, - val action: String, - val recipient_did: String -): JsonEncoded - -@Serializable -data class MediationKeylistQueryRequest( - val paginate: Paginate -): JsonEncoded - -@Serializable -data class Paginate( - val limit: Int, - val offset: Int -): JsonEncoded diff --git a/tests/mediator-integration-tests/src/main/kotlin/models/MessagePickup.kt b/tests/mediator-integration-tests/src/main/kotlin/models/MessagePickup.kt deleted file mode 100644 index db9f3b3f..00000000 --- a/tests/mediator-integration-tests/src/main/kotlin/models/MessagePickup.kt +++ /dev/null @@ -1,21 +0,0 @@ -package models - -import kotlinx.serialization.Serializable - -@Serializable -data class MessagePickupStatus( - val id: String, - val type: String, - val body: MessagePickupStatusBody -): JsonEncoded - -@Serializable -data class MessagePickupStatusBody( - val recipient_did: String, - val message_count: Int, - val longest_waited_seconds: Int = 0, - val newest_received_time: Int = 0, - val oldest_received_time: Int = 0, - val total_bytes: Int = 0, - val live_delivery: Boolean = false -): JsonEncoded diff --git a/tests/mediator-integration-tests/src/test/kotlin/abilities/HttpListener.kt b/tests/mediator-integration-tests/src/test/kotlin/abilities/HttpListener.kt deleted file mode 100644 index 07d3b238..00000000 --- a/tests/mediator-integration-tests/src/test/kotlin/abilities/HttpListener.kt +++ /dev/null @@ -1,48 +0,0 @@ -package abilities - -import common.Environments -import io.ktor.http.* -import io.ktor.server.application.* -import io.ktor.server.engine.* -import io.ktor.server.netty.* -import io.ktor.server.request.* -import io.ktor.server.response.* -import io.ktor.server.routing.* -import net.serenitybdd.screenplay.Actor - - -object HttpListener { - - private var receivedResponse: String? = null - - fun route(application: Application) { - application.routing { - post("/") { - val json = call.receiveText() - receivedResponse = json - call.respond(HttpStatusCode.OK) - } - } - } - - init { - embeddedServer( - Netty, - port = Environments.RECIPIENT_LISTENER_PORT, - host = Environments.RECIPIENT_LISTENER_HOST, - module = {route(this)}) - .start(wait = false) - } - - fun endpoint(): String { - return "http://host.docker.internal:${Environments.RECIPIENT_LISTENER_PORT}" - } - - fun receivedResponse(): String? { - return receivedResponse - } - - override fun toString(): String { - return "Listen HTTP port at ${Environments.RECIPIENT_LISTENER_HOST}:${Environments.RECIPIENT_LISTENER_PORT}" - } -} diff --git a/tests/mediator-integration-tests/src/test/kotlin/common/Agents.kt b/tests/mediator-integration-tests/src/test/kotlin/common/Agents.kt deleted file mode 100644 index 647eb452..00000000 --- a/tests/mediator-integration-tests/src/test/kotlin/common/Agents.kt +++ /dev/null @@ -1,25 +0,0 @@ -package common - -import abilities.HttpListener -import io.iohk.atala.prism.walletsdk.domain.models.DID -import io.restassured.builder.RequestSpecBuilder -import net.serenitybdd.rest.SerenityRest -import net.serenitybdd.screenplay.Actor -import net.serenitybdd.screenplay.rest.abilities.CallAnApi - -object Agents { - lateinit var Recipient: Actor - private set - - lateinit var Sender: Actor - private set - - fun createAgents() { - Recipient = Actor.named("Recipient") - .whoCan(CallAnApi.at(Environments.MEDIATOR_URL)) - Recipient.remember("peerDid", EdgeAgent.createPeerDid(HttpListener.endpoint())) - Sender = Actor.named("Sender") - .whoCan(CallAnApi.at(Environments.MEDIATOR_URL)) - Sender.remember("peerDid", EdgeAgent.createPeerDid(HttpListener.endpoint())) - } -} diff --git a/tests/mediator-integration-tests/src/test/kotlin/common/DidcommMessageTypes.kt b/tests/mediator-integration-tests/src/test/kotlin/common/DidcommMessageTypes.kt deleted file mode 100644 index 9ceda90f..00000000 --- a/tests/mediator-integration-tests/src/test/kotlin/common/DidcommMessageTypes.kt +++ /dev/null @@ -1,18 +0,0 @@ -package common - -object DidcommMessageTypes { - const val PING_REQUEST = "https://didcomm.org/trust-ping/2.0/ping" - const val PING_RESPONSE = "https://didcomm.org/trust-ping/2.0/ping-response" - const val MEDIATE_REQUEST = "https://didcomm.org/coordinate-mediation/2.0/mediate-request" - const val MEDIATE_GRANT = "https://didcomm.org/coordinate-mediation/2.0/mediate-grant" - const val MEDIATE_KEYLIST_UPDATE = "https://didcomm.org/coordinate-mediation/2.0/keylist-update" - const val MEDIATE_KEYLIST_UPDATE_RESPONSE = "https://didcomm.org/coordinate-mediation/2.0/keylist-update-response" - const val MEDIATE_KEYLIST = "https://didcomm.org/coordinate-mediation/2.0/keylist" - const val MEDIATE_KEYLIST_QUERY = "https://didcomm.org/coordinate-mediation/2.0/keylist-query" - const val FORWARD_REQUEST = "https://didcomm.org/routing/2.0/forward" - const val BASIC_MESSAGE = "https://didcomm.org/basicmessage/2.0/message" - const val PICKUP_STATUS_REQUEST = "https://didcomm.org/messagepickup/3.0/status-request" - const val PICKUP_DELIVERY_REQUEST = "https://didcomm.org/messagepickup/3.0/delivery-request" - const val PICKUP_STATUS = "https://didcomm.org/messagepickup/3.0/status" - const val CONNECTION_RESPONSE = "https://atalaprism.io/mercury/connections/1.0/response" -} diff --git a/tests/mediator-integration-tests/src/test/kotlin/common/EdgeAgent.kt b/tests/mediator-integration-tests/src/test/kotlin/common/EdgeAgent.kt deleted file mode 100644 index 2a8569e5..00000000 --- a/tests/mediator-integration-tests/src/test/kotlin/common/EdgeAgent.kt +++ /dev/null @@ -1,102 +0,0 @@ -package common - -import abilities.HttpListener -import io.iohk.atala.prism.walletsdk.apollo.ApolloImpl -import io.iohk.atala.prism.walletsdk.castor.CastorImpl -import io.iohk.atala.prism.walletsdk.domain.models.* -import io.iohk.atala.prism.walletsdk.mercury.MercuryImpl -import io.iohk.atala.prism.walletsdk.mercury.resolvers.DIDCommWrapper -import io.iohk.atala.prism.walletsdk.pluto.PlutoImpl -import io.iohk.atala.prism.walletsdk.pluto.data.DbConnection -import io.iohk.atala.prism.walletsdk.prismagent.DIDCOMM1 -import io.iohk.atala.prism.walletsdk.prismagent.DIDCOMM_MESSAGING -import kotlinx.coroutines.runBlocking -import kotlinx.serialization.json.Json -import models.MediationGrantResponse -import net.serenitybdd.core.Serenity -import net.serenitybdd.rest.SerenityRest -import org.didcommx.didcomm.common.Typ -import org.didcommx.didcomm.model.PackEncryptedParams - -object EdgeAgent { - val apollo = ApolloImpl() - val pluto = PlutoImpl(DbConnection()) - val castor = CastorImpl(apollo) - val mercury = MercuryImpl( - castor, - DIDCommWrapper(castor, pluto, apollo), - ApiImpl(httpClient()) - ) - - val peerDID: DID - - init { - runBlocking { - pluto.start() - } - peerDID = createPeerDid(HttpListener.endpoint()) - } - - fun unpackLastDidcommMessage(): Message { - val didcommMessage = unpackMessage(SerenityRest.lastResponse().asString()) - Serenity.recordReportData().withTitle("DIDComm Response").andContents(didcommMessage.body) - return didcommMessage - } - - fun unpackMessage(message: String): Message { - return mercury.unpackMessage(message) - } - - fun packMessage(message: Message): String { - return mercury.packMessage(message) - } - - fun createPeerDid(serviceEndpoint: String): DID { - val seed = apollo.createSeed(apollo.createRandomMnemonics(), "") - val keyAgreementKeyPair = - apollo.createKeyPair(seed = seed, curve = KeyCurve(Curve.X25519)) - val authenticationKeyPair = - apollo.createKeyPair(seed = seed, curve = KeyCurve(Curve.ED25519)) - val did = castor.createPeerDID( - arrayOf(authenticationKeyPair, keyAgreementKeyPair), - arrayOf( - DIDDocument.Service( - DIDCOMM1, - arrayOf(DIDCOMM_MESSAGING), - DIDDocument.ServiceEndpoint(serviceEndpoint) - ) - ) - ) - - val document = runBlocking { - castor.resolveDID(did.toString()) - } - - val listOfVerificationMethods: MutableList = - mutableListOf() - document.coreProperties.forEach { - if (it is DIDDocument.Authentication) { - listOfVerificationMethods.addAll(it.verificationMethods) - } - if (it is DIDDocument.KeyAgreement) { - listOfVerificationMethods.addAll(it.verificationMethods) - } - } - val verificationMethods = - DIDDocument.VerificationMethods(listOfVerificationMethods.toTypedArray()) - - verificationMethods.values.forEach { - if (it.type.contains("X25519")) { - pluto.storePrivateKeys(keyAgreementKeyPair.privateKey, did, 0, it.id.toString()) - } else if (it.type.contains("Ed25519")) { - pluto.storePrivateKeys( - authenticationKeyPair.privateKey, - did, - 0, - it.id.toString() - ) - } - } - return did - } -} diff --git a/tests/mediator-integration-tests/src/test/kotlin/common/Ensure.kt b/tests/mediator-integration-tests/src/test/kotlin/common/Ensure.kt deleted file mode 100644 index ebf03788..00000000 --- a/tests/mediator-integration-tests/src/test/kotlin/common/Ensure.kt +++ /dev/null @@ -1,53 +0,0 @@ -package common - -import net.serenitybdd.screenplay.Question -import org.openqa.selenium.By -import java.time.LocalDate -import java.time.LocalTime -import net.serenitybdd.screenplay.ensure.enableSoftAssertions as EnableSoftAssertions -import net.serenitybdd.screenplay.ensure.reportSoftAssertions as ReportSoftAssertions -import net.serenitybdd.screenplay.ensure.that as That -import net.serenitybdd.screenplay.ensure.thatAmongst as ThatAmongst -import net.serenitybdd.screenplay.ensure.thatTheCurrentPage as ThatTheCurrentPage -import net.serenitybdd.screenplay.ensure.thatTheListOf as ThatTheListOf -import net.serenitybdd.screenplay.targets.Target as SerenityTarget - -object Ensure { - fun that(value: String) = That(value) - fun that(value: LocalDate) = That(value) - fun that(value: LocalTime) = That(value) - fun that(value: Boolean) = That(value) - fun that(value: Float) = That(value) - fun that(value: Double) = That(value) - - fun that(value: Comparable) = That(value) - fun that(value: Collection) = That(value) - - fun that(question: Question, predicate: (actual: A) -> Boolean) = That(question, predicate) - fun that(description: String, question: Question, predicate: (actual: A) -> Boolean) = - That(description, question, predicate) - - fun > that(description: String, question: Question) = That(description, question) - fun > that(question: Question) = That(question) - - fun that(description: String, question: Question>) = That(description, question) - fun that(question: Question>) = That(question) - - fun thatTheListOf(description: String, question: Question>) = ThatTheListOf(description, question) - fun thatTheListOf(question: Question>) = ThatTheListOf(question) - - fun thatTheCurrentPage() = ThatTheCurrentPage() - fun that(value: SerenityTarget) = That(value) - fun that(value: By) = net.serenitybdd.screenplay.ensure.that(value) - - // Collection matchers - fun thatTheListOf(value: SerenityTarget) = ThatTheListOf(value) - fun thatTheListOf(value: By) = ThatTheListOf(value) - - fun thatAmongst(value: SerenityTarget) = ThatAmongst(value) - fun thatAmongst(value: By) = ThatAmongst(value) - - fun enableSoftAssertions() = EnableSoftAssertions() - fun reportSoftAssertions() = ReportSoftAssertions() - -} diff --git a/tests/mediator-integration-tests/src/test/kotlin/common/Environments.kt b/tests/mediator-integration-tests/src/test/kotlin/common/Environments.kt deleted file mode 100644 index af70c32f..00000000 --- a/tests/mediator-integration-tests/src/test/kotlin/common/Environments.kt +++ /dev/null @@ -1,10 +0,0 @@ -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.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() -} diff --git a/tests/mediator-integration-tests/src/test/kotlin/common/MediatorErrorMessages.kt b/tests/mediator-integration-tests/src/test/kotlin/common/MediatorErrorMessages.kt deleted file mode 100644 index 79d44c10..00000000 --- a/tests/mediator-integration-tests/src/test/kotlin/common/MediatorErrorMessages.kt +++ /dev/null @@ -1,5 +0,0 @@ -package common - -object MediatorErrorMessages { - const val WRONG_CONTENT_TYPE = "The content-type must be application/didcomm-signed+json or application/didcomm-encrypted+json" -} diff --git a/tests/mediator-integration-tests/src/test/kotlin/common/TestConstants.kt b/tests/mediator-integration-tests/src/test/kotlin/common/TestConstants.kt deleted file mode 100644 index 05059cb3..00000000 --- a/tests/mediator-integration-tests/src/test/kotlin/common/TestConstants.kt +++ /dev/null @@ -1,14 +0,0 @@ -package common - -object TestConstants { - const val EMPTY_BODY: String = "{}" - const val CONST_BODY: String = """{"key":"value"}""" - const val UNSUPPORTED_CONTENT_TYPE: String = "unsupported-type+json" - const val DIDCOMM_V2_CONTENT_TYPE_ENCRYPTED: String = "application/didcomm-encrypted+json" - const val DIDCOMM_V2_CONTENT_TYPE_PLAIN: String = "application/didcomm-plain+json" - const val MEDIATOR_COORDINATION_ACTION_ADD: String = "add" - const val MEDIATOR_COORDINATION_ACTION_REMOVE: String = "remove" - const val MEDIATOR_COORDINATION_ACTION_RESULT_SUCCESS: String = "success" - const val MEDIATOR_COORDINATION_ACTION_RESULT_NO_CHANGE: String = "no_change" - const val EXAMPLE_DID: String = "did:example:123456789abcdefghi" -} diff --git a/tests/mediator-integration-tests/src/test/kotlin/features/CommonSteps.kt b/tests/mediator-integration-tests/src/test/kotlin/features/CommonSteps.kt deleted file mode 100644 index 000a326e..00000000 --- a/tests/mediator-integration-tests/src/test/kotlin/features/CommonSteps.kt +++ /dev/null @@ -1,30 +0,0 @@ -package features - -import common.Agents.Recipient -import common.Agents.Sender -import common.Agents.createAgents -import io.cucumber.java.Before -import io.cucumber.java.BeforeAll -import io.cucumber.java.ParameterType -import net.serenitybdd.screenplay.Actor -import net.serenitybdd.screenplay.actors.Cast -import net.serenitybdd.screenplay.actors.OnStage - -class CommonSteps { - - @Before - fun setStage() { - createAgents() - val cast = object : Cast() { - override fun getActors(): MutableList { - return mutableListOf(Recipient, Sender) - } - } - OnStage.setTheStage(cast) - } - - @ParameterType(".*") - fun actor(actorName: String): Actor { - return OnStage.theActorCalled(actorName) - } -} diff --git a/tests/mediator-integration-tests/src/test/kotlin/features/general/GeneralTestSteps.kt b/tests/mediator-integration-tests/src/test/kotlin/features/general/GeneralTestSteps.kt deleted file mode 100644 index 9f2f9175..00000000 --- a/tests/mediator-integration-tests/src/test/kotlin/features/general/GeneralTestSteps.kt +++ /dev/null @@ -1,42 +0,0 @@ -package features.general - -import common.* -import common.MediatorErrorMessages.WRONG_CONTENT_TYPE -import interactions.SendDidcommMessage -import io.cucumber.java.en.When -import net.serenitybdd.screenplay.Actor -import io.cucumber.java.en.Then -import io.iohk.atala.prism.walletsdk.domain.models.Message -import net.serenitybdd.rest.SerenityRest -import org.apache.http.HttpStatus -import org.apache.http.HttpStatus.SC_BAD_REQUEST - -class GeneralTestSteps { - - @When("{actor} sends a didcomm message with the wrong content type") - fun recipientSendsADidcommMessageWithTheWrongContentType(recipient: Actor) { - - val pingMessage = Message( - piuri = DidcommMessageTypes.PING_REQUEST, - from = EdgeAgent.peerDID, - to = Environments.MEDIATOR_PEER_DID, - body = TestConstants.EMPTY_BODY, - ) - - recipient.attemptsTo( - SendDidcommMessage( - pingMessage, - TestConstants.UNSUPPORTED_CONTENT_TYPE - ) - ) - } - - @Then("Mediator returns a correct error message to {actor}") - fun mediatorReturnsACorrectErrorMessage(recipient: Actor) { - val httpResponse = SerenityRest.lastResponse() - recipient.attemptsTo( - Ensure.that(httpResponse.statusCode()).isEqualTo(HttpStatus.SC_BAD_REQUEST), - Ensure.that(httpResponse.body().asString()).contains(WRONG_CONTENT_TYPE) - ) - } -} diff --git a/tests/mediator-integration-tests/src/test/kotlin/features/mediation_coordination/MediationCoordinationSteps.kt b/tests/mediator-integration-tests/src/test/kotlin/features/mediation_coordination/MediationCoordinationSteps.kt deleted file mode 100644 index 3d501249..00000000 --- a/tests/mediator-integration-tests/src/test/kotlin/features/mediation_coordination/MediationCoordinationSteps.kt +++ /dev/null @@ -1,209 +0,0 @@ -package features.mediation_coordination - -import abilities.HttpListener -import common.* -import interactions.SendDidcommMessage -import io.cucumber.java.en.When -import net.serenitybdd.screenplay.Actor -import io.cucumber.java.en.Then -import io.iohk.atala.prism.walletsdk.domain.models.Message -import io.cucumber.java.en.Given -import io.iohk.atala.prism.walletsdk.domain.models.DID -import kotlinx.serialization.decodeFromString -import kotlinx.serialization.json.Json -import models.* - -class MediationCoordinationSteps { - - @When("{actor} sends a mediate request message to the mediator") - fun recipientSendsAMediateRequestMessageToTheMediator(recipient: Actor) { - - val mediateRequest = Message( - piuri = DidcommMessageTypes.MEDIATE_REQUEST, - from = recipient.recall("peerDid"), - to = Environments.MEDIATOR_PEER_DID, - body = TestConstants.EMPTY_BODY, - ) - - recipient.attemptsTo( - SendDidcommMessage(mediateRequest) - ) - } - - @Then("Mediator responds to {actor} with mediate grant message") - fun mediatorRespondsToHimWithMediateGrantMessage(recipient: Actor) { - val didcommMessage = EdgeAgent.unpackLastDidcommMessage() - val didcommBody = Json.decodeFromString(didcommMessage.body) - recipient.attemptsTo( - Ensure.that(didcommMessage.piuri).isEqualTo(DidcommMessageTypes.MEDIATE_GRANT), - Ensure.that(didcommMessage.from.toString()).isEqualTo(Environments.MEDIATOR_PEER_DID.toString()), - Ensure.that(didcommMessage.to.toString()).isEqualTo(recipient.recall("peerDid").toString()), - Ensure.that(didcommBody.routing_did).isEqualTo(Environments.MEDIATOR_PEER_DID.toString()) - ) - } - - @Given("{actor} successfully set up a connection with the mediator") - fun recipientSuccessfullySetUpAConnectionWithTheMediator(recipient: Actor) { - recipientSendsAMediateRequestMessageToTheMediator(recipient) - val didcommMessage = EdgeAgent.unpackLastDidcommMessage() - recipient.attemptsTo( - Ensure.that(didcommMessage.piuri).isEqualTo(DidcommMessageTypes.MEDIATE_GRANT), - ) - } - - @When("{actor} sends a keylist update message to the mediator with a new peer did") - fun recipientSendsAKeylistUpdateMessageToTheMediatorWithANewPeerDid(recipient: Actor) { - val newPeerDid = EdgeAgent.createPeerDid(HttpListener.endpoint()) - recipient.attemptsTo( - Ensure.that(newPeerDid.toString()).isNotEqualTo(recipient.recall("peerDid").toString()) - ) - recipient.remember("newPeerDid", newPeerDid) - - val keylistUpdateMessage = Message( - piuri = DidcommMessageTypes.MEDIATE_KEYLIST_UPDATE, - from = recipient.recall("peerDid"), - to = Environments.MEDIATOR_PEER_DID, - body = MediationKeylistRequest( - updates = listOf( - MediationKeylistRequestMessage( - action = "add", - recipient_did = newPeerDid.toString(), - ) - ) - ).toJsonString() - ) - recipient.attemptsTo( - SendDidcommMessage(keylistUpdateMessage) - ) - } - - @Then("Mediator responds to {actor} with a correct keylist update add message") - fun mediatorRespondsToHimWithACorrectKeylistUpdateAddMessage(recipient: Actor) { - val didcommMessage = EdgeAgent.unpackLastDidcommMessage() - val didcommBody = Json.decodeFromString(didcommMessage.body) - recipient.attemptsTo( - Ensure.that(didcommMessage.piuri).isEqualTo(DidcommMessageTypes.MEDIATE_KEYLIST_UPDATE_RESPONSE), - Ensure.that(didcommBody.updated.size).isGreaterThan(0), - Ensure.that(didcommBody.updated[0].result).isEqualTo(TestConstants.MEDIATOR_COORDINATION_ACTION_RESULT_SUCCESS), - Ensure.that(didcommBody.updated[0].action).isEqualTo(TestConstants.MEDIATOR_COORDINATION_ACTION_ADD), - Ensure.that(didcommBody.updated[0].recipient_did).isEqualTo( - recipient.recall("newPeerDid").toString() - ), - ) - } - - @When("{actor} sends a keylist query message to the mediator") - fun recipientSendsAKeylistQueryMessageToTheMediator(recipient: Actor) { - val keyListQueryMessage = Message( - piuri = DidcommMessageTypes.MEDIATE_KEYLIST_QUERY, - from = recipient.recall("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) { - val didcommMessage = EdgeAgent.unpackLastDidcommMessage() - val didcommBody = Json.decodeFromString(didcommMessage.body) - recipient.attemptsTo( - Ensure.that(didcommMessage.piuri).isEqualTo(DidcommMessageTypes.MEDIATE_KEYLIST), - Ensure.that(didcommBody.keys.size).isGreaterThan(0), - Ensure.that(didcommBody.keys.last().recipient_did).isEqualTo(recipient.recall("peerDid").toString()) - ) - } - - @When("{actor} sends a keylist update message to the mediator to remove the last alias") - fun recipientSendsAKeylistUpdateMessageToTheMediatorToRemoveAKey(recipient: Actor) { - val keylistUpdateMessage = Message( - piuri = DidcommMessageTypes.MEDIATE_KEYLIST_UPDATE, - from = recipient.recall("peerDid"), - to = Environments.MEDIATOR_PEER_DID, - body = MediationKeylistRequest( - updates = listOf( - MediationKeylistRequestMessage( - action = "remove", - recipient_did = recipient.recall("peerDid").toString() - ) - ) - ).toJsonString() - ) - recipient.attemptsTo( - SendDidcommMessage(keylistUpdateMessage) - ) - } - - @When("{actor} sends a keylist update message to the mediator to remove added alias") - fun recipientSendsAKeylistUpdateMessageToTheMediatorToRemoveAddedAlias(recipient: Actor) { - val keylistUpdateMessage = Message( - piuri = DidcommMessageTypes.MEDIATE_KEYLIST_UPDATE, - from = recipient.recall("peerDid"), - to = Environments.MEDIATOR_PEER_DID, - body = MediationKeylistRequest( - updates = listOf( - MediationKeylistRequestMessage( - action = "remove", - recipient_did = recipient.recall("newPeerDid").toString() - ) - ) - ).toJsonString() - ) - recipient.attemptsTo( - SendDidcommMessage(keylistUpdateMessage) - ) - } - - @Then("Mediator responds to {actor} with a correct keylist update remove message") - fun mediatorRespondsToRecipientWithACorrectKeylistUpdateRemoveMessage(recipient: Actor) { - val didcommMessage = EdgeAgent.unpackLastDidcommMessage() - val didcommBody = Json.decodeFromString(didcommMessage.body) - recipient.attemptsTo( - Ensure.that(didcommMessage.piuri).isEqualTo(DidcommMessageTypes.MEDIATE_KEYLIST_UPDATE_RESPONSE), - Ensure.that(didcommBody.updated.size).isGreaterThan(0), - Ensure.that(didcommBody.updated[0].result).isEqualTo(TestConstants.MEDIATOR_COORDINATION_ACTION_RESULT_SUCCESS), - Ensure.that(didcommBody.updated[0].action).isEqualTo(TestConstants.MEDIATOR_COORDINATION_ACTION_REMOVE), - ) - } - - @When("{actor} sends a keylist update message to the mediator to remove not existing alias") - fun recipientSendsAKeylistUpdateMessageToTheMediatorToRemoveNotExistingAlias(recipient: Actor) { - - val keylistUpdateMessage = Message( - piuri = DidcommMessageTypes.MEDIATE_KEYLIST_UPDATE, - from = recipient.recall("peerDid"), - to = Environments.MEDIATOR_PEER_DID, - body = MediationKeylistRequest( - updates = listOf( - MediationKeylistRequestMessage( - action = TestConstants.MEDIATOR_COORDINATION_ACTION_REMOVE, - recipient_did = TestConstants.EXAMPLE_DID - ) - ) - ).toJsonString() - ) - - recipient.attemptsTo( - SendDidcommMessage(keylistUpdateMessage) - ) - } - - @Then("Mediator responds to {actor} with a message with no_change status") - fun mediatorRespondsToRecipientWithAMessageWithNo_changeStatus(recipient: Actor) { - val didcommMessage = EdgeAgent.unpackLastDidcommMessage() - val didcommBody = Json.decodeFromString(didcommMessage.body) - recipient.attemptsTo( - Ensure.that(didcommMessage.piuri).isEqualTo(DidcommMessageTypes.MEDIATE_KEYLIST_UPDATE_RESPONSE), - Ensure.that(didcommBody.updated.size).isGreaterThan(0), - Ensure.that(didcommBody.updated[0].result).isEqualTo(TestConstants.MEDIATOR_COORDINATION_ACTION_RESULT_NO_CHANGE), - Ensure.that(didcommBody.updated[0].action).isEqualTo(TestConstants.MEDIATOR_COORDINATION_ACTION_REMOVE), - ) - } -} diff --git a/tests/mediator-integration-tests/src/test/kotlin/features/pickup_message/PickupMessageSteps.kt b/tests/mediator-integration-tests/src/test/kotlin/features/pickup_message/PickupMessageSteps.kt deleted file mode 100644 index 283746b3..00000000 --- a/tests/mediator-integration-tests/src/test/kotlin/features/pickup_message/PickupMessageSteps.kt +++ /dev/null @@ -1,98 +0,0 @@ -package features.pickup_message - -import common.* -import interactions.SendDidcommMessage -import io.cucumber.java.en.Given -import net.serenitybdd.screenplay.Actor -import io.cucumber.java.en.When -import io.cucumber.java.en.Then -import io.iohk.atala.prism.walletsdk.domain.models.AttachmentBase64 -import io.iohk.atala.prism.walletsdk.domain.models.DID -import java.util.Base64 -import io.iohk.atala.prism.walletsdk.domain.models.Message -import io.iohk.atala.prism.walletsdk.mercury.forward.ForwardMessage -import kotlinx.serialization.decodeFromString -import kotlinx.serialization.json.Json -import models.MessagePickupStatusBody - -class PickupMessageSteps { - - @Given("{actor} sent a forward message to {actor}") - fun senderSentAForwardMessageToRecipient(sender: Actor, recipient: Actor) { - - val message = Message( - piuri = DidcommMessageTypes.BASIC_MESSAGE, - from = sender.recall("peerDid"), - to = recipient.recall("peerDid"), - body = TestConstants.CONST_BODY, - ) - sender.remember("initialMessage", message) - - val forwardMessage = ForwardMessage( - body = ForwardMessage.ForwardBody(message.to.toString()), - encryptedMessage = EdgeAgent.packMessage(message), - from = message.from!!, - to = Environments.MEDIATOR_PEER_DID, - ).makeMessage() - - recipient.attemptsTo( - SendDidcommMessage(forwardMessage) - ) - - } - - @When("{actor} sends a status-request message") - fun recipientSendsAStatusRequestMessage(recipient: Actor) { - recipient.attemptsTo( - SendDidcommMessage( - Message( - piuri = DidcommMessageTypes.PICKUP_STATUS_REQUEST, - from = recipient.recall("peerDid"), - to = Environments.MEDIATOR_PEER_DID, - body = """ {"recipient_did": "${recipient.recall("peerDid")}"} """, - ) - ) - ) - } - - @Then("Mediator responds with a status message detailing the queued messages of {actor}") - fun mediatorRespondsWithAStatusMessageDetailingTheQueuedMessagesOfRecipient(recipient: Actor) { - val didcommMessage = EdgeAgent.unpackLastDidcommMessage() - val pickupStatus = Json.decodeFromString(didcommMessage.body) - recipient.attemptsTo( - Ensure.that(pickupStatus.recipient_did).isEqualTo(recipient.recall("peerDid").toString()), - Ensure.that(pickupStatus.message_count).isGreaterThan(0) - ) - } - - @When("{actor} sends a delivery-request message") - fun recipientSendsADeliveryRequestMessage(recipient: Actor) { - recipient.attemptsTo( - SendDidcommMessage( - Message( - piuri = DidcommMessageTypes.PICKUP_DELIVERY_REQUEST, - from = recipient.recall("peerDid"), - to = Environments.MEDIATOR_PEER_DID, - body = """ { "recipient_did": "${recipient.recall("peerDid")}", "limit": 3 } """, - ) - ) - ) - } - - @Then("Mediator delivers message of {actor} to {actor}") - fun mediatorDeliversMessageOfSenderToRecipient(sender: Actor, recipient: Actor) { - val didcommMessage = EdgeAgent.unpackLastDidcommMessage() - val data = didcommMessage.attachments.first().data as AttachmentBase64 - val decoded = Base64.getUrlDecoder().decode(data.base64).decodeToString() - val achievedMessage = EdgeAgent.unpackMessage(decoded) - val initialMessage = sender.recall("initialMessage") - - recipient.attemptsTo( - Ensure.that(didcommMessage.attachments.size).isEqualTo(1), - Ensure.that(achievedMessage.id).isEqualTo(initialMessage.id), - Ensure.that(achievedMessage.body).isEqualTo(initialMessage.body), - Ensure.that(achievedMessage.from.toString()).isEqualTo(initialMessage.from.toString()), - Ensure.that(achievedMessage.to.toString()).isEqualTo(initialMessage.to.toString()) - ) - } -} diff --git a/tests/mediator-integration-tests/src/test/kotlin/features/ping/PingProtocolSteps.kt b/tests/mediator-integration-tests/src/test/kotlin/features/ping/PingProtocolSteps.kt deleted file mode 100644 index e76bdec1..00000000 --- a/tests/mediator-integration-tests/src/test/kotlin/features/ping/PingProtocolSteps.kt +++ /dev/null @@ -1,48 +0,0 @@ -package features.ping - -import abilities.HttpListener -import common.DidcommMessageTypes -import common.EdgeAgent -import common.Ensure -import common.Environments.MEDIATOR_PEER_DID -import interactions.SendDidcommMessage -import io.cucumber.java.en.Then -import io.cucumber.java.en.When -import io.iohk.atala.prism.walletsdk.domain.models.Message -import net.serenitybdd.rest.SerenityRest -import net.serenitybdd.screenplay.Actor -import org.apache.http.HttpStatus.SC_OK - -class PingProtocolSteps { - - @When("{actor} sends trusted ping message to mediator") - fun iSendTrustedPingMessageToMediator(recipient: Actor) { - - val pingMessage = Message( - piuri = DidcommMessageTypes.PING_REQUEST, - from = EdgeAgent.peerDID, - to = MEDIATOR_PEER_DID, - body = """{"response_requested": true}""" - ) - - recipient.attemptsTo( - SendDidcommMessage(pingMessage) - ) - } - - @Then("{actor} gets trusted ping message back") - fun recipientGetTrustedPingMessageBack(recipient: Actor) { - val didcommResponse: Message = EdgeAgent.unpackMessage( - HttpListener.receivedResponse()!! - ) - val httpResponse = SerenityRest.lastResponse() - - recipient.attemptsTo( - Ensure.that(httpResponse.statusCode).isEqualTo(SC_OK), - Ensure.that(didcommResponse.piuri).isEqualTo(DidcommMessageTypes.PING_RESPONSE), - Ensure.that(didcommResponse.from.toString()).isEqualTo(MEDIATOR_PEER_DID.toString()), - Ensure.that(didcommResponse.to.toString()).isEqualTo(EdgeAgent.peerDID.toString()), - ) - - } -} diff --git a/tests/mediator-integration-tests/src/test/kotlin/interactions/SendDidcommMessage.kt b/tests/mediator-integration-tests/src/test/kotlin/interactions/SendDidcommMessage.kt deleted file mode 100644 index 6186b715..00000000 --- a/tests/mediator-integration-tests/src/test/kotlin/interactions/SendDidcommMessage.kt +++ /dev/null @@ -1,40 +0,0 @@ -package interactions - -import net.serenitybdd.screenplay.Actor - -import common.EdgeAgent.packMessage -import common.TestConstants -import io.iohk.atala.prism.walletsdk.domain.models.Message -import io.restassured.RestAssured -import io.restassured.builder.RequestSpecBuilder -import io.restassured.config.EncoderConfig -import net.serenitybdd.core.Serenity -import net.serenitybdd.screenplay.Interaction -import net.serenitybdd.screenplay.rest.interactions.Post - -open class SendDidcommMessage( - val message: Message, - val contentType: String = TestConstants.DIDCOMM_V2_CONTENT_TYPE_ENCRYPTED -): Interaction { - override fun performAs(actor: T) { - Serenity.recordReportData().withTitle("DIDComm Message").andContents( - message.toJsonString() - ) - val packedMessage = packMessage(message) - // We have to rewrite spec to remove all unnecessary hardcoded headers - // from standard serenity rest interaction - val spec = RequestSpecBuilder().noContentType() - .setContentType(contentType) - .setConfig(RestAssured.config() - .encoderConfig( - EncoderConfig - .encoderConfig() - .appendDefaultContentCharsetToContentTypeIfUndefined(false)) - ) - .setBody(packedMessage) - .build() - Post.to("/").with { - it.spec(spec) - }.performAs(actor) - } -} diff --git a/tests/mediator-integration-tests/src/test/kotlin/runners/IntegrationTestRunner.kt b/tests/mediator-integration-tests/src/test/kotlin/runners/IntegrationTestRunner.kt deleted file mode 100644 index f32e6ba3..00000000 --- a/tests/mediator-integration-tests/src/test/kotlin/runners/IntegrationTestRunner.kt +++ /dev/null @@ -1,19 +0,0 @@ -package runners - -import io.cucumber.junit.CucumberOptions -import net.serenitybdd.cucumber.CucumberWithSerenity -import org.junit.runner.RunWith - -@CucumberOptions( - features = [ - "src/test/resources/features", - ], - glue = ["features"], - snippets = CucumberOptions.SnippetType.CAMELCASE, - plugin = [ - "pretty", - "json:target/serenity-reports/cucumber_report.json", - ], -) -@RunWith(CucumberWithSerenity::class) -class IntegrationTestRunner diff --git a/tests/mediator-integration-tests/src/test/resources/cucumber.properties b/tests/mediator-integration-tests/src/test/resources/cucumber.properties deleted file mode 100644 index b48dd63b..00000000 --- a/tests/mediator-integration-tests/src/test/resources/cucumber.properties +++ /dev/null @@ -1 +0,0 @@ -cucumber.publish.quiet=true diff --git a/tests/mediator-integration-tests/src/test/resources/features/general/general.feature b/tests/mediator-integration-tests/src/test/resources/features/general/general.feature deleted file mode 100644 index eff3297a..00000000 --- a/tests/mediator-integration-tests/src/test/resources/features/general/general.feature +++ /dev/null @@ -1,5 +0,0 @@ -Feature: General Mediator Functionality - -Scenario: Wrong content type - When Recipient sends a didcomm message with the wrong content type - Then Mediator returns a correct error message to Recipient diff --git a/tests/mediator-integration-tests/src/test/resources/features/mediation_coordination/mediation_coordination.feature b/tests/mediator-integration-tests/src/test/resources/features/mediation_coordination/mediation_coordination.feature deleted file mode 100644 index afd7340e..00000000 --- a/tests/mediator-integration-tests/src/test/resources/features/mediation_coordination/mediation_coordination.feature +++ /dev/null @@ -1,32 +0,0 @@ -Feature: Mediatior Coordination protocol - -Scenario: Successful Mediation Request - When Recipient sends a mediate request message to the mediator - Then Mediator responds to Recipient with mediate grant message - -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 - Then Mediator responds to Recipient with a correct keylist update add message - -Scenario: Recipient removes alias from keylist - Given Recipient successfully set up a connection with the mediator - And Recipient sends a keylist update message to the mediator with a new peer did - 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 - -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 - -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 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 - Then Mediator responds to Recipient with keylist message containing the current list of keys diff --git a/tests/mediator-integration-tests/src/test/resources/features/pickup_message/pickup_message.feature b/tests/mediator-integration-tests/src/test/resources/features/pickup_message/pickup_message.feature deleted file mode 100644 index 683c626c..00000000 --- a/tests/mediator-integration-tests/src/test/resources/features/pickup_message/pickup_message.feature +++ /dev/null @@ -1,101 +0,0 @@ -Feature: Pickup message protocol - -Scenario: Recipient sends a status-request message - Given Recipient sends a mediate request message to the mediator - And Mediator responds to Recipient with mediate grant message - And Sender sent a forward message to Recipient - When Recipient sends a status-request message - Then Mediator responds with a status message detailing the queued messages of Recipient - -Scenario: Recipient sends a delivery-request message - Given Recipient sends a mediate request message to the mediator - And Mediator responds to Recipient with mediate grant message - And Sender sent a forward message to Recipient - When Recipient sends a delivery-request message - Then Mediator delivers message of Sender to Recipient - -# -#Scenario: -# Given the mediator has no messages for the recipient -# When the recipient sends a status-request message -# Then the mediator responds with a status message with message_count as 0 -# -#Scenario: -# Given the mediator has messages for multiple DIDs -# When the recipient sends a status-request message for a specific DID -# Then the mediator responds with a status message detailing only the queued messages for that specific DID -# -#Scenario: -# Given the mediator has messages for the recipient -# When the recipient sends a delivery-request message -# Then the mediator responds with a message-delivery message containing up to the requested limit of messages -# -#Scenario: -# Given the mediator has no messages for the recipient -# When the recipient sends a delivery-request message -# Then the mediator responds with a status message indicating no messages are available -# -#Scenario: -# Given the mediator has messages for multiple DIDs -# When the recipient sends a delivery-request message for a specific DID -# Then the mediator responds with a message-delivery message containing messages for that specific DID only -# -#Scenario: -# Given the mediator has sent a message-delivery to the recipient -# When the recipient sends a message-received message -# Then the mediator removes the acknowledged messages from the queue and sends an updated status message -# -#Scenario: -# Given the mediator receives a message addressed to multiple recipients -# When one recipient retrieves the message and indicates it has been received -# Then the mediator still holds the message for the other recipients and only removes it from the queue when all recipients have retrieved it -# -#Scenario: -# Given the mediator has messages for multiple DIDs but none for a specific DID -# When the recipient sends a status-request message for the specific DID -# Then the mediator responds with a status message with a message_count of 0 for that specific DID -# -#Scenario: -# Given the mediator has less messages for the recipient than the limit set in the delivery request -# When the recipient sends a delivery-request message -# Then the mediator responds with a message-delivery message containing all the queued messages -# -#Scenario: -# Given the mediator has no messages for a specific DID but has messages for other DIDs -# When the recipient sends a delivery-request message for the specific DID -# Then the mediator responds with a status message with a message_count of 0 for that specific DID -# -#Scenario: -# Given the mediator has not sent any messages to the recipient -# When the recipient sends a message-received message -# Then the mediator responds with a problem report or ignores the message, since there are no messages to acknowledge -# -#Scenario: -# Given the mediator receives a message addressed to multiple recipients and one of them is offline -# When the offline recipient comes online and fetches messages -# Then the mediator delivers the message to the recipient, despite other recipients having already fetched it -# -#Scenario: -# Given the mediator receives a message addressed to multiple recipients -# When all recipients retrieve the message and indicate it has been received -# Then the mediator removes the message from the queue completely -# -#Scenario: -# Given the mediator has messages for the recipient -# When the recipient sends a delivery-request message with a limit of 0 -# Then the mediator responds with a problem report indicating that the limit must be greater than 0 -# -#Scenario: -# Given the mediator has messages for the recipient that haven't been delivered yet -# When the recipient sends a message-received message for these undelivered messages -# Then the mediator responds with a problem report indicating that these messages haven't been delivered yet -# -#Scenario: -# Given the mediator has messages queued for various DIDs -# When the recipient sends a delivery-request message for a DID that doesn't exist in the mediator's queue -# Then the mediator responds with a status message with a message_count of 0 for that specific DID -# -#Scenario: -# Given the mediator has a maximum batch size it can handle -# When the recipient sends a delivery-request message with a limit exceeding this maximum -# Then the mediator responds with a problem report indicating that the request exceeds the maximum batch size diff --git a/tests/mediator-integration-tests/src/test/resources/features/ping/ping.feature b/tests/mediator-integration-tests/src/test/resources/features/ping/ping.feature deleted file mode 100644 index d731d03b..00000000 --- a/tests/mediator-integration-tests/src/test/resources/features/ping/ping.feature +++ /dev/null @@ -1,5 +0,0 @@ -Feature: Ping protocol - -Scenario: Trusted ping - When Recipient sends trusted ping message to mediator - Then Recipient gets trusted ping message back