forked from eclipse-apoapsis/ort-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The User data model includes also first name, last name and an e-mail address, but the request object for creating new users was missing those, in effect preventing to set the corr. attributes when creating new users. Signed-off-by: Jyrki Keisala <[email protected]>
- Loading branch information
Showing
5 changed files
with
65 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,13 +80,20 @@ val getUsers: OpenApiRoute.() -> Unit = { | |
|
||
val postUsers: OpenApiRoute.() -> Unit = { | ||
operationId = "postUsers" | ||
summary = "Create a user, possibly with a password. This is enabled for server administrators only." | ||
summary = "Create a user, possibly with a password." | ||
tags = listOf("Admin") | ||
|
||
request { | ||
jsonBody<CreateUser> { | ||
example("Create User") { | ||
value = CreateUser(username = "newUser", password = "password", temporary = true) | ||
value = CreateUser( | ||
username = "newUser", | ||
firstName = "First", | ||
lastName = "Last", | ||
email = "[email protected]", | ||
password = "password", | ||
temporary = true | ||
) | ||
description = "temporary=true means the password is for one-time use only and needs to be changed " + | ||
"on first login. If password is not set, temporary is ignored." | ||
} | ||
|
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 |
---|---|---|
|
@@ -44,6 +44,9 @@ class AdminRouteIntegrationTest : AbstractIntegrationTest({ | |
tags(Integration) | ||
|
||
val testUsername = "test123" | ||
val testFirstName = "FirstName" | ||
val testLastName = "LastName" | ||
val testEmail = "[email protected]" | ||
val testPassword = "password123" | ||
val testTemporary = true | ||
|
||
|
@@ -89,7 +92,14 @@ class AdminRouteIntegrationTest : AbstractIntegrationTest({ | |
"POST /admin/users" should { | ||
"create a new user" { | ||
integrationTestApplication { | ||
val user = CreateUser(testUsername, testPassword, testTemporary) | ||
val user = CreateUser( | ||
username = testUsername, | ||
firstName = testFirstName, | ||
lastName = testLastName, | ||
email = testEmail, | ||
password = testPassword, | ||
temporary = testTemporary | ||
) | ||
|
||
val response = superuserClient.post("/api/v1/admin/users") { | ||
setBody(user) | ||
|
@@ -101,7 +111,14 @@ class AdminRouteIntegrationTest : AbstractIntegrationTest({ | |
|
||
"respond with an internal error if the user already exists" { | ||
integrationTestApplication { | ||
val user = CreateUser(testUsername, testPassword, testTemporary) | ||
val user = CreateUser( | ||
username = testUsername, | ||
firstName = testFirstName, | ||
lastName = testLastName, | ||
email = testEmail, | ||
password = testPassword, | ||
temporary = testTemporary | ||
) | ||
|
||
superuserClient.post("/api/v1/admin/users") { | ||
setBody(user) | ||
|
@@ -117,7 +134,16 @@ class AdminRouteIntegrationTest : AbstractIntegrationTest({ | |
"require superuser role" { | ||
requestShouldRequireRole(Superuser.ROLE_NAME, HttpStatusCode.Created) { | ||
post("/api/v1/admin/users") { | ||
setBody(CreateUser(testUsername, testPassword, testTemporary)) | ||
setBody( | ||
CreateUser( | ||
username = testUsername, | ||
firstName = testFirstName, | ||
lastName = testLastName, | ||
email = testEmail, | ||
password = testPassword, | ||
temporary = testTemporary | ||
) | ||
) | ||
} | ||
} | ||
} | ||
|
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