Skip to content

Commit

Permalink
refactor: Move components to AdminModule (#3227)
Browse files Browse the repository at this point in the history
  • Loading branch information
seakayone authored May 2, 2024
1 parent dfc8925 commit 507888a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import org.knora.webapi.slice.admin.domain.service.ProjectExportStorageService
import org.knora.webapi.slice.admin.domain.service._
import org.knora.webapi.slice.common.api._
import org.knora.webapi.slice.common.repo.service.PredicateObjectMapper
import org.knora.webapi.slice.infrastructure.CacheManager
import org.knora.webapi.slice.infrastructure.JwtService
import org.knora.webapi.slice.infrastructure.JwtServiceLive
import org.knora.webapi.slice.infrastructure.api.ManagementEndpoints
Expand Down Expand Up @@ -87,26 +86,24 @@ object LayersTest {

type CommonR =
AdminApiEndpoints &
AdminModule.Provided &
ApiRoutes &
ApiV2Endpoints &
AppRouter &
AssetPermissionsResponder &
Authenticator &
AuthorizationRestService &
CacheManager &
CardinalityHandler &
ConstructResponseUtilV2 &
DspIngestClient &
GravsearchTypeInspectionRunner &
GroupRestService &
GroupService &
HttpServer &
IIIFRequestMessageHandler &
InferenceOptimizationService &
InvalidTokenCache &
IriConverter &
JwtService &
KnoraUserToUserConverter &
ListsResponder &
ListsResponderV2 &
MessageRelay &
Expand All @@ -122,7 +119,6 @@ object LayersTest {
ProjectExportStorageService &
ProjectImportService &
ProjectRestService &
ProjectService &
QueryTraverser &
RepositoryUpdater &
ResourceUtilV2 &
Expand All @@ -138,7 +134,6 @@ object LayersTest {
TestClientService &
TriplestoreService &
UserRestService &
UserService &
ValuesResponderV2

private val commonLayersForAllIntegrationTests =
Expand Down Expand Up @@ -167,7 +162,6 @@ object LayersTest {
IriService.layer,
JwtServiceLive.layer,
KnoraResponseRenderer.layer,
KnoraUserToUserConverter.layer,
ListsResponder.layer,
ListsResponderV2.layer,
ManagementEndpoints.layer,
Expand Down Expand Up @@ -202,7 +196,6 @@ object LayersTest {
TapirToPekkoInterpreter.layer,
TestClientService.layer,
TriplestoreServiceLive.layer,
UserService.layer,
ValuesResponderV2Live.layer,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ object KnoraUserToUserConverterSpec extends E2EZSpec {
isInProjectAdminGroup.map(ProjectIri.unsafeFrom).toChunk,
)

private val KnoraUserToUserConverter = ZIO.serviceWithZIO[KnoraUserToUserConverter]
private val knoraUserToUserConverter = ZIO.serviceWithZIO[KnoraUserToUserConverter]

override def e2eSpec =
suite("KnoraUserToUserConverter, given a KnoraUser")(
Expand All @@ -62,7 +62,7 @@ object KnoraUserToUserConverterSpec extends E2EZSpec {
Chunk.empty,
)
for {
actual <- KnoraUserToUserConverter(_.toUser(user))
actual <- knoraUserToUserConverter(_.toUser(user))
} yield assertTrue(actual.permissions == SharedTestDataADM2.rootUser.permissionData)
},
test("return the permissions profile (multi group user)") {
Expand All @@ -73,7 +73,7 @@ object KnoraUserToUserConverterSpec extends E2EZSpec {
Chunk(SharedTestDataADM.incunabulaProjectIri, imagesProjectIri),
)
for {
actual <- KnoraUserToUserConverter(_.toUser(user))
actual <- knoraUserToUserConverter(_.toUser(user))
} yield assertTrue(actual.permissions == SharedTestDataADM2.multiuserUser.permissionData)
},
test("return the permissions profile (incunabula project admin user)") {
Expand All @@ -85,7 +85,7 @@ object KnoraUserToUserConverterSpec extends E2EZSpec {
Chunk(SharedTestDataADM.incunabulaProjectIri),
)
for {
actual <- KnoraUserToUserConverter(_.toUser(user))
actual <- knoraUserToUserConverter(_.toUser(user))
} yield assertTrue(actual.permissions == SharedTestDataADM2.incunabulaProjectAdminUser.permissionData)
},
test("return the permissions profile (incunabula creator user)") {
Expand All @@ -97,7 +97,7 @@ object KnoraUserToUserConverterSpec extends E2EZSpec {
Chunk.empty,
)
for {
actual <- KnoraUserToUserConverter(_.toUser(user))
actual <- knoraUserToUserConverter(_.toUser(user))
} yield assertTrue(actual.permissions == SharedTestDataADM2.incunabulaCreatorUser.permissionData)
},
test("return the permissions profile (incunabula normal project member user)") {
Expand All @@ -107,7 +107,7 @@ object KnoraUserToUserConverterSpec extends E2EZSpec {
SystemAdmin.IsNotSystemAdmin,
Chunk.empty,
)
for { actual <- KnoraUserToUserConverter(_.toUser(user)) } yield assertTrue(
for { actual <- knoraUserToUserConverter(_.toUser(user)) } yield assertTrue(
actual.permissions == SharedTestDataADM2.incunabulaMemberUser.permissionData,
)
},
Expand All @@ -120,7 +120,7 @@ object KnoraUserToUserConverterSpec extends E2EZSpec {
Chunk(imagesProjectIri),
)
for {
actual <- KnoraUserToUserConverter(_.toUser(user))
actual <- knoraUserToUserConverter(_.toUser(user))
} yield assertTrue(actual.permissions == SharedTestDataADM2.imagesUser01.permissionData)
},
test("return the permissions profile (images-reviewer-user)") {
Expand All @@ -131,7 +131,7 @@ object KnoraUserToUserConverterSpec extends E2EZSpec {
Chunk.empty,
)
for {
actual <- KnoraUserToUserConverter(_.toUser(user))
actual <- knoraUserToUserConverter(_.toUser(user))
} yield assertTrue(actual.permissions == SharedTestDataADM2.imagesReviewerUser.permissionData)
},
test("return the permissions profile (anything user 01)") {
Expand All @@ -141,7 +141,7 @@ object KnoraUserToUserConverterSpec extends E2EZSpec {
SystemAdmin.IsNotSystemAdmin,
Chunk.empty,
)
for { actual <- KnoraUserToUserConverter(_.toUser(user)) } yield assertTrue(
for { actual <- knoraUserToUserConverter(_.toUser(user)) } yield assertTrue(
actual.permissions == SharedTestDataADM2.anythingUser1.permissionData,
)
},
Expand Down
9 changes: 1 addition & 8 deletions webapi/src/main/scala/org/knora/webapi/core/LayersLive.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import org.knora.webapi.slice.admin.api.service.UserRestService
import org.knora.webapi.slice.admin.domain.service._
import org.knora.webapi.slice.common.api._
import org.knora.webapi.slice.common.repo.service.PredicateObjectMapper
import org.knora.webapi.slice.infrastructure.CacheManager
import org.knora.webapi.slice.infrastructure.JwtService
import org.knora.webapi.slice.infrastructure.JwtServiceLive
import org.knora.webapi.slice.infrastructure.api.ManagementEndpoints
Expand Down Expand Up @@ -72,27 +71,25 @@ object LayersLive {
type DspEnvironmentLive =
ActorSystem &
AdminApiEndpoints &
AdminModule.Provided &
ApiRoutes &
ApiV2Endpoints &
AppConfigurations &
AppRouter &
AssetPermissionsResponder &
Authenticator &
AuthorizationRestService &
CacheManager &
CardinalityHandler &
ConstructResponseUtilV2 &
GravsearchTypeInspectionRunner &
GroupRestService &
GroupService &
HttpServer &
IIIFRequestMessageHandler &
InferenceOptimizationService &
InstrumentationServerConfig &
InvalidTokenCache &
IriConverter &
JwtService &
KnoraUserToUserConverter &
ListsResponder &
ListsResponderV2 &
MessageRelay &
Expand All @@ -107,7 +104,6 @@ object LayersLive {
ProjectExportStorageService &
ProjectImportService &
ProjectRestService &
ProjectService &
QueryTraverser &
RepositoryUpdater &
ResourceUtilV2 &
Expand All @@ -123,7 +119,6 @@ object LayersLive {
StringFormatter &
TriplestoreService &
UserRestService &
UserService &
ValuesResponderV2

/**
Expand Down Expand Up @@ -156,7 +151,6 @@ object LayersLive {
IriService.layer,
JwtServiceLive.layer,
KnoraResponseRenderer.layer,
KnoraUserToUserConverter.layer,
ListsResponder.layer,
ListsResponderV2.layer,
ManagementEndpoints.layer,
Expand Down Expand Up @@ -190,7 +184,6 @@ object LayersLive {
StringFormatter.live,
TapirToPekkoInterpreter.layer,
TriplestoreServiceLive.layer,
UserService.layer,
ValuesResponderV2Live.layer,
org.knora.webapi.core.ActorSystem.layer,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ import org.knora.webapi.store.triplestore.api.TriplestoreService
object AdminModule {

type Dependencies =
AppConfig & IriService & OntologyRepo & PredicateObjectMapper & TriplestoreService
AppConfig &
IriService &
OntologyRepo &
PredicateObjectMapper &
TriplestoreService

type Provided = AdminDomainModule.Provided

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,22 @@ object AdminDomainModule {
KnoraGroupService &
KnoraProjectService &
KnoraUserService &
KnoraUserToUserConverter &
MaintenanceService &
PasswordService &
ProjectService
ProjectService &
UserService

val layer = ZLayer.makeSome[Dependencies, Provided](
AdministrativePermissionService.layer,
GroupService.layer,
KnoraGroupService.layer,
KnoraProjectService.layer,
KnoraUserService.layer,
KnoraUserToUserConverter.layer,
MaintenanceService.layer,
PasswordService.layer,
ProjectService.layer,
UserService.layer,
)
}

0 comments on commit 507888a

Please sign in to comment.