• 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/agent/server/MainApp.scala
1
package org.hyperledger.identus.agent.server
2

3
import com.nimbusds.jose.crypto.bc.BouncyCastleProviderSingleton
4
import io.micrometer.prometheus.{PrometheusConfig, PrometheusMeterRegistry}
5
import org.hyperledger.identus.agent.server.config.AppConfig
6
import org.hyperledger.identus.agent.server.http.ZioHttpClient
7
import org.hyperledger.identus.agent.server.sql.Migrations as AgentMigrations
8
import org.hyperledger.identus.agent.walletapi.service.{
9
  EntityServiceImpl,
10
  ManagedDIDService,
11
  ManagedDIDServiceWithEventNotificationImpl,
12
  WalletManagementServiceImpl
13
}
14
import org.hyperledger.identus.agent.walletapi.sql.{
15
  JdbcDIDNonSecretStorage,
16
  JdbcEntityRepository,
17
  JdbcWalletNonSecretStorage
18
}
19
import org.hyperledger.identus.agent.walletapi.storage.GenericSecretStorage
20
import org.hyperledger.identus.castor.controller.{DIDControllerImpl, DIDRegistrarControllerImpl}
21
import org.hyperledger.identus.castor.core.service.DIDServiceImpl
22
import org.hyperledger.identus.castor.core.util.DIDOperationValidator
23
import org.hyperledger.identus.connect.controller.ConnectionControllerImpl
24
import org.hyperledger.identus.connect.core.service.{ConnectionServiceImpl, ConnectionServiceNotifier}
25
import org.hyperledger.identus.connect.sql.repository.{JdbcConnectionRepository, Migrations as ConnectMigrations}
26
import org.hyperledger.identus.credentialstatus.controller.CredentialStatusControllerImpl
27
import org.hyperledger.identus.didcomm.controller.DIDCommControllerImpl
28
import org.hyperledger.identus.event.controller.EventControllerImpl
29
import org.hyperledger.identus.event.notification.EventNotificationServiceImpl
30
import org.hyperledger.identus.iam.authentication.{DefaultAuthenticator, Oid4vciAuthenticatorFactory}
31
import org.hyperledger.identus.iam.authentication.apikey.JdbcAuthenticationRepository
32
import org.hyperledger.identus.iam.authorization.core.EntityPermissionManagementService
33
import org.hyperledger.identus.iam.authorization.DefaultPermissionManagementService
34
import org.hyperledger.identus.iam.entity.http.controller.{EntityController, EntityControllerImpl}
35
import org.hyperledger.identus.iam.wallet.http.controller.WalletManagementControllerImpl
36
import org.hyperledger.identus.issue.controller.IssueControllerImpl
37
import org.hyperledger.identus.mercury.*
38
import org.hyperledger.identus.oid4vci.controller.CredentialIssuerControllerImpl
39
import org.hyperledger.identus.oid4vci.service.OIDCCredentialIssuerServiceImpl
40
import org.hyperledger.identus.oid4vci.storage.InMemoryIssuanceSessionService
41
import org.hyperledger.identus.pollux.core.service.*
42
import org.hyperledger.identus.pollux.core.service.verification.VcVerificationServiceImpl
43
import org.hyperledger.identus.pollux.credentialdefinition.controller.CredentialDefinitionControllerImpl
44
import org.hyperledger.identus.pollux.credentialschema.controller.{
45
  CredentialSchemaController,
46
  CredentialSchemaControllerImpl,
47
  VerificationPolicyControllerImpl
48
}
49
import org.hyperledger.identus.pollux.sql.repository.{
50
  JdbcCredentialDefinitionRepository,
51
  JdbcCredentialRepository,
52
  JdbcCredentialSchemaRepository,
53
  JdbcCredentialStatusListRepository,
54
  JdbcOID4VCIIssuerMetadataRepository,
55
  JdbcPresentationRepository,
56
  JdbcVerificationPolicyRepository,
57
  Migrations as PolluxMigrations
58
}
59
import org.hyperledger.identus.presentproof.controller.PresentProofControllerImpl
60
import org.hyperledger.identus.resolvers.DIDResolver
61
import org.hyperledger.identus.system.controller.SystemControllerImpl
62
import org.hyperledger.identus.verification.controller.VcVerificationControllerImpl
63
import zio.*
64
import zio.logging.*
65
import zio.logging.backend.SLF4J
66
import zio.logging.LogFormat.*
67
import zio.metrics.connectors.micrometer
68
import zio.metrics.connectors.micrometer.MicrometerConfig
69
import zio.metrics.jvm.DefaultJvmMetrics
70

71
import java.security.Security
72

73
object MainApp extends ZIOAppDefault {
74

75
  val colorFormat: LogFormat =
76
    fiberId.color(LogColor.YELLOW) |-|
×
77
      line.highlight |-|
×
78
      allAnnotations |-|
79
      cause.highlight
×
80

81
  override val bootstrap: ZLayer[ZIOAppArgs, Any, Any] =
82
    Runtime.removeDefaultLoggers >>> SLF4J.slf4j(colorFormat)
×
83

84
  Security.insertProviderAt(BouncyCastleProviderSingleton.getInstance(), 2)
×
85

86
  // FIXME: remove this when db app user have correct privileges provisioned by k8s operator.
87
  // This should be executed before migration to have correct privilege for new objects.
88
  private val preMigrations = for {
×
89
    _ <- ZIO.logInfo("running pre-migration steps.")
×
90
    appConfig <- ZIO.service[AppConfig].provide(SystemModule.configLayer)
×
91
    _ <- PolluxMigrations
×
92
      .initDbPrivileges(appConfig.pollux.database.appUsername)
×
93
      .provide(RepoModule.polluxTransactorLayer)
×
94
    _ <- ConnectMigrations
×
95
      .initDbPrivileges(appConfig.connect.database.appUsername)
×
96
      .provide(RepoModule.connectTransactorLayer)
×
97
    _ <- AgentMigrations
×
98
      .initDbPrivileges(appConfig.agent.database.appUsername)
×
99
      .provide(RepoModule.agentTransactorLayer)
×
100
  } yield ()
×
101

102
  private val migrations = for {
×
103
    _ <- ZIO.serviceWithZIO[PolluxMigrations](_.migrateAndRepair)
×
104
    _ <- ZIO.serviceWithZIO[ConnectMigrations](_.migrateAndRepair)
×
105
    _ <- ZIO.serviceWithZIO[AgentMigrations](_.migrateAndRepair)
×
106
    _ <- ZIO.logInfo("Running post-migration RLS checks for DB application users")
×
107
    _ <- PolluxMigrations.validateRLS.provide(RepoModule.polluxContextAwareTransactorLayer)
×
108
    _ <- ConnectMigrations.validateRLS.provide(RepoModule.connectContextAwareTransactorLayer)
×
109
    _ <- AgentMigrations.validateRLS.provide(RepoModule.agentContextAwareTransactorLayer)
×
110
  } yield ()
×
111
  override def run: ZIO[Any, Throwable, Unit] = {
×
112

113
    val app = for {
×
114
      _ <- Console
×
115
        .printLine(s"""
×
116
      |██╗██████╗ ███████╗███╗   ██╗████████╗██╗   ██╗███████╗
117
      |██║██╔══██╗██╔════╝████╗  ██║╚══██╔══╝██║   ██║██╔════╝
118
      |██║██║  ██║█████╗  ██╔██╗ ██║   ██║   ██║   ██║███████╗
119
      |██║██║  ██║██╔══╝  ██║╚██╗██║   ██║   ██║   ██║╚════██║
120
      |██║██████╔╝███████╗██║ ╚████║   ██║   ╚██████╔╝███████║
121
      |╚═╝╚═════╝ ╚══════╝╚═╝  ╚═══╝   ╚═╝    ╚═════╝ ╚══════╝
122
      |
123
      | ██████╗██╗      ██████╗ ██╗   ██╗██████╗
124
      |██╔════╝██║     ██╔═══██╗██║   ██║██╔══██╗
125
      |██║     ██║     ██║   ██║██║   ██║██║  ██║
126
      |██║     ██║     ██║   ██║██║   ██║██║  ██║
127
      |╚██████╗███████╗╚██████╔╝╚██████╔╝██████╔╝
128
      | ╚═════╝╚══════╝ ╚═════╝  ╚═════╝ ╚═════╝
129
      |
130
      | █████╗  ██████╗ ███████╗███╗   ██╗████████╗
131
      |██╔══██╗██╔════╝ ██╔════╝████╗  ██║╚══██╔══╝
132
      |███████║██║  ███╗█████╗  ██╔██╗ ██║   ██║
133
      |██╔══██║██║   ██║██╔══╝  ██║╚██╗██║   ██║
134
      |██║  ██║╚██████╔╝███████╗██║ ╚████║   ██║
135
      |╚═╝  ╚═╝ ╚═════╝ ╚══════╝╚═╝  ╚═══╝   ╚═╝
136
      |
137
      |version: ${buildinfo.BuildInfo.version}
138
      |
139
      |""".stripMargin)
×
140
        .ignore
141

142
      _ <- preMigrations
×
143
      _ <- migrations
×
144

145
      app <- CloudAgentApp.run
×
146
        .provide(
×
147
          DidCommX.liveLayer,
148
          // infra
149
          SystemModule.configLayer,
150
          ZioHttpClient.layer,
151
          // observability
152
          DefaultJvmMetrics.live.unit,
×
153
          SystemControllerImpl.layer,
154
          ZLayer.succeed(PrometheusMeterRegistry(PrometheusConfig.DEFAULT)),
×
155
          ZLayer.succeed(MicrometerConfig.default),
×
156
          micrometer.micrometerLayer,
157
          // controller
158
          ConnectionControllerImpl.layer,
159
          CredentialSchemaControllerImpl.layer,
160
          CredentialDefinitionControllerImpl.layer,
161
          DIDControllerImpl.layer,
162
          DIDRegistrarControllerImpl.layer,
163
          IssueControllerImpl.layer,
164
          CredentialStatusControllerImpl.layer,
165
          PresentProofControllerImpl.layer,
166
          VcVerificationControllerImpl.layer,
167
          VerificationPolicyControllerImpl.layer,
168
          EntityControllerImpl.layer,
169
          WalletManagementControllerImpl.layer,
170
          EventControllerImpl.layer,
171
          DIDCommControllerImpl.layer,
172
          // domain
173
          AppModule.apolloLayer,
174
          AppModule.didJwtResolverLayer,
175
          DIDOperationValidator.layer(),
×
176
          DIDResolver.layer,
177
          HttpURIDereferencerImpl.layer,
178
          // service
179
          ConnectionServiceImpl.layer >>> ConnectionServiceNotifier.layer,
×
180
          CredentialSchemaServiceImpl.layer,
181
          CredentialDefinitionServiceImpl.layer,
182
          CredentialStatusListServiceImpl.layer,
183
          LinkSecretServiceImpl.layer >>> CredentialServiceImpl.layer >>> CredentialServiceNotifier.layer,
×
184
          DIDServiceImpl.layer,
185
          EntityServiceImpl.layer,
186
          ManagedDIDServiceWithEventNotificationImpl.layer,
187
          LinkSecretServiceImpl.layer >>> PresentationServiceImpl.layer >>> PresentationServiceNotifier.layer,
×
188
          VerificationPolicyServiceImpl.layer,
189
          WalletManagementServiceImpl.layer,
190
          VcVerificationServiceImpl.layer,
191
          // authentication
192
          AppModule.builtInAuthenticatorLayer,
193
          AppModule.keycloakAuthenticatorLayer,
194
          AppModule.keycloakPermissionManagementLayer,
195
          DefaultAuthenticator.layer,
196
          DefaultPermissionManagementService.layer,
×
197
          EntityPermissionManagementService.layer,
198
          Oid4vciAuthenticatorFactory.layer,
×
199
          // grpc
200
          GrpcModule.prismNodeStubLayer,
201
          // storage
202
          RepoModule.agentContextAwareTransactorLayer ++ RepoModule.agentTransactorLayer >>> JdbcDIDNonSecretStorage.layer,
×
203
          RepoModule.agentContextAwareTransactorLayer >>> JdbcWalletNonSecretStorage.layer,
×
204
          RepoModule.allSecretStorageLayer,
205
          RepoModule.agentTransactorLayer >>> JdbcEntityRepository.layer,
×
206
          RepoModule.agentTransactorLayer >>> JdbcAuthenticationRepository.layer,
×
207
          RepoModule.connectContextAwareTransactorLayer ++ RepoModule.connectTransactorLayer >>> JdbcConnectionRepository.layer,
×
208
          RepoModule.polluxContextAwareTransactorLayer ++ RepoModule.polluxTransactorLayer >>> JdbcCredentialRepository.layer,
×
209
          RepoModule.polluxContextAwareTransactorLayer ++ RepoModule.polluxTransactorLayer >>> JdbcCredentialStatusListRepository.layer,
×
210
          RepoModule.polluxContextAwareTransactorLayer ++ RepoModule.polluxTransactorLayer >>> JdbcCredentialSchemaRepository.layer,
×
211
          RepoModule.polluxContextAwareTransactorLayer ++ RepoModule.polluxTransactorLayer >>> JdbcCredentialDefinitionRepository.layer,
×
212
          RepoModule.polluxContextAwareTransactorLayer ++ RepoModule.polluxTransactorLayer >>> JdbcPresentationRepository.layer,
×
213
          RepoModule.polluxContextAwareTransactorLayer ++ RepoModule.polluxTransactorLayer >>> JdbcOID4VCIIssuerMetadataRepository.layer,
×
214
          RepoModule.polluxContextAwareTransactorLayer >>> JdbcVerificationPolicyRepository.layer,
×
215
          // oidc
216
          CredentialIssuerControllerImpl.layer,
217
          InMemoryIssuanceSessionService.layer,
218
          OID4VCIIssuerMetadataServiceImpl.layer,
×
219
          OIDCCredentialIssuerServiceImpl.layer,
220
          // event notification service
221
          ZLayer.succeed(500) >>> EventNotificationServiceImpl.layer,
×
222
          // HTTP client
223
          SystemModule.zioHttpClientLayer,
224
          Scope.default,
225
        )
226
    } yield app
227

228
    app.provide(
×
229
      RepoModule.polluxDbConfigLayer(appUser = false) >>> PolluxMigrations.layer,
×
230
      RepoModule.connectDbConfigLayer(appUser = false) >>> ConnectMigrations.layer,
×
231
      RepoModule.agentDbConfigLayer(appUser = false) >>> AgentMigrations.layer,
×
232
    )
233
  }
234

235
}
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