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

hyperledger / identus-cloud-agent / 11056733508

26 Sep 2024 04:52PM UTC coverage: 48.532% (-0.03%) from 48.558%
11056733508

Pull #1366

CryptoKnightIOG
ATL-7775: Fix integration test

Signed-off-by: Bassam Riman <bassam.riman@iohk.io>
Pull Request #1366: feat: Default Backend API to Array Of Credential Schema

41 of 54 new or added lines in 8 files covered. (75.93%)

187 existing lines in 61 files now uncovered.

7622 of 15705 relevant lines covered (48.53%)

0.49 hits per line

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

42.86
/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✔
UNCOV
18
        url.schemeOption.fold(ZIO.fail(InvalidUri(uri)))(schema =>
×
19
          resolvers.get(schema).fold(ZIO.fail(UnsupportedUriSchema(schema)))(resolver => resolver.resolve(uri))
1✔
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

UNCOV
30
    DataUrl.parseOption(dataUrl).fold(ZIO.fail(InvalidUri(dataUrl))) { url =>
×
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