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: Move and rename UserADM #2978

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -19,11 +19,11 @@ import org.knora.webapi.e2e.ClientTestDataCollector
import org.knora.webapi.e2e.TestDataFileContent
import org.knora.webapi.e2e.TestDataFilePath
import org.knora.webapi.messages.admin.responder.projectsmessages._
import org.knora.webapi.messages.admin.responder.usersmessages.UserADM
import org.knora.webapi.messages.admin.responder.usersmessages.UsersADMJsonProtocol._
import org.knora.webapi.messages.store.triplestoremessages.RdfDataObject
import org.knora.webapi.messages.util.rdf.RdfModel
import org.knora.webapi.sharedtestdata.SharedTestDataADM
import org.knora.webapi.slice.admin.domain.model.User
import org.knora.webapi.util.AkkaHttpUtils
import org.knora.webapi.util.MutableTestIri

Expand Down Expand Up @@ -546,7 +546,7 @@ class ProjectsADME2ESpec extends E2ESpec with ProjectsADMJsonProtocol {
// log.debug(s"response: {}", response)
assert(response.status === StatusCodes.OK)

val members: Seq[UserADM] = AkkaHttpUtils.httpResponseToJson(response).fields("members").convertTo[Seq[UserADM]]
val members: Seq[User] = AkkaHttpUtils.httpResponseToJson(response).fields("members").convertTo[Seq[User]]
members.size should be(4)

clientTestDataCollector.addFile(
Expand All @@ -569,7 +569,7 @@ class ProjectsADME2ESpec extends E2ESpec with ProjectsADMJsonProtocol {
// log.debug(s"response: {}", response)
assert(response.status === StatusCodes.OK)

val members: Seq[UserADM] = AkkaHttpUtils.httpResponseToJson(response).fields("members").convertTo[Seq[UserADM]]
val members: Seq[User] = AkkaHttpUtils.httpResponseToJson(response).fields("members").convertTo[Seq[User]]
members.size should be(4)
}

Expand All @@ -581,7 +581,7 @@ class ProjectsADME2ESpec extends E2ESpec with ProjectsADMJsonProtocol {
// log.debug(s"response: {}", response)
assert(response.status === StatusCodes.OK)

val members: Seq[UserADM] = AkkaHttpUtils.httpResponseToJson(response).fields("members").convertTo[Seq[UserADM]]
val members: Seq[User] = AkkaHttpUtils.httpResponseToJson(response).fields("members").convertTo[Seq[User]]
members.size should be(4)
}

Expand All @@ -593,7 +593,7 @@ class ProjectsADME2ESpec extends E2ESpec with ProjectsADMJsonProtocol {
// log.debug(s"response: {}", response)
assert(response.status === StatusCodes.OK)

val members: Seq[UserADM] = AkkaHttpUtils.httpResponseToJson(response).fields("members").convertTo[Seq[UserADM]]
val members: Seq[User] = AkkaHttpUtils.httpResponseToJson(response).fields("members").convertTo[Seq[User]]
members.size should be(2)
clientTestDataCollector.addFile(
TestDataFileContent(
Expand All @@ -615,7 +615,7 @@ class ProjectsADME2ESpec extends E2ESpec with ProjectsADMJsonProtocol {
// log.debug(s"response: {}", response)
assert(response.status === StatusCodes.OK)

val members: Seq[UserADM] = AkkaHttpUtils.httpResponseToJson(response).fields("members").convertTo[Seq[UserADM]]
val members: Seq[User] = AkkaHttpUtils.httpResponseToJson(response).fields("members").convertTo[Seq[User]]
members.size should be(2)
}

Expand All @@ -627,7 +627,7 @@ class ProjectsADME2ESpec extends E2ESpec with ProjectsADMJsonProtocol {
// log.debug(s"response: {}", response)
assert(response.status === StatusCodes.OK)

val members: Seq[UserADM] = AkkaHttpUtils.httpResponseToJson(response).fields("members").convertTo[Seq[UserADM]]
val members: Seq[User] = AkkaHttpUtils.httpResponseToJson(response).fields("members").convertTo[Seq[User]]
members.size should be(2)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ import org.knora.webapi.messages.admin.responder.groupsmessages.GroupADM
import org.knora.webapi.messages.admin.responder.groupsmessages.GroupsADMJsonProtocol
import org.knora.webapi.messages.admin.responder.projectsmessages.ProjectADM
import org.knora.webapi.messages.admin.responder.projectsmessages.ProjectsADMJsonProtocol
import org.knora.webapi.messages.admin.responder.usersmessages.UserADM
import org.knora.webapi.messages.admin.responder.usersmessages.UsersADMJsonProtocol._
import org.knora.webapi.messages.store.triplestoremessages.TriplestoreJsonProtocol
import org.knora.webapi.messages.util.KnoraSystemInstances
import org.knora.webapi.sharedtestdata.SharedTestDataADM
import org.knora.webapi.sharedtestdata.SharedTestDataADM2
import org.knora.webapi.slice.admin.domain.model.User
import org.knora.webapi.util.AkkaHttpUtils
import org.knora.webapi.util.MutableTestIri

Expand All @@ -51,7 +51,7 @@ class UsersADME2ESpec
private def addRootUserCredentials() = addCredentials(rootUser)
private def addProjectAdminUserCredentials() = addCredentials(projectAdminUser)
private def addNormalUserCredentials() = addCredentials(normalUser)
private def addCredentials(user: UserADM): RequestTransformer = addCredentials(
private def addCredentials(user: User): RequestTransformer = addCredentials(
BasicHttpCredentials(user.email, "test")
)

Expand Down Expand Up @@ -215,7 +215,7 @@ class UsersADME2ESpec
val request = Get(baseApiUrl + s"/admin/users/iri/$normalUserIriEnc") ~> addProjectAdminUserCredentials()
val response: HttpResponse = singleAwaitingRequest(request)
response.status should be(StatusCodes.OK)
val result: UserADM = AkkaHttpUtils.httpResponseToJson(response).fields("user").convertTo[UserADM]
val result: User = AkkaHttpUtils.httpResponseToJson(response).fields("user").convertTo[User]
result.givenName should be(SharedTestDataADM.normalUser.givenName)
result.familyName should be(SharedTestDataADM.normalUser.familyName)
result.status should be(false)
Expand All @@ -237,7 +237,7 @@ class UsersADME2ESpec
val request = Get(baseApiUrl + s"/admin/users/iri/$normalUserIriEnc")
val response: HttpResponse = singleAwaitingRequest(request)
response.status should be(StatusCodes.OK)
val result: UserADM = AkkaHttpUtils.httpResponseToJson(response).fields("user").convertTo[UserADM]
val result: User = AkkaHttpUtils.httpResponseToJson(response).fields("user").convertTo[User]
result.givenName should be(SharedTestDataADM.normalUser.givenName)
result.familyName should be(SharedTestDataADM.normalUser.familyName)
result.status should be(false)
Expand Down Expand Up @@ -328,7 +328,7 @@ class UsersADME2ESpec

response.status should be(StatusCodes.OK)

val result: UserADM = AkkaHttpUtils.httpResponseToJson(response).fields("user").convertTo[UserADM]
val result: User = AkkaHttpUtils.httpResponseToJson(response).fields("user").convertTo[User]

// check that the custom IRI is correctly assigned
result.id should be(customUserIri)
Expand Down Expand Up @@ -394,7 +394,7 @@ class UsersADME2ESpec

response.status should be(StatusCodes.OK)

val result: UserADM = AkkaHttpUtils.httpResponseToJson(response).fields("user").convertTo[UserADM]
val result: User = AkkaHttpUtils.httpResponseToJson(response).fields("user").convertTo[User]

// check that the special characters were escaped correctly
result.id should equal(otherCustomUserIri)
Expand All @@ -419,7 +419,7 @@ class UsersADME2ESpec

response.status should be(StatusCodes.OK)

val result: UserADM = AkkaHttpUtils.httpResponseToJson(response).fields("user").convertTo[UserADM]
val result: User = AkkaHttpUtils.httpResponseToJson(response).fields("user").convertTo[User]
result.givenName should be("Updated\tGivenName")
result.familyName should be("Updated\"FamilyName")
}
Expand All @@ -432,7 +432,7 @@ class UsersADME2ESpec

response.status should be(StatusCodes.OK)

val result: UserADM = AkkaHttpUtils.httpResponseToJson(response).fields("user").convertTo[UserADM]
val result: User = AkkaHttpUtils.httpResponseToJson(response).fields("user").convertTo[User]
result.givenName should be("Updated\tGivenName")
result.familyName should be("Updated\"FamilyName")
}
Expand Down Expand Up @@ -468,7 +468,7 @@ class UsersADME2ESpec

response.status should be(StatusCodes.OK)

val result: UserADM = AkkaHttpUtils.httpResponseToJson(response).fields("user").convertTo[UserADM]
val result: User = AkkaHttpUtils.httpResponseToJson(response).fields("user").convertTo[User]
result.username should be("donald.duck")
result.email should be("[email protected]")
result.givenName should be("Donald")
Expand Down Expand Up @@ -626,7 +626,7 @@ class UsersADME2ESpec
val response: HttpResponse = singleAwaitingRequest(request)
response.status should be(StatusCodes.OK)

val result: UserADM = AkkaHttpUtils.httpResponseToJson(response).fields("user").convertTo[UserADM]
val result: User = AkkaHttpUtils.httpResponseToJson(response).fields("user").convertTo[User]
result.username should be("donald.big.duck")
result.email should be("[email protected]")
result.givenName should be("Big Donald")
Expand Down Expand Up @@ -887,7 +887,7 @@ class UsersADME2ESpec
val response: HttpResponse = singleAwaitingRequest(request)
response.status should be(StatusCodes.OK)

val result: UserADM = AkkaHttpUtils.httpResponseToJson(response).fields("user").convertTo[UserADM]
val result: User = AkkaHttpUtils.httpResponseToJson(response).fields("user").convertTo[User]
result.status should be(false)
clientTestDataCollector.addFile(
TestDataFileContent(
Expand Down Expand Up @@ -942,7 +942,7 @@ class UsersADME2ESpec
val response: HttpResponse = singleAwaitingRequest(request)
response.status should be(StatusCodes.OK)

val result: UserADM = AkkaHttpUtils.httpResponseToJson(response).fields("user").convertTo[UserADM]
val result: User = AkkaHttpUtils.httpResponseToJson(response).fields("user").convertTo[User]
result.permissions.groupsPerProject
.get("http://www.knora.org/ontology/knora-admin#SystemProject")
.head should equal(List("http://www.knora.org/ontology/knora-admin#SystemAdmin"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package org.knora.webapi.e2e.admin.lists

import org.apache.pekko

import org.knora.webapi.messages.admin.responder.usersmessages.UserADM
import org.knora.webapi.slice.admin.domain.model.User

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

Expand All @@ -16,7 +16,7 @@ import pekko.http.scaladsl.model.headers.BasicHttpCredentials
*
* @param user the user's information.
*/
case class CredentialsADM(user: UserADM, password: String) {
case class CredentialsADM(user: User, password: String) {

def iri = user.id

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ import org.knora.webapi.messages.StringFormatter
import org.knora.webapi.messages.admin.responder.permissionsmessages.PermissionProfileType
import org.knora.webapi.messages.admin.responder.permissionsmessages.PermissionsDataADM
import org.knora.webapi.sharedtestdata.SharedTestDataADM
import org.knora.webapi.slice.admin.domain.model.User

/**
* This spec is used to test the [[UserADM]] and [[UserIdentifierADM]] classes.
* This spec is used to test the [[User]] and [[UserIdentifierADM]] classes.
*/
class UsersMessagesADMSpec extends CoreSpec {

Expand All @@ -37,7 +38,7 @@ class UsersMessagesADMSpec extends CoreSpec {

"The UserADM case class" should {
"return a RESTRICTED UserADM when requested " in {
val rootUser = UserADM(
val rootUser = User(
id = id,
username = username,
email = email,
Expand All @@ -51,7 +52,7 @@ class UsersMessagesADMSpec extends CoreSpec {
projects = projects,
permissions = permissions
)
val rootUserRestricted = UserADM(
val rootUserRestricted = User(
id = id,
username = username,
email = email,
Expand Down Expand Up @@ -86,7 +87,7 @@ class UsersMessagesADMSpec extends CoreSpec {
"allow checking the SCrypt passwords" in {
val encoder = new SCryptPasswordEncoder(16384, 8, 1, 32, 64)
val hp = encoder.encode("123456")
val up = UserADM(
val up = User(
id = "something",
username = "something",
email = "something",
Expand All @@ -111,7 +112,7 @@ class UsersMessagesADMSpec extends CoreSpec {
"allow checking the BCrypt passwords" in {
val encoder = new BCryptPasswordEncoder()
val hp = encoder.encode("123456")
val up = UserADM(
val up = User(
id = "something",
username = "something",
email = "something",
Expand Down Expand Up @@ -168,7 +169,7 @@ class UsersMessagesADMSpec extends CoreSpec {
val userEmail = "[email protected]"
val username = "user"

val user = UserADM(
val user = User(
id = "http://rdfh.ch/users/example",
username = username,
email = userEmail,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import java.util.UUID
import org.knora.webapi.messages.IriConversions._
import org.knora.webapi.messages.OntologyConstants
import org.knora.webapi.messages.StringFormatter
import org.knora.webapi.messages.admin.responder.usersmessages.UserADM
import org.knora.webapi.messages.util.rdf.JsonLDKeywords
import org.knora.webapi.messages.v2.responder.standoffmessages.CreateMappingRequestMetadataV2
import org.knora.webapi.messages.v2.responder.standoffmessages.CreateMappingRequestV2
import org.knora.webapi.messages.v2.responder.standoffmessages.CreateMappingRequestXMLV2
import org.knora.webapi.sharedtestdata.SharedTestDataADM2.anythingProjectIri
import org.knora.webapi.slice.admin.domain.model.User

sealed abstract case class DefineStandoffMapping private (
mappingName: String,
Expand Down Expand Up @@ -55,7 +55,7 @@ sealed abstract case class DefineStandoffMapping private (
*/
def toMessage(
xml: String,
user: UserADM
user: User
): CreateMappingRequestV2 = {
val mappingMetadata = CreateMappingRequestMetadataV2(
label = label,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import org.knora.webapi.messages.IriConversions._
import org.knora.webapi.messages.OntologyConstants
import org.knora.webapi.messages.SmartIri
import org.knora.webapi.messages.StringFormatter
import org.knora.webapi.messages.admin.responder.usersmessages.UserADM
import org.knora.webapi.messages.store.triplestoremessages._
import org.knora.webapi.messages.twirl.queries.sparql
import org.knora.webapi.messages.util.CalendarNameGregorian
Expand All @@ -38,6 +37,7 @@ import org.knora.webapi.models.filemodels._
import org.knora.webapi.responders.v2.ResourcesResponseCheckerV2.compareReadResourcesSequenceV2Response
import org.knora.webapi.routing.UnsafeZioRun
import org.knora.webapi.sharedtestdata.SharedTestDataADM
import org.knora.webapi.slice.admin.domain.model.User
import org.knora.webapi.store.triplestore.api.TriplestoreService
import org.knora.webapi.store.triplestore.api.TriplestoreService.Queries.Ask
import org.knora.webapi.store.triplestore.api.TriplestoreService.Queries.Select
Expand Down Expand Up @@ -479,7 +479,7 @@ class ResourcesResponderV2Spec extends CoreSpec with ImplicitSender {
)
)

private def getResource(resourceIri: IRI, requestingUser: UserADM): ReadResourceV2 = {
private def getResource(resourceIri: IRI, requestingUser: User): ReadResourceV2 = {
appActor ! ResourcesGetRequestV2(
resourceIris = Seq(resourceIri),
targetSchema = ApiV2Complex,
Expand All @@ -497,7 +497,7 @@ class ResourcesResponderV2Spec extends CoreSpec with ImplicitSender {
outputResource: ReadResourceV2,
defaultResourcePermissions: String,
defaultValuePermissions: String,
requestingUser: UserADM
requestingUser: User
): Unit = {
assert(outputResource.resourceIri == inputResourceIri)
assert(outputResource.resourceClassIri == inputResource.resourceClassIri)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import org.knora.webapi.messages.IriConversions._
import org.knora.webapi.messages.OntologyConstants
import org.knora.webapi.messages.SmartIri
import org.knora.webapi.messages.StringFormatter
import org.knora.webapi.messages.admin.responder.usersmessages.UserADM
import org.knora.webapi.messages.store.triplestoremessages._
import org.knora.webapi.messages.util.CalendarNameGregorian
import org.knora.webapi.messages.util.DatePrecisionYear
Expand All @@ -34,6 +33,7 @@ import org.knora.webapi.models.filemodels.FileModelUtil
import org.knora.webapi.models.filemodels.FileType
import org.knora.webapi.routing.UnsafeZioRun
import org.knora.webapi.sharedtestdata.SharedTestDataADM
import org.knora.webapi.slice.admin.domain.model.User
import org.knora.webapi.store.iiif.errors.SipiException
import org.knora.webapi.store.triplestore.api.TriplestoreService
import org.knora.webapi.store.triplestore.api.TriplestoreService.Queries.Select
Expand Down Expand Up @@ -185,7 +185,7 @@ class ValuesResponderV2Spec extends CoreSpec with ImplicitSender {
private def getResourceWithValues(
resourceIri: IRI,
propertyIrisForGravsearch: Seq[SmartIri],
requestingUser: UserADM
requestingUser: User
): ReadResourceV2 = {
// Make a Gravsearch query from a template.
val gravsearchQuery: String = org.knora.webapi.messages.twirl.queries.gravsearch.txt
Expand Down Expand Up @@ -235,7 +235,7 @@ class ValuesResponderV2Spec extends CoreSpec with ImplicitSender {
valueIri: IRI,
customDeleteDate: Option[Instant] = None,
deleteComment: Option[String] = None,
requestingUser: UserADM,
requestingUser: User,
isLinkValue: Boolean = false
): Unit = {
appActor ! ResourcesGetRequestV2(
Expand Down Expand Up @@ -315,7 +315,7 @@ class ValuesResponderV2Spec extends CoreSpec with ImplicitSender {
propertyIriForGravsearch: SmartIri,
propertyIriInResult: SmartIri,
expectedValueIri: IRI,
requestingUser: UserADM,
requestingUser: User,
checkLastModDateChanged: Boolean = true
): ReadValueV2 = {
val resource = getResourceWithValues(
Expand All @@ -338,7 +338,7 @@ class ValuesResponderV2Spec extends CoreSpec with ImplicitSender {
)
}

private def getResourceLastModificationDate(resourceIri: IRI, requestingUser: UserADM): Option[Instant] = {
private def getResourceLastModificationDate(resourceIri: IRI, requestingUser: User): Option[Instant] = {
appActor ! ResourcesPreviewGetRequestV2(
resourceIris = Seq(resourceIri),
targetSchema = ApiV2Complex,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import dsp.errors.BadCredentialsException
import dsp.errors.BadRequestException
import org.knora.webapi._
import org.knora.webapi.messages.StringFormatter
import org.knora.webapi.messages.admin.responder.usersmessages.UserADM
import org.knora.webapi.messages.admin.responder.usersmessages.UserIdentifierADM
import org.knora.webapi.messages.v2.routing.authenticationmessages.KnoraCredentialsV2.KnoraJWTTokenCredentialsV2
import org.knora.webapi.messages.v2.routing.authenticationmessages.KnoraCredentialsV2.KnoraPasswordCredentialsV2
import org.knora.webapi.routing.Authenticator.AUTHENTICATION_INVALIDATION_CACHE_NAME
import org.knora.webapi.sharedtestdata.SharedTestDataADM
import org.knora.webapi.slice.admin.domain.model.User
import org.knora.webapi.util.ZioScalaTestUtil.assertFailsWithA
import org.knora.webapi.util.cache.CacheUtil

Expand All @@ -34,7 +34,7 @@ class AuthenticatorSpec extends CoreSpec with ImplicitSender with PrivateMethodT

implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance

private def testUserAdmFromIri(iri: String) = UserADM(iri, "", "", "", "", false, "")
private def testUserAdmFromIri(iri: String) = User(iri, "", "", "", "", false, "")

"During Authentication" when {
"called, the 'getUserADMByEmail' method " should {
Expand Down
Loading
Loading