From 1b7f88b58eb8263481c819d7f81fd25d59db5ee0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kleinb=C3=B6lting?= Date: Mon, 12 Feb 2024 14:26:26 +0100 Subject: [PATCH] refactor: Remove token property from user which is always None (#3041) --- .../webapi/e2e/v2/AuthenticationV2E2ESpec.scala | 1 - .../usersmessages/UsersMessagesADMSpec.scala | 5 ----- .../webapi/sharedtestdata/SharedTestDataADM.scala | 15 --------------- .../knora/webapi/sharedtestdata/UserProfile.scala | 1 - .../usersmessages/UsersMessagesADM.scala | 2 +- .../messages/util/KnoraSystemInstances.scala | 3 --- .../responders/admin/UsersResponderADM.scala | 1 - .../webapi/slice/admin/domain/model/User.scala | 5 +---- 8 files changed, 2 insertions(+), 31 deletions(-) diff --git a/integration/src/test/scala/org/knora/webapi/e2e/v2/AuthenticationV2E2ESpec.scala b/integration/src/test/scala/org/knora/webapi/e2e/v2/AuthenticationV2E2ESpec.scala index 2de049b5f1..e4c0736a28 100644 --- a/integration/src/test/scala/org/knora/webapi/e2e/v2/AuthenticationV2E2ESpec.scala +++ b/integration/src/test/scala/org/knora/webapi/e2e/v2/AuthenticationV2E2ESpec.scala @@ -396,7 +396,6 @@ class AuthenticationV2E2ESpec extends E2ESpec with AuthenticationV2JsonProtocol /* check for sensitive information leakage */ val body: String = Await.result(Unmarshal(response.entity).to[String], 1.seconds) assert(body contains "\"password\":null") - assert(body contains "\"token\":null") } } } diff --git a/integration/src/test/scala/org/knora/webapi/messages/admin/responder/usersmessages/UsersMessagesADMSpec.scala b/integration/src/test/scala/org/knora/webapi/messages/admin/responder/usersmessages/UsersMessagesADMSpec.scala index af2de8214d..c68780d155 100644 --- a/integration/src/test/scala/org/knora/webapi/messages/admin/responder/usersmessages/UsersMessagesADMSpec.scala +++ b/integration/src/test/scala/org/knora/webapi/messages/admin/responder/usersmessages/UsersMessagesADMSpec.scala @@ -25,7 +25,6 @@ class UsersMessagesADMSpec extends CoreSpec { private val username = SharedTestDataADM.rootUser.username private val email = SharedTestDataADM.rootUser.email private val password = SharedTestDataADM.rootUser.password - private val token = SharedTestDataADM.rootUser.token private val givenName = SharedTestDataADM.rootUser.givenName private val familyName = SharedTestDataADM.rootUser.familyName private val status = SharedTestDataADM.rootUser.status @@ -47,7 +46,6 @@ class UsersMessagesADMSpec extends CoreSpec { status = status, lang = lang, password = password, - token = token, groups = groups, projects = projects, permissions = permissions @@ -61,7 +59,6 @@ class UsersMessagesADMSpec extends CoreSpec { status = status, lang = lang, password = None, - token = None, groups = groups, projects = projects, permissions = permissions.ofType(PermissionProfileType.Restricted) @@ -96,7 +93,6 @@ class UsersMessagesADMSpec extends CoreSpec { status = status, lang = lang, password = Some(hp), - token = None, groups = groups, projects = projects, permissions = PermissionsDataADM() @@ -121,7 +117,6 @@ class UsersMessagesADMSpec extends CoreSpec { status = status, lang = lang, password = Some(hp), - token = None, groups = groups, projects = projects, permissions = PermissionsDataADM() diff --git a/integration/src/test/scala/org/knora/webapi/sharedtestdata/SharedTestDataADM.scala b/integration/src/test/scala/org/knora/webapi/sharedtestdata/SharedTestDataADM.scala index 25f3561cca..c59f10d3fe 100644 --- a/integration/src/test/scala/org/knora/webapi/sharedtestdata/SharedTestDataADM.scala +++ b/integration/src/test/scala/org/knora/webapi/sharedtestdata/SharedTestDataADM.scala @@ -47,7 +47,6 @@ object SharedTestDataADM { status = true, lang = "de", password = Option("$2a$12$7XEBehimXN1rbhmVgQsyve08.vtDmKK7VMin4AdgCEtE4DWgfQbTK"), - token = None, groups = Seq.empty[GroupADM], projects = Seq.empty[ProjectADM], permissions = PermissionsDataADM( @@ -69,7 +68,6 @@ object SharedTestDataADM { status = true, lang = "de", password = Some("$2a$12$7XEBehimXN1rbhmVgQsyve08.vtDmKK7VMin4AdgCEtE4DWgfQbTK"), - token = None, groups = Seq.empty[GroupADM], projects = Seq.empty[ProjectADM], permissions = PermissionsDataADM( @@ -90,7 +88,6 @@ object SharedTestDataADM { status = true, lang = "de", password = Some("$2a$12$7XEBehimXN1rbhmVgQsyve08.vtDmKK7VMin4AdgCEtE4DWgfQbTK"), - token = None, groups = Seq.empty[GroupADM], projects = Seq.empty[ProjectADM], permissions = PermissionsDataADM() @@ -107,7 +104,6 @@ object SharedTestDataADM { status = false, lang = "de", password = Some("$2a$12$7XEBehimXN1rbhmVgQsyve08.vtDmKK7VMin4AdgCEtE4DWgfQbTK"), - token = None, groups = Seq.empty[GroupADM], projects = Seq.empty[ProjectADM], permissions = PermissionsDataADM() @@ -127,7 +123,6 @@ object SharedTestDataADM { status = true, lang = "de", password = Some("$2a$12$7XEBehimXN1rbhmVgQsyve08.vtDmKK7VMin4AdgCEtE4DWgfQbTK"), - token = None, groups = Seq(imagesReviewerGroup), projects = Seq(incunabulaProject, imagesProject), permissions = PermissionsDataADM( @@ -208,7 +203,6 @@ object SharedTestDataADM { status = true, lang = "de", password = Some("$2a$12$7XEBehimXN1rbhmVgQsyve08.vtDmKK7VMin4AdgCEtE4DWgfQbTK"), - token = None, groups = Seq.empty[GroupADM], projects = Seq(imagesProject), permissions = PermissionsDataADM( @@ -238,7 +232,6 @@ object SharedTestDataADM { status = true, lang = "de", password = Some("$2a$12$7XEBehimXN1rbhmVgQsyve08.vtDmKK7VMin4AdgCEtE4DWgfQbTK"), - token = None, groups = Seq.empty[GroupADM], projects = Seq(imagesProject), permissions = PermissionsDataADM( @@ -264,7 +257,6 @@ object SharedTestDataADM { status = true, lang = "de", password = Some("$2a$10$fTEr/xVjPq7UBAy1O6KWKOM1scLhKGeRQdR4GTA997QPqHzXv0MnW"), - token = None, groups = Seq(imagesReviewerGroup), projects = Seq(imagesProject), permissions = PermissionsDataADM( @@ -375,7 +367,6 @@ object SharedTestDataADM { status = true, lang = "de", password = Some("$2a$12$7XEBehimXN1rbhmVgQsyve08.vtDmKK7VMin4AdgCEtE4DWgfQbTK"), - token = None, groups = Seq.empty[GroupADM], projects = Seq(incunabulaProject), permissions = PermissionsDataADM( @@ -405,7 +396,6 @@ object SharedTestDataADM { status = true, lang = "de", password = Some("$2a$12$7XEBehimXN1rbhmVgQsyve08.vtDmKK7VMin4AdgCEtE4DWgfQbTK"), - token = None, groups = Seq.empty[GroupADM], projects = Seq(incunabulaProject), permissions = PermissionsDataADM( @@ -431,7 +421,6 @@ object SharedTestDataADM { status = true, lang = "de", password = Some("$2a$12$7XEBehimXN1rbhmVgQsyve08.vtDmKK7VMin4AdgCEtE4DWgfQbTK"), - token = None, groups = Seq.empty[GroupADM], projects = Seq(incunabulaProject), permissions = PermissionsDataADM( @@ -546,7 +535,6 @@ object SharedTestDataADM { status = true, lang = "de", password = Some("$2a$12$7XEBehimXN1rbhmVgQsyve08.vtDmKK7VMin4AdgCEtE4DWgfQbTK"), - token = None, groups = Seq.empty[GroupADM], projects = Seq(anythingProject), permissions = PermissionsDataADM( @@ -575,7 +563,6 @@ object SharedTestDataADM { status = true, lang = "de", password = Some("$2a$12$7XEBehimXN1rbhmVgQsyve08.vtDmKK7VMin4AdgCEtE4DWgfQbTK"), - token = None, groups = Seq.empty[GroupADM], projects = Seq(anythingProject), permissions = PermissionsDataADM( @@ -603,7 +590,6 @@ object SharedTestDataADM { status = true, lang = "de", password = Some("$2a$12$7XEBehimXN1rbhmVgQsyve08.vtDmKK7VMin4AdgCEtE4DWgfQbTK"), - token = None, groups = Seq.empty[GroupADM], projects = Seq(anythingProject), permissions = PermissionsDataADM( @@ -694,7 +680,6 @@ object SharedTestDataADM { status = true, lang = "en", password = Some("$2a$10$fTEr/xVjPq7UBAy1O6KWKOM1scLhKGeRQdR4GTA997QPqHzXv0MnW"), - token = None, groups = Seq.empty[GroupADM], projects = Seq(beolProject), permissions = PermissionsDataADM( diff --git a/integration/src/test/scala/org/knora/webapi/sharedtestdata/UserProfile.scala b/integration/src/test/scala/org/knora/webapi/sharedtestdata/UserProfile.scala index bcd15d7f09..ac1839c158 100644 --- a/integration/src/test/scala/org/knora/webapi/sharedtestdata/UserProfile.scala +++ b/integration/src/test/scala/org/knora/webapi/sharedtestdata/UserProfile.scala @@ -61,7 +61,6 @@ object UserProfile { }, email = Some(userADM.email), password = userADM.password, - token = userADM.token, firstname = Some(userADM.givenName), lastname = Some(userADM.familyName), status = Some(userADM.status), diff --git a/webapi/src/main/scala/org/knora/webapi/messages/admin/responder/usersmessages/UsersMessagesADM.scala b/webapi/src/main/scala/org/knora/webapi/messages/admin/responder/usersmessages/UsersMessagesADM.scala index 2ce1df63ee..6eafab64f2 100644 --- a/webapi/src/main/scala/org/knora/webapi/messages/admin/responder/usersmessages/UsersMessagesADM.scala +++ b/webapi/src/main/scala/org/knora/webapi/messages/admin/responder/usersmessages/UsersMessagesADM.scala @@ -495,7 +495,7 @@ object UsersADMJsonProtocol with GroupsADMJsonProtocol with PermissionsADMJsonProtocol { - implicit val userADMFormat: JsonFormat[User] = jsonFormat12(User) + implicit val userADMFormat: JsonFormat[User] = jsonFormat11(User) implicit val groupMembersGetResponseADMFormat: RootJsonFormat[GroupMembersGetResponseADM] = jsonFormat(GroupMembersGetResponseADM, "members") implicit val changeUserApiRequestADMFormat: RootJsonFormat[ChangeUserApiRequestADM] = diff --git a/webapi/src/main/scala/org/knora/webapi/messages/util/KnoraSystemInstances.scala b/webapi/src/main/scala/org/knora/webapi/messages/util/KnoraSystemInstances.scala index 4562307b3a..b34e409587 100644 --- a/webapi/src/main/scala/org/knora/webapi/messages/util/KnoraSystemInstances.scala +++ b/webapi/src/main/scala/org/knora/webapi/messages/util/KnoraSystemInstances.scala @@ -30,7 +30,6 @@ object KnoraSystemInstances { status = true, lang = "en", password = None, - token = None, groups = Seq.empty[GroupADM], projects = Seq.empty[ProjectADM], permissions = PermissionsDataADM() @@ -48,11 +47,9 @@ object KnoraSystemInstances { status = true, lang = "en", password = None, - token = None, groups = Seq.empty[GroupADM], projects = Seq.empty[ProjectADM], permissions = PermissionsDataADM() ) } - } diff --git a/webapi/src/main/scala/org/knora/webapi/responders/admin/UsersResponderADM.scala b/webapi/src/main/scala/org/knora/webapi/responders/admin/UsersResponderADM.scala index 95f91081af..89ca7f12be 100644 --- a/webapi/src/main/scala/org/knora/webapi/responders/admin/UsersResponderADM.scala +++ b/webapi/src/main/scala/org/knora/webapi/responders/admin/UsersResponderADM.scala @@ -1752,7 +1752,6 @@ final case class UsersResponderADMLive( password = propsMap .get(OntologyConstants.KnoraAdmin.Password.toSmartIri) .map(_.head.asInstanceOf[StringLiteralV2].value), - token = None, groups = groups, projects = projects, permissions = permissionData diff --git a/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/model/User.scala b/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/model/User.scala index ef67809c48..004b7d4326 100644 --- a/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/model/User.scala +++ b/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/model/User.scala @@ -53,7 +53,6 @@ final case class User( status: Boolean, lang: String, password: Option[String] = None, - token: Option[String] = None, groups: Seq[GroupADM] = Vector.empty[GroupADM], projects: Seq[ProjectADM] = Seq.empty[ProjectADM], permissions: PermissionsDataADM = PermissionsDataADM() @@ -104,7 +103,6 @@ final case class User( status = false, lang = "", password = None, - token = None, groups = Seq.empty[GroupADM], projects = Seq.empty[ProjectADM], permissions = PermissionsDataADM() @@ -112,13 +110,12 @@ final case class User( case UserInformationTypeADM.Short => self.copy( password = None, - token = None, groups = Seq.empty[GroupADM], projects = Seq.empty[ProjectADM], permissions = PermissionsDataADM() ) case UserInformationTypeADM.Restricted => - self.copy(password = None, token = None) + self.copy(password = None) case UserInformationTypeADM.Full => self }