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

fix(escape-special-characters): escape special characters in user routes (DSP-1557) (DEV-63) #1902

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
1a9040f
feat(valueobjects): add user value objects
subotic Aug 2, 2021
90c8944
feat(valueobjects): add user value objects
subotic Aug 2, 2021
f3c6ee0
example either usage
subotic Aug 3, 2021
57f8f05
create UserEntity to represent request payload for user creation
Aug 26, 2021
0f06563
add trait and inherit from it in value objects
Aug 26, 2021
c758972
add unit tests for the creation of value objects
Aug 30, 2021
15a9c40
add unittests for value objects
Aug 30, 2021
a782547
refactor createNewUserADM
Aug 30, 2021
37969cc
reformat UsersRouteADM
Aug 30, 2021
ba1d1ce
add docstrings to unit tests
Aug 30, 2021
78d86b6
add e2e spec for handling special characters
Aug 30, 2021
a41fb31
use value objects in update basic user information
Sep 1, 2021
d405939
refactor update password with value objects
Sep 6, 2021
8188881
add e2e tests for updating the user password
Sep 6, 2021
812e18a
refactor update user status
Sep 6, 2021
7ba30a3
refactor systemAdmin
Sep 6, 2021
d7564d6
refactor project membership and add test
Sep 7, 2021
909f868
remove log.debug statements from e2e tests
Sep 7, 2021
418915c
remove unused code from e2e tests
Sep 7, 2021
2f84e18
cleanup code
Sep 7, 2021
627fd8d
cleanup code
Sep 7, 2021
47c5ea1
add tests
Sep 7, 2021
c5b983c
add test
Sep 7, 2021
c1ce081
add new client-test-data
Sep 7, 2021
26af0d2
refactor change basic user information request
Sep 8, 2021
fcfc742
update unit tests
Sep 8, 2021
935837c
fix failed unit tests
Sep 8, 2021
b784a6b
fix expected-client-test-data.txt
Sep 8, 2021
67e0c90
add test to get user with special characters
Sep 13, 2021
eb4e6f9
delete password information in debug log
Sep 13, 2021
e9d35b6
Merge branch 'main' into wip/DSP-1557-escape-special-characters-in-us…
Sep 13, 2021
12c486a
Merge branch 'main' into wip/DSP-1557-escape-special-characters-in-us…
Sep 14, 2021
4cdefb7
resolve merge conflicts
Sep 14, 2021
74f1d04
Revert "Merge branch 'main' into wip/DSP-1557-escape-special-characte…
Sep 14, 2021
cbc737e
Revert "resolve merge conflicts"
Sep 14, 2021
a83ec64
resolve merge conflicts
Sep 15, 2021
ceffc01
integrate changes from main
Sep 15, 2021
6b5aafb
Merge branch 'main' into wip/DSP-1557-escape-special-characters-in-us…
Sep 15, 2021
56a9f73
rename userEntity
Sep 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -57,5 +57,6 @@ dump.rdb
dependencies.txt
/client-test-data.zip
/db_staging_dump.trig
cleandeps.sh
/.vscode
/cleandeps.sh
/.metals
12 changes: 12 additions & 0 deletions webapi/scripts/expected-client-test-data.txt
Expand Up @@ -137,7 +137,11 @@ test-data/admin/users/
test-data/admin/users/add-user-to-group-response.json
test-data/admin/users/add-user-to-project-admin-group-response.json
test-data/admin/users/add-user-to-project-response.json
test-data/admin/users/create-user-request-duplicate-email.json
test-data/admin/users/create-user-request-duplicate-username.json
test-data/admin/users/create-user-request.json
test-data/admin/users/create-user-response-duplicate-email.json
test-data/admin/users/create-user-response-duplicate-username.json
test-data/admin/users/create-user-response.json
test-data/admin/users/create-user-with-custom-Iri-request.json
test-data/admin/users/create-user-with-custom-Iri-response.json
Expand All @@ -153,17 +157,25 @@ test-data/admin/users/get-user-response.json
test-data/admin/users/get-users-for-ProjectAdmin-response.json
test-data/admin/users/get-users-for-SystemAdmin-response.json
test-data/admin/users/get-users-response.json
test-data/admin/users/incomplete-update-user-password-request-2.json
test-data/admin/users/incomplete-update-user-password-request.json
test-data/admin/users/incomplete-update-user-password-response-2.json
test-data/admin/users/incomplete-update-user-password-response.json
test-data/admin/users/remove-user-from-group-response.json
test-data/admin/users/remove-user-from-project-admin-group-response.json
test-data/admin/users/remove-user-from-project-response.json
test-data/admin/users/update-user-password-request.json
test-data/admin/users/update-user-password-response.json
test-data/admin/users/update-user-request-without-iri.json
test-data/admin/users/update-user-request.json
test-data/admin/users/update-user-response-without-iri-1.json
test-data/admin/users/update-user-response-without-iri-2.json
test-data/admin/users/update-user-response.json
test-data/admin/users/update-user-status-request.json
test-data/admin/users/update-user-status-response.json
test-data/admin/users/update-user-system-admin-membership-request.json
test-data/admin/users/update-user-system-admin-membership-response.json
test-data/admin/users/user-already-member-of-project-response.json
test-data/system/
test-data/system/health/
test-data/system/health/maintenance-mode-response.json
Expand Down
Expand Up @@ -89,7 +89,7 @@ case class ChangeGroupApiRequestADM(name: Option[String] = None,
if (parametersCount == 0) throw BadRequestException("No data sent in API request.")

/**
* check that only allowed information for the 2 cases is send and not more.
* check that only allowed information for the 2 cases is sent and not more.
*/
// change status case
if (status.isDefined) {
Expand Down
@@ -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)
) {}
}