• 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
/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/controller/DIDController.scala
1
package org.hyperledger.identus.castor.controller
2

3
import org.hyperledger.identus.castor.controller.http.{
4
  DIDDocument,
5
  DIDDocumentMetadata,
6
  DIDResolutionMetadata,
7
  DIDResolutionResult
8
}
9
import org.hyperledger.identus.castor.core.model.did.w3c.{
10
  makeW3CResolver,
11
  DIDDocumentMetadataRepr,
12
  DIDDocumentRepr,
13
  DIDResolutionErrorRepr
14
}
15
import org.hyperledger.identus.castor.core.service.DIDService
16
import zio.*
17

18
import scala.language.implicitConversions
19

20
trait DIDController {
21
  def getDID(did: String): UIO[DIDResolutionResult]
22
}
23

24
object DIDController {
25
  def toResolutionResult(
×
26
      didDocumentMetadata: DIDDocumentMetadataRepr,
27
      didDocument: DIDDocumentRepr
28
  ): DIDResolutionResult = {
29
    val isDeactivated = didDocumentMetadata.deactivated
30
    DIDResolutionResult(
31
      `@context` = "https://w3id.org/did-resolution/v1",
×
32
      didDocument = if (isDeactivated) None else Some(didDocument),
×
33
      didDocumentMetadata = didDocumentMetadata,
×
34
      didResolutionMetadata = DIDResolutionMetadata()
×
35
    )
36
  }
37

38
  def toResolutionResult(resolutionError: DIDResolutionErrorRepr): DIDResolutionResult = {
×
39
    DIDResolutionResult(
40
      `@context` = "https://w3id.org/did-resolution/v1",
×
41
      didDocument = None,
42
      didDocumentMetadata = DIDDocumentMetadata(),
×
43
      didResolutionMetadata = DIDResolutionMetadata(
×
44
        error = Some(resolutionError.value),
45
        errorMessage = resolutionError.errorMessage
46
      )
47
    )
48
  }
49
}
50

51
class DIDControllerImpl(service: DIDService) extends DIDController {
52

53
  override def getDID(did: String): UIO[DIDResolutionResult] = {
×
54
    for {
×
55
      result <- makeW3CResolver(service)(did).either
×
56
      resolutionResult = result.fold(
×
57
        DIDController.toResolutionResult,
×
58
        { case (metadata, document) =>
×
59
          DIDController.toResolutionResult(metadata, document)
×
60
        }
61
      )
62
    } yield resolutionResult
×
63
  }
64

65
}
66

67
object DIDControllerImpl {
68
  val layer: URLayer[DIDService, DIDController] = ZLayer.fromFunction(DIDControllerImpl(_))
×
69
}
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