• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hyperledger / identus-cloud-agent / 10793991050

10 Sep 2024 01:56PM CUT coverage: 48.504% (-4.5%) from 52.962%
10793991050

push

web-flow
build: sbt and plugins dependency update (#1337)

Signed-off-by: Hyperledger Bot <hyperledger-bot@hyperledger.org>
Signed-off-by: Yurii Shynbuiev <yurii.shynbuiev@iohk.io>
Co-authored-by: Hyperledger Bot <hyperledger-bot@hyperledger.org>
Co-authored-by: Yurii Shynbuiev <yurii.shynbuiev@iohk.io>

7406 of 15269 relevant lines covered (48.5%)

0.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/mercury/agent/src/main/scala/org/hyperledger/identus/mercury/CoordinateMediationPrograms.scala
1
package org.hyperledger.identus.mercury
2

3
import io.circe.*
4
import io.circe.parser.*
5
import org.hyperledger.identus.*
6
import org.hyperledger.identus.mercury.model.*
7
import org.hyperledger.identus.mercury.protocol.coordinatemediation.*
8
import org.hyperledger.identus.mercury.protocol.invitation.v2.Invitation
9
import zio.*
10

11
object CoordinateMediationPrograms {
12

13
  def replyToInvitation(replier: DidId, invitation: Invitation) = {
×
14
    val requestMediation = MediateRequest()
×
15
    Message(
×
16
      from = Some(replier),
17
      to = Seq(invitation.from),
×
18
      id = requestMediation.id,
19
      `type` = requestMediation.`type`
20
    )
21
  }
22

23
  private def toPrettyJson(parseToJson: String): Either[ParsingFailure, String] = {
×
24
    parse(parseToJson).map(_.spaces2)
×
25
  }
26

27
  def senderMediationRequestProgram(mediatorURL: String = "http://localhost:8000") = {
×
28

29
    for {
×
30
      _ <- ZIO.log("#### Send Mediation request ####")
×
31
      link <- InvitationPrograms
×
32
        .getInvitationProgram(mediatorURL + "/oob_url")
×
33
        .flatMap {
34
          case Left(value)  => ZIO.fail(value)
×
35
          case Right(value) => ZIO.succeed(value)
×
36
        }
37
      opsService <- ZIO.service[DidOps]
×
38
      agentService <- ZIO.service[DidAgent]
×
39

40
      planMessage = replyToInvitation(agentService.id, link)
×
41
      invitationFrom = link.from
42
      _ <- ZIO.log(s"Invitation from $invitationFrom")
×
43

44
      encryptedMessage <- opsService.packEncrypted(planMessage, to = invitationFrom)
×
45
      _ <- ZIO.log("Sending bytes ...")
×
46
      jsonString = encryptedMessage.string
×
47
      _ <- ZIO.log(jsonString)
×
48

49
      client <- ZIO.service[HttpClient]
×
50
      res <- client.postDIDComm(mediatorURL, jsonString)
×
51
      _ <- ZIO.log(res.bodyAsString)
×
52

53
      messageReceived <- opsService.unpack(res.bodyAsString)
×
54
      _ <- Console.printLine("Unpacking and decrypting the received message ...")
×
55
      _ <- Console.printLine("*" * 100)
×
56
      tmp <- ZIO.fromEither(toPrettyJson(messageReceived.message.toString))
×
57
      _ <- Console.printLine(tmp)
×
58
      _ <- Console.printLine("*" * 100)
×
59
      ret <- ZIO
×
60
        .fromEither(parse(messageReceived.message.toString))
×
61
        .flatMap { json =>
62
          json.as[MediateGrant] match {
×
63
            case Right(mediateGrant) => ZIO.succeed(mediateGrant)
×
64
            case Left(_) =>
×
65
              json.as[MediateDeny] match {
×
66
                case Right(mediateDeny) => ZIO.succeed(mediateDeny)
×
67
                case Left(ex)           => ZIO.fail(ex)
×
68
              }
69
          }
70
        }
71
      _ <- Console.printLine(ret)
×
72
      _ <- Console.printLine("*" * 100)
×
73
    } yield (ret)
×
74
  }
75

76
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc