Skip to content

Commit

Permalink
Added webp file type
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunoRosendo committed Aug 2, 2023
1 parent 0486c19 commit 2024c42
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ object UploadConstants {
val contentTypes = listOf(
"image/png",
"image/jpg",
"image/jpeg"
"image/jpeg",
"image/webp"
)

val fileExtensions = listOf(
"png",
"jpg",
"jpeg"
"jpeg",
"webp"
)
}
}
4 changes: 2 additions & 2 deletions src/main/resources/validation_errors.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ size.min = size must be greater or equal to {min}
null_or_not_blank.error = must be null or not blank
date_interval.error = endDate must be after startDate
school_year.error = must be formatted as <xx-yy> where yy=xx+1
no_duplicate_roles.error= must not contain duplicate roles
files.invalid_image = invalid image type (png, jpg or jpeg)
no_duplicate_roles.error=must not contain duplicate roles
files.invalid_image=invalid image type (png, jpg, jpeg or webp)
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ class AccountControllerTest @Autowired constructor(
status().isBadRequest,
content().contentType(MediaType.APPLICATION_JSON),
jsonPath("$.errors.length()").value(1),
jsonPath("$.errors[0].message").value("invalid image type (png, jpg or jpeg)"),
jsonPath("$.errors[0].message").value("invalid image type (png, jpg, jpeg or webp)"),
jsonPath("$.errors[0].param").value("createAccount.photo")
)
.andDocumentErrorResponse(documentation, hasRequestPayload = true)
Expand All @@ -300,7 +300,7 @@ class AccountControllerTest @Autowired constructor(
status().isBadRequest,
content().contentType(MediaType.APPLICATION_JSON),
jsonPath("$.errors.length()").value(1),
jsonPath("$.errors[0].message").value("invalid image type (png, jpg or jpeg)"),
jsonPath("$.errors[0].message").value("invalid image type (png, jpg, jpeg or webp)"),
jsonPath("$.errors[0].param").value("createAccount.photo")
)
}
Expand Down Expand Up @@ -837,7 +837,7 @@ class AccountControllerTest @Autowired constructor(
status().isBadRequest,
content().contentType(MediaType.APPLICATION_JSON),
jsonPath("$.errors.length()").value(1),
jsonPath("$.errors[0].message").value("invalid image type (png, jpg or jpeg)"),
jsonPath("$.errors[0].message").value("invalid image type (png, jpg, jpeg or webp)"),
jsonPath("$.errors[0].param").value("updateAccountById.photo")
)
.andDocumentErrorResponse(documentation, hasRequestPayload = true)
Expand All @@ -854,7 +854,7 @@ class AccountControllerTest @Autowired constructor(
status().isBadRequest,
content().contentType(MediaType.APPLICATION_JSON),
jsonPath("$.errors.length()").value(1),
jsonPath("$.errors[0].message").value("invalid image type (png, jpg or jpeg)"),
jsonPath("$.errors[0].message").value("invalid image type (png, jpg, jpeg or webp)"),
jsonPath("$.errors[0].param").value("updateAccountById.photo")
)
.andDocumentErrorResponse(documentation, hasRequestPayload = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ internal class EventControllerTest @Autowired constructor(
status().isBadRequest,
content().contentType(MediaType.APPLICATION_JSON),
jsonPath("$.errors.length()").value(1),
jsonPath("$.errors[0].message").value("invalid image type (png, jpg or jpeg)"),
jsonPath("$.errors[0].message").value("invalid image type (png, jpg, jpeg or webp)"),
jsonPath("$.errors[0].param").value("createEvent.image")
)
.andDocumentErrorResponse(documentation, hasRequestPayload = true)
Expand All @@ -437,7 +437,7 @@ internal class EventControllerTest @Autowired constructor(
status().isBadRequest,
content().contentType(MediaType.APPLICATION_JSON),
jsonPath("$.errors.length()").value(1),
jsonPath("$.errors[0].message").value("invalid image type (png, jpg or jpeg)"),
jsonPath("$.errors[0].message").value("invalid image type (png, jpg, jpeg or webp)"),
jsonPath("$.errors[0].param").value("createEvent.image")
)
.andDocumentErrorResponse(documentation, hasRequestPayload = true)
Expand Down Expand Up @@ -1000,7 +1000,7 @@ internal class EventControllerTest @Autowired constructor(
status().isBadRequest,
content().contentType(MediaType.APPLICATION_JSON),
jsonPath("$.errors.length()").value(1),
jsonPath("$.errors[0].message").value("invalid image type (png, jpg or jpeg)"),
jsonPath("$.errors[0].message").value("invalid image type (png, jpg, jpeg or webp)"),
jsonPath("$.errors[0].param").value("updateEventById.image")
)
.andDocumentErrorResponse(documentation, hasRequestPayload = true)
Expand All @@ -1017,7 +1017,7 @@ internal class EventControllerTest @Autowired constructor(
status().isBadRequest,
content().contentType(MediaType.APPLICATION_JSON),
jsonPath("$.errors.length()").value(1),
jsonPath("$.errors[0].message").value("invalid image type (png, jpg or jpeg)"),
jsonPath("$.errors[0].message").value("invalid image type (png, jpg, jpeg or webp)"),
jsonPath("$.errors[0].param").value("updateEventById.image")
)
.andDocumentErrorResponse(documentation, hasRequestPayload = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ internal class ProjectControllerTest @Autowired constructor(
status().isBadRequest,
content().contentType(MediaType.APPLICATION_JSON),
jsonPath("$.errors.length()").value(1),
jsonPath("$.errors[0].message").value("invalid image type (png, jpg or jpeg)"),
jsonPath("$.errors[0].message").value("invalid image type (png, jpg, jpeg or webp)"),
jsonPath("$.errors[0].param").value("createProject.image")
)
.andDocumentErrorResponse(documentation, hasRequestPayload = true)
Expand All @@ -385,7 +385,7 @@ internal class ProjectControllerTest @Autowired constructor(
status().isBadRequest,
content().contentType(MediaType.APPLICATION_JSON),
jsonPath("$.errors.length()").value(1),
jsonPath("$.errors[0].message").value("invalid image type (png, jpg or jpeg)"),
jsonPath("$.errors[0].message").value("invalid image type (png, jpg, jpeg or webp)"),
jsonPath("$.errors[0].param").value("createProject.image")
)
.andDocumentErrorResponse(documentation, hasRequestPayload = true)
Expand Down Expand Up @@ -808,7 +808,7 @@ internal class ProjectControllerTest @Autowired constructor(
status().isBadRequest,
content().contentType(MediaType.APPLICATION_JSON),
jsonPath("$.errors.length()").value(1),
jsonPath("$.errors[0].message").value("invalid image type (png, jpg or jpeg)"),
jsonPath("$.errors[0].message").value("invalid image type (png, jpg, jpeg or webp)"),
jsonPath("$.errors[0].param").value("updateProjectById.image")
)
.andDocumentErrorResponse(documentation, hasRequestPayload = true)
Expand All @@ -825,7 +825,7 @@ internal class ProjectControllerTest @Autowired constructor(
status().isBadRequest,
content().contentType(MediaType.APPLICATION_JSON),
jsonPath("$.errors.length()").value(1),
jsonPath("$.errors[0].message").value("invalid image type (png, jpg or jpeg)"),
jsonPath("$.errors[0].message").value("invalid image type (png, jpg, jpeg or webp)"),
jsonPath("$.errors[0].param").value("updateProjectById.image")
)
.andDocumentErrorResponse(documentation, hasRequestPayload = true)
Expand Down

0 comments on commit 2024c42

Please sign in to comment.