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

hyperledger / identus-cloud-agent / 10833924030

12 Sep 2024 03:25PM UTC coverage: 48.864% (+0.07%) from 48.793%
10833924030

Pull #1351

CryptoKnightIOG
ATL-7660: Credential Schema as List

Signed-off-by: Bassam Riman <bassam.riman@iohk.io>
Pull Request #1351: feat: Support Array Of Credential Schema

15 of 28 new or added lines in 3 files covered. (53.57%)

222 existing lines in 68 files now uncovered.

7530 of 15410 relevant lines covered (48.86%)

0.49 hits per line

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

50.0
/shared/core/src/main/scala/org/hyperledger/identus/shared/http/GenericUriResolver.scala
1
package org.hyperledger.identus.shared.http
2

3
import io.lemonlabs.uri.{DataUrl, Uri, Url, Urn}
4
import zio.*
5

6
trait UriResolver {
7

8
  def resolve(uri: String): IO[GenericUriResolverError, String]
9

10
}
11

12
class GenericUriResolver(resolvers: Map[String, UriResolver]) extends UriResolver {
13

14
  override def resolve(uri: String): IO[GenericUriResolverError, String] = {
1✔
15
    val parsedUri = Uri.parse(uri)
1✔
16
    parsedUri match
17
      case url: Url =>
1✔
18
        url.schemeOption.fold(ZIO.fail(InvalidUri(uri)))(schema =>
1✔
UNCOV
19
          resolvers.get(schema).fold(ZIO.fail(UnsupportedUriSchema(schema)))(resolver => resolver.resolve(uri))
×
20
        )
21

22
      case Urn(path) => ZIO.fail(InvalidUri(uri)) // Must be a URL
×
23
  }
24

25
}
26

27
class DataUrlResolver extends UriResolver {
28
  override def resolve(dataUrl: String): IO[GenericUriResolverError, String] = {
1✔
29

30
    DataUrl.parseOption(dataUrl).fold(ZIO.fail(InvalidUri(dataUrl))) { url =>
1✔
31
      ZIO.succeed(String(url.data, url.mediaType.charset))
1✔
32
    }
33

34
  }
35

36
}
37

38
sealed trait GenericUriResolverError {
39
  def toThrowable: Throwable = {
×
40
    this match
41
      case InvalidUri(uri)              => new RuntimeException(s"Invalid URI: $uri")
×
42
      case UnsupportedUriSchema(schema) => new RuntimeException(s"Unsupported URI schema: $schema")
×
43
      case SchemaSpecificResolutionError(schema, error) =>
×
44
        new RuntimeException(s"Error resolving ${schema} URL: ${error.getMessage}")
×
45
  }
46
}
47

48
case class InvalidUri(uri: String) extends GenericUriResolverError
49

50
case class UnsupportedUriSchema(schema: String) extends GenericUriResolverError
51

52
case class SchemaSpecificResolutionError(schema: String, error: Throwable) extends GenericUriResolverError
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