Add user service tests
This commit is contained in:
@@ -2,7 +2,6 @@ package be.vandewalleh.routing
|
||||
|
||||
import be.vandewalleh.extensions.respondStatus
|
||||
import be.vandewalleh.extensions.userId
|
||||
import be.vandewalleh.services.UserDto
|
||||
import be.vandewalleh.services.UserService
|
||||
import io.ktor.application.*
|
||||
import io.ktor.auth.*
|
||||
@@ -26,9 +25,7 @@ fun Routing.user(kodein: Kodein) {
|
||||
|
||||
val hashedPassword = BCrypt.hashpw(user.password, BCrypt.gensalt())
|
||||
|
||||
userService.createUser(
|
||||
UserDto(user.username, user.email, hashedPassword)
|
||||
)
|
||||
userService.createUser(user.username, user.email, hashedPassword)
|
||||
|
||||
call.respondStatus(HttpStatusCode.Created)
|
||||
}
|
||||
@@ -42,10 +39,7 @@ fun Routing.user(kodein: Kodein) {
|
||||
|
||||
val hashedPassword = BCrypt.hashpw(user.password, BCrypt.gensalt())
|
||||
|
||||
userService.updateUser(
|
||||
call.userId(),
|
||||
UserDto(user.username, user.email, hashedPassword)
|
||||
)
|
||||
userService.updateUser(call.userId(), user.username, user.email, hashedPassword)
|
||||
|
||||
call.respondStatus(HttpStatusCode.OK)
|
||||
}
|
||||
@@ -57,5 +51,6 @@ fun Routing.user(kodein: Kodein) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private data class UserDto(val username: String, val email: String, val password: String)
|
||||
|
||||
Reference in New Issue
Block a user