Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Migrate admin/permissions endpoints to tapir (DEV-1590) #2975

Merged
merged 37 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
0434f1b
Add createAdministrativePermission endpoint
seakayone Dec 28, 2023
3116f41
add copyright headers
seakayone Dec 28, 2023
6bc36e4
migrate get AdministrativePermissionForProjectGroup
seakayone Dec 28, 2023
6c8d10d
migrate get AdministrativePermissionsForProject
seakayone Dec 28, 2023
e9c7b47
fixup
seakayone Dec 28, 2023
52b2d6a
sort tokens
seakayone Dec 28, 2023
de8fc16
Introduce GroupIri PathVariable and move GroupIri to slice admin package
seakayone Dec 28, 2023
94227ac
migrate delete permission
seakayone Dec 28, 2023
3930150
migrate delete permission
seakayone Dec 28, 2023
df3e7c7
copyright header fmt
seakayone Dec 28, 2023
461d0d5
Fix GroupIri to allow builtIn UserGroups from knora-admin
seakayone Dec 28, 2023
f5abde0
migrate create doa permissions
seakayone Dec 28, 2023
6275cb3
migrate getPermissionsDaopByProjectIri
seakayone Dec 28, 2023
d1baaf3
migrate getPermissionsByProjectIri
seakayone Dec 28, 2023
5712e7d
migrate putPermissionsProjectIriGroup
seakayone Dec 28, 2023
193b004
cleanup
seakayone Dec 28, 2023
ef5dac6
add def toExternal[A <: AdminKnoraResponseADM](response: A): Task[A]
seakayone Dec 29, 2023
4fe7847
migrate updatePermissionHasPermissions
seakayone Dec 29, 2023
8e15d82
migrate updatePermissionResourceClass
seakayone Dec 29, 2023
88b9d4c
migrate updatePermissionProperty
seakayone Dec 29, 2023
937b002
rm DefaultObjectAccessPermissionCreateRequestADM
seakayone Dec 30, 2023
a8e950f
rm AdministrativePermissionCreateRequestADM
seakayone Dec 30, 2023
c9f7734
Merge branch 'main' into refactor/migrate-admin-permissions-to-tapir
seakayone Jan 8, 2024
13a0155
move request param validation into Responder
seakayone Jan 8, 2024
2835d74
revert
seakayone Jan 8, 2024
3d95d46
fix validation of CreateDefaultObjectAccessPermissionAPIRequestADM
seakayone Jan 8, 2024
4e69f3c
fixup
seakayone Jan 8, 2024
1a5868e
fmt
seakayone Jan 8, 2024
502eda9
Merge branch 'main' into refactor/migrate-admin-permissions-to-tapir
seakayone Jan 8, 2024
dbc463d
remove relative import
seakayone Jan 8, 2024
762163b
Update integration/src/test/scala/org/knora/webapi/util/ZioScalaTestU…
seakayone Jan 8, 2024
456e32e
Merge branch 'main' into refactor/migrate-admin-permissions-to-tapir
seakayone Jan 8, 2024
b890503
Merge branch 'main' into refactor/migrate-admin-permissions-to-tapir
seakayone Jan 8, 2024
3fc7ac1
copyright headers
seakayone Jan 8, 2024
413cefa
Merge branch 'main' into refactor/migrate-admin-permissions-to-tapir
seakayone Jan 9, 2024
0f54648
Fix abbrevation
seakayone Jan 9, 2024
65ee8f2
Remove redundant list of built in groups in GroupIri
seakayone Jan 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import org.knora.webapi.responders.v2.ontology.OntologyHelpersLive
import org.knora.webapi.routing._
import org.knora.webapi.slice.admin.api._
import org.knora.webapi.slice.admin.api.service.MaintenanceRestService
import org.knora.webapi.slice.admin.api.service.PermissionsRestService
import org.knora.webapi.slice.admin.api.service.ProjectADMRestService
import org.knora.webapi.slice.admin.api.service.ProjectsADMRestServiceLive
import org.knora.webapi.slice.admin.api.service.UsersADMRestServiceLive
Expand Down Expand Up @@ -77,11 +78,12 @@ object LayersTest {
with DspIngestTestContainer
with SharedVolumes.Images

type CommonR0 = ActorSystem with AppConfigurations with SipiService with JwtService with StringFormatter
type CommonR0 = ActorSystem with AppConfigurations with JwtService with SipiService with StringFormatter
type CommonR =
ApiRoutes
with AppRouter
with Authenticator
with AuthorizationRestService
with CacheService
with CacheServiceRequestMessageHandler
with CardinalityHandler
Expand All @@ -102,10 +104,12 @@ object LayersTest {
with MessageRelay
with OntologyCache
with OntologyHelpers
with OntologyInferencer
with OntologyRepo
with OntologyResponderV2
with PermissionUtilADM
with PermissionsResponderADM
with PermissionsRestService
with PredicateObjectMapper
with ProjectADMRestService
with ProjectADMService
Expand All @@ -118,12 +122,10 @@ object LayersTest {
with ResourceUtilV2
with ResourcesResponderV2
with RestCardinalityService
with RestPermissionService
with RestResourceInfoService
with SearchApiRoutes
with SearchResponderV2
with SipiResponderADM
with OntologyInferencer
with StandoffResponderV2
with StandoffTagUtilV2
with State
Expand All @@ -139,6 +141,7 @@ object LayersTest {
ApiRoutes.layer,
AppRouter.layer,
AuthenticatorLive.layer,
AuthorizationRestServiceLive.layer,
BaseEndpoints.layer,
CacheServiceInMemImpl.layer,
CacheServiceRequestMessageHandlerLive.layer,
Expand Down Expand Up @@ -170,7 +173,10 @@ object LayersTest {
OntologyRepoLive.layer,
OntologyResponderV2Live.layer,
PermissionUtilADMLive.layer,
PermissionsEndpoints.layer,
PermissionsEndpointsHandlers.layer,
PermissionsResponderADMLive.layer,
PermissionsRestService.layer,
PredicateObjectMapper.layer,
PredicateRepositoryLive.layer,
ProjectADMServiceLive.layer,
Expand All @@ -187,7 +193,6 @@ object LayersTest {
ResourceUtilV2Live.layer,
ResourcesResponderV2Live.layer,
RestCardinalityServiceLive.layer,
RestPermissionServiceLive.layer,
SearchApiRoutes.layer,
SearchResponderV2Live.layer,
SipiResponderADMLive.layer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@

package org.knora.webapi.e2e.admin

import org.apache.pekko
import org.apache.pekko.http.scaladsl.model._
import org.apache.pekko.http.scaladsl.model.headers.BasicHttpCredentials
import spray.json._
import zio.durationInt

import java.net.URLEncoder

import org.knora.webapi.E2ESpec
import org.knora.webapi.e2e.ClientTestDataCollector
import org.knora.webapi.e2e.TestDataFileContent
Expand All @@ -18,11 +21,10 @@ import org.knora.webapi.messages.store.triplestoremessages.TriplestoreJsonProtoc
import org.knora.webapi.sharedtestdata.SharedOntologyTestDataADM
import org.knora.webapi.sharedtestdata.SharedTestDataADM
import org.knora.webapi.sharedtestdata.SharedTestDataADM2
import org.knora.webapi.slice.admin.domain.model.GroupIri
import org.knora.webapi.slice.admin.domain.model.KnoraProject.ProjectIri
import org.knora.webapi.util.AkkaHttpUtils

import pekko.http.scaladsl.model._
import pekko.http.scaladsl.model.headers.BasicHttpCredentials

/**
* End-to-End (E2E) test specification for testing the 'v1/permissions' route.
*
Expand All @@ -38,9 +40,10 @@ class PermissionsADME2ESpec extends E2ESpec with TriplestoreJsonProtocol {
"The Permissions Route ('admin/permissions')" when {
"getting permissions" should {
"return a group's administrative permission" in {

val projectIri = java.net.URLEncoder.encode(SharedTestDataADM2.imagesProjectInfo.id, "utf-8")
val groupIri = java.net.URLEncoder.encode(OntologyConstants.KnoraAdmin.ProjectMember, "utf-8")
val projectIri =
URLEncoder.encode(ProjectIri.unsafeFrom(SharedTestDataADM2.imagesProjectInfo.id).value, "utf-8")
val groupIri =
URLEncoder.encode(GroupIri.unsafeFrom(OntologyConstants.KnoraAdmin.ProjectMember).value, "utf-8")
val request = Get(baseApiUrl + s"/admin/permissions/ap/$projectIri/$groupIri") ~> addCredentials(
BasicHttpCredentials(SharedTestDataADM.rootUser.email, SharedTestDataADM.testPass)
)
Expand Down Expand Up @@ -68,7 +71,7 @@ class PermissionsADME2ESpec extends E2ESpec with TriplestoreJsonProtocol {
}

"return a project's administrative permissions" in {
val projectIri = java.net.URLEncoder.encode(SharedTestDataADM2.imagesProjectInfo.id, "utf-8")
val projectIri = URLEncoder.encode(SharedTestDataADM2.imagesProjectInfo.id, "utf-8")

val request = Get(baseApiUrl + s"/admin/permissions/ap/$projectIri") ~> addCredentials(
BasicHttpCredentials(SharedTestDataADM.rootUser.email, SharedTestDataADM.testPass)
Expand All @@ -93,7 +96,7 @@ class PermissionsADME2ESpec extends E2ESpec with TriplestoreJsonProtocol {
}

"return a project's default object access permissions" in {
val projectIri = java.net.URLEncoder.encode(SharedTestDataADM2.imagesProjectInfo.id, "utf-8")
val projectIri = URLEncoder.encode(SharedTestDataADM2.imagesProjectInfo.id, "utf-8")

val request = Get(baseApiUrl + s"/admin/permissions/doap/$projectIri") ~> addCredentials(
BasicHttpCredentials(SharedTestDataADM.rootUser.email, SharedTestDataADM.testPass)
Expand All @@ -118,7 +121,7 @@ class PermissionsADME2ESpec extends E2ESpec with TriplestoreJsonProtocol {
}

"return a project's all permissions" in {
val projectIri = java.net.URLEncoder.encode(SharedTestDataADM2.imagesProjectInfo.id, "utf-8")
val projectIri = URLEncoder.encode(SharedTestDataADM2.imagesProjectInfo.id, "utf-8")

val request = Get(baseApiUrl + s"/admin/permissions/$projectIri") ~> addCredentials(
BasicHttpCredentials(SharedTestDataADM.rootUser.email, SharedTestDataADM.testPass)
Expand Down Expand Up @@ -419,7 +422,7 @@ class PermissionsADME2ESpec extends E2ESpec with TriplestoreJsonProtocol {
"updating permissions" should {
"change the group of an administrative permission" in {
val permissionIri = "http://rdfh.ch/permissions/00FF/buxHAlz8SHuu0FuiLN_tKQ"
val encodedPermissionIri = java.net.URLEncoder.encode(permissionIri, "utf-8")
val encodedPermissionIri = URLEncoder.encode(permissionIri, "utf-8")
val newGroupIri = "http://rdfh.ch/groups/00FF/images-reviewer"
val updatePermissionGroup =
s"""{
Expand Down Expand Up @@ -461,7 +464,7 @@ class PermissionsADME2ESpec extends E2ESpec with TriplestoreJsonProtocol {

"change the group of a default object access permission" in {
val permissionIri = "http://rdfh.ch/permissions/00FF/sdHG20U6RoiwSu8MeAT1vA"
val encodedPermissionIri = java.net.URLEncoder.encode(permissionIri, "utf-8")
val encodedPermissionIri = URLEncoder.encode(permissionIri, "utf-8")
val newGroupIri = "http://rdfh.ch/groups/00FF/images-reviewer"
val updatePermissionGroup =
s"""{
Expand Down Expand Up @@ -504,7 +507,7 @@ class PermissionsADME2ESpec extends E2ESpec with TriplestoreJsonProtocol {

"change the set of hasPermissions of an administrative permission" in {
val permissionIri = "http://rdfh.ch/permissions/00FF/buxHAlz8SHuu0FuiLN_tKQ"
val encodedPermissionIri = java.net.URLEncoder.encode(permissionIri, "utf-8")
val encodedPermissionIri = URLEncoder.encode(permissionIri, "utf-8")
val updateHasPermissions =
s"""{
| "hasPermissions":[{"additionalInformation":null,"name":"ProjectAdminGroupAllPermission","permissionCode":null}]
Expand Down Expand Up @@ -549,7 +552,7 @@ class PermissionsADME2ESpec extends E2ESpec with TriplestoreJsonProtocol {

"change the set of hasPermissions of a default object access permission" in {
val permissionIri = "http://rdfh.ch/permissions/00FF/Q3OMWyFqStGYK8EXmC7KhQ"
val encodedPermissionIri = java.net.URLEncoder.encode(permissionIri, "utf-8")
val encodedPermissionIri = URLEncoder.encode(permissionIri, "utf-8")
val updateHasPermissions =
s"""{
| "hasPermissions":[{"additionalInformation":"http://www.knora.org/ontology/knora-admin#ProjectMember","name":"D","permissionCode":7}]
Expand Down Expand Up @@ -600,7 +603,7 @@ class PermissionsADME2ESpec extends E2ESpec with TriplestoreJsonProtocol {

"change the resource class of a default object access permission" in {
val permissionIri = "http://rdfh.ch/permissions/00FF/Q3OMWyFqStGYK8EXmC7KhQ"
val encodedPermissionIri = java.net.URLEncoder.encode(permissionIri, "utf-8")
val encodedPermissionIri = URLEncoder.encode(permissionIri, "utf-8")
val resourceClassIri = SharedOntologyTestDataADM.INCUNABULA_BOOK_RESOURCE_CLASS
val updateResourceClass =
s"""{
Expand Down Expand Up @@ -646,7 +649,7 @@ class PermissionsADME2ESpec extends E2ESpec with TriplestoreJsonProtocol {

"change the property of a default object access permission" in {
val permissionIri = "http://rdfh.ch/permissions/00FF/Mck2xJDjQ_Oimi_9z4aFaA"
val encodedPermissionIri = java.net.URLEncoder.encode(permissionIri, "utf-8")
val encodedPermissionIri = URLEncoder.encode(permissionIri, "utf-8")
val propertyClassIri = SharedOntologyTestDataADM.IMAGES_TITEL_PROPERTY
val updateResourceClass =
s"""{
Expand Down Expand Up @@ -691,7 +694,7 @@ class PermissionsADME2ESpec extends E2ESpec with TriplestoreJsonProtocol {
"delete request" should {
"erase a defaultObjectAccess permission" in {
val permissionIri = customDOAPIri
val encodedPermissionIri = java.net.URLEncoder.encode(permissionIri, "utf-8")
val encodedPermissionIri = URLEncoder.encode(permissionIri, "utf-8")
val request = Delete(baseApiUrl + s"/admin/permissions/" + encodedPermissionIri) ~> addCredentials(
BasicHttpCredentials(SharedTestDataADM.rootUser.email, SharedTestDataADM.testPass)
)
Expand All @@ -712,7 +715,7 @@ class PermissionsADME2ESpec extends E2ESpec with TriplestoreJsonProtocol {
}
"erase an administrative permission" in {
val permissionIri = "http://rdfh.ch/permissions/00FF/buxHAlz8SHuu0FuiLN_tKQ"
val encodedPermissionIri = java.net.URLEncoder.encode(permissionIri, "utf-8")
val encodedPermissionIri = URLEncoder.encode(permissionIri, "utf-8")
val request = Delete(baseApiUrl + s"/admin/permissions/" + encodedPermissionIri) ~> addCredentials(
BasicHttpCredentials(SharedTestDataADM.rootUser.email, SharedTestDataADM.testPass)
)
Expand Down
Loading
Loading