Add user service tests

This commit is contained in:
2020-06-14 19:18:33 +02:00
parent fc7fa6b5f7
commit 44859b1ecd
8 changed files with 142 additions and 133 deletions
+4 -9
View File
@@ -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)