From fc7a3f40e7fc98495b2b3f0c1b69c50e1b8383c8 Mon Sep 17 00:00:00 2001 From: FabioPinheiro Date: Fri, 3 Nov 2023 10:35:39 +0000 Subject: [PATCH 1/2] Return 202 HTTP code (for DID Comm) The recommendation from the didcomm-messaging specs is to return a 202 Accepted. See https://identity.foundation/didcomm-messaging/spec/#https Resolves issue #160 --- .../iohk/atala/mediator/app/MediatorAgent.scala | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/mediator/src/main/scala/io/iohk/atala/mediator/app/MediatorAgent.scala b/mediator/src/main/scala/io/iohk/atala/mediator/app/MediatorAgent.scala index ccaeaeab..7dd84925 100644 --- a/mediator/src/main/scala/io/iohk/atala/mediator/app/MediatorAgent.scala +++ b/mediator/src/main/scala/io/iohk/atala/mediator/app/MediatorAgent.scala @@ -26,6 +26,7 @@ import scala.io.Source import zio.http.internal.middlewares.Cors.CorsConfig import zio.http.Header.AccessControlAllowOrigin import zio.http.Header.AccessControlAllowMethods +import zio.http.Header.HeaderType case class MediatorAgent( override val id: DID, @@ -250,9 +251,19 @@ object MediatorAgent { ret <- agent .receiveMessage(data) .map { - case None => Response.ok - case Some(value: SignedMessage) => Response.json(value.toJson) - case Some(value: EncryptedMessage) => Response.json(value.toJson) + case None => Response(status = Status.Accepted) + case Some(value: SignedMessage) => + Response( + status = Status.Accepted, + headers = Headers(Header.ContentType(MediaType.apply("application", "didcomm-signed+json"))), + body = Body.fromCharSequence(value.toJson) + ) + case Some(value: EncryptedMessage) => + Response( + status = Status.Accepted, + headers = Headers(Header.ContentType(MediaType.apply("application", "didcomm-encrypted+json"))), + body = Body.fromCharSequence(value.toJson) + ) } .catchAll { case MediatorDidError(error) => From 99e08dc163b748c8f7244f8f34b1650ccd95e52e Mon Sep 17 00:00:00 2001 From: FabioPinheiro Date: Tue, 7 Nov 2023 17:42:06 +0000 Subject: [PATCH 2/2] Update integration-tests --- .github/workflows/integration-tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 6bdb3af7..13154906 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -25,7 +25,7 @@ jobs: ATALA_GITHUB_ACTOR: ${{ secrets.ATALA_GITHUB_ACTOR }} ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }} REPORTS_DIR: "didcomm-v2-mediator-test-suite/target/site/serenity" - DIDCOMM_V2_TESTSUITE_VERSION: "v0.1.0" + DIDCOMM_V2_TESTSUITE_VERSION: "3ed43f8f864ef0ea1cd89a9f81d3f379e8c0c217" # old "v0.1.0" MEDIATOR_DID: "did:peer:2.Ez6LSghwSE437wnDE1pt3X6hVDUQzSjsHzinpX3XFvMjRAm7y.Vz6Mkhh1e5CEYYq6JBUcTZ6Cp2ranCWRrv7Yax3Le4N59R6dd.SeyJ0IjoiZG0iLCJzIjoiaHR0cDovL2xvY2FsaG9zdDo4MDgwIiwiciI6W10sImEiOlsiZGlkY29tbS92MiJdfQ" steps: - name: Checkout mediator @@ -35,7 +35,7 @@ jobs: uses: actions/checkout@v3 with: repository: input-output-hk/didcomm-v2-mediator-test-suite - path: './didcomm-v2-mediator-test-suite' + path: "./didcomm-v2-mediator-test-suite" ref: ${{ env.DIDCOMM_V2_TESTSUITE_VERSION }} - name: Setup Java and Scala @@ -62,7 +62,7 @@ jobs: uses: ndeloof/install-compose-action@v0.0.1 with: version: v2.19.1 # defaults to 'latest' - legacy: true # will also install in PATH as `docker-compose` + legacy: true # will also install in PATH as `docker-compose` - name: Build local version of Mediator Agent env: