diff --git a/src/main/kotlin/pt/up/fe/ni/website/backend/controller/AccountController.kt b/src/main/kotlin/pt/up/fe/ni/website/backend/controller/AccountController.kt index 34cbd1c9..d4e930fb 100644 --- a/src/main/kotlin/pt/up/fe/ni/website/backend/controller/AccountController.kt +++ b/src/main/kotlin/pt/up/fe/ni/website/backend/controller/AccountController.kt @@ -11,9 +11,9 @@ import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RequestParam import org.springframework.web.bind.annotation.RequestPart import org.springframework.web.bind.annotation.RestController -import pt.up.fe.ni.website.backend.dto.auth.PassRecoveryDto import org.springframework.web.multipart.MultipartFile import pt.up.fe.ni.website.backend.dto.auth.ChangePasswordDto +import pt.up.fe.ni.website.backend.dto.auth.PassRecoveryDto import pt.up.fe.ni.website.backend.dto.entity.account.CreateAccountDto import pt.up.fe.ni.website.backend.dto.entity.account.UpdateAccountDto import pt.up.fe.ni.website.backend.model.Account diff --git a/src/main/kotlin/pt/up/fe/ni/website/backend/service/AccountService.kt b/src/main/kotlin/pt/up/fe/ni/website/backend/service/AccountService.kt index fd8ea298..6b12f9f3 100644 --- a/src/main/kotlin/pt/up/fe/ni/website/backend/service/AccountService.kt +++ b/src/main/kotlin/pt/up/fe/ni/website/backend/service/AccountService.kt @@ -1,19 +1,19 @@ package pt.up.fe.ni.website.backend.service +import java.time.Instant import java.util.UUID import org.springframework.data.repository.findByIdOrNull import org.springframework.security.crypto.password.PasswordEncoder import org.springframework.security.oauth2.jwt.JwtDecoder import org.springframework.security.oauth2.server.resource.InvalidBearerTokenException import org.springframework.stereotype.Service -import pt.up.fe.ni.website.backend.dto.auth.PassRecoveryDto -import pt.up.fe.ni.website.backend.model.Account -import pt.up.fe.ni.website.backend.repository.AccountRepository -import java.time.Instant import org.springframework.web.multipart.MultipartFile import pt.up.fe.ni.website.backend.dto.auth.ChangePasswordDto +import pt.up.fe.ni.website.backend.dto.auth.PassRecoveryDto import pt.up.fe.ni.website.backend.dto.entity.account.CreateAccountDto import pt.up.fe.ni.website.backend.dto.entity.account.UpdateAccountDto +import pt.up.fe.ni.website.backend.model.Account +import pt.up.fe.ni.website.backend.repository.AccountRepository import pt.up.fe.ni.website.backend.service.upload.FileUploader import pt.up.fe.ni.website.backend.utils.extensions.filenameExtension diff --git a/src/test/kotlin/pt/up/fe/ni/website/backend/controller/AccountControllerTest.kt b/src/test/kotlin/pt/up/fe/ni/website/backend/controller/AccountControllerTest.kt index 067465b8..096dc259 100644 --- a/src/test/kotlin/pt/up/fe/ni/website/backend/controller/AccountControllerTest.kt +++ b/src/test/kotlin/pt/up/fe/ni/website/backend/controller/AccountControllerTest.kt @@ -915,7 +915,7 @@ class AccountControllerTest @Autowired constructor( private val passwordRecoveryPayload = PayloadSchema( "password-recover", mutableListOf( - DocumentedJSONField("password", "The new password.", JsonFieldType.STRING), + DocumentedJSONField("password", "The new password.", JsonFieldType.STRING) ) ) @@ -930,15 +930,16 @@ class AccountControllerTest @Autowired constructor( .andReturn().response.let { authResponse -> val recoveryLink = objectMapper.readTree(authResponse.contentAsString)["recovery_url"].asText() .removePrefix("localhost:8080") - mockMvc.perform(put(recoveryLink) - .contentType(MediaType.APPLICATION_JSON) - .content( - objectMapper.writeValueAsString( - mapOf( - "password" to newPassword + mockMvc.perform( + put(recoveryLink) + .contentType(MediaType.APPLICATION_JSON) + .content( + objectMapper.writeValueAsString( + mapOf( + "password" to newPassword + ) ) ) - ) ).andExpectAll( status().isOk() ).andDocumentCustomRequestSchemaEmptyResponse( @@ -954,15 +955,16 @@ class AccountControllerTest @Autowired constructor( @Test fun `should fail when token is invalid`() { - mockMvc.perform(put("/accounts/recoverPassword/invalid_token") - .contentType(MediaType.APPLICATION_JSON) - .content( - objectMapper.writeValueAsString( - mapOf( - "password" to newPassword + mockMvc.perform( + put("/accounts/recoverPassword/invalid_token") + .contentType(MediaType.APPLICATION_JSON) + .content( + objectMapper.writeValueAsString( + mapOf( + "password" to newPassword + ) ) ) - ) ).andExpectAll( status().isUnauthorized(), jsonPath("$.errors.length()").value(1),