Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jamcunha committed May 3, 2023
1 parent 3179ffd commit 6bfc6c1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
)

Expand All @@ -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(
Expand All @@ -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),
Expand Down

0 comments on commit 6bfc6c1

Please sign in to comment.