Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
fix(escape-special-characters): escape special characters in user rou…
…tes (DSP-1557) (#1902) * feat(valueobjects): add user value objects * feat(valueobjects): add user value objects * example either usage * create UserEntity to represent request payload for user creation * add trait and inherit from it in value objects * add unit tests for the creation of value objects * add unittests for value objects * refactor createNewUserADM * reformat UsersRouteADM * add docstrings to unit tests * add e2e spec for handling special characters * use value objects in update basic user information * refactor update password with value objects * add e2e tests for updating the user password * refactor update user status * refactor systemAdmin * refactor project membership and add test * remove log.debug statements from e2e tests * remove unused code from e2e tests * cleanup code * cleanup code * add tests * add test * add new client-test-data * refactor change basic user information request * update unit tests * fix failed unit tests * fix expected-client-test-data.txt * add test to get user with special characters * delete password information in debug log * resolve merge conflicts * Revert "Merge branch 'main' into wip/DSP-1557-escape-special-characters-in-user-routes" This reverts commit 12c486a, reversing changes made to e9d35b6. * Revert "resolve merge conflicts" This reverts commit 4cdefb7. * resolve merge conflicts * integrate changes from main * rename userEntity Co-authored-by: Ivan Subotic <400790+subotic@users.noreply.github.com>
- Loading branch information
Showing
17 changed files
with
3,370 additions
and
2,213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...rc/main/scala/org/knora/webapi/messages/admin/responder/usersmessages/AdminEntities.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package org.knora.webapi.messages.admin.responder.usersmessages | ||
|
||
import org.knora.webapi.IRI | ||
|
||
sealed trait ValidationError | ||
case object InvalidUsername extends ValidationError | ||
case object InvalidEmail extends ValidationError | ||
case object InvalidGivenOrFamilyName extends ValidationError | ||
case object InvalidPassword extends ValidationError | ||
case object InvalidLanguageCode extends ValidationError | ||
|
||
trait UserCreatePayloadTraitADM { | ||
def create( | ||
id: Option[IRI], | ||
username: Username, | ||
email: Email, | ||
givenName: GivenName, | ||
familyName: FamilyName, | ||
password: Password, | ||
status: Status, | ||
lang: LanguageCode, | ||
systemAdmin: SystemAdmin | ||
): UserCreatePayloadADM | ||
} | ||
|
||
/** | ||
* User entity representing the payload for the create user request | ||
*/ | ||
sealed abstract case class UserCreatePayloadADM( | ||
id: Option[IRI], | ||
username: Option[Username], | ||
email: Option[Email], | ||
givenName: Option[GivenName], | ||
familyName: Option[FamilyName], | ||
password: Option[Password], | ||
status: Option[Status], | ||
lang: Option[LanguageCode], | ||
projects: Option[Seq[IRI]], | ||
projectsAdmin: Option[Seq[IRI]], | ||
groups: Option[Seq[IRI]], | ||
systemAdmin: Option[SystemAdmin] | ||
) | ||
|
||
object UserCreatePayloadADM extends UserCreatePayloadTraitADM { | ||
|
||
/** The create constructor needs all attributes but id which is optional */ | ||
override def create( | ||
id: Option[IRI] = None, | ||
username: Username, | ||
email: Email, | ||
givenName: GivenName, | ||
familyName: FamilyName, | ||
password: Password, | ||
status: Status, | ||
lang: LanguageCode, | ||
systemAdmin: SystemAdmin | ||
): UserCreatePayloadADM = | ||
new UserCreatePayloadADM( | ||
id = id, | ||
username = Some(username), | ||
email = Some(email), | ||
givenName = Some(givenName), | ||
familyName = Some(familyName), | ||
password = Some(password), | ||
status = Some(status), | ||
lang = Some(lang), | ||
projects = None, | ||
projectsAdmin = None, | ||
groups = None, | ||
systemAdmin = Some(systemAdmin) | ||
) {} | ||
} |
Oops, something went wrong.