Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 7eb6204b authored by Jujube Orange's avatar Jujube Orange
Browse files

Merge remote-tracking branch 'origin/develop'

parents e8dd6077 b10b4841
No related branches found
No related tags found
No related merge requests found
Pipeline #610185 passed
......@@ -9,7 +9,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.7</version>
<version>2.7.3</version>
</parent>
<groupId>fr.gouv.stopc</groupId>
......@@ -20,12 +20,12 @@
<properties>
<flyway.version>7.15.0</flyway.version>
<java.version>11</java.version>
<kotlin.version>1.6.21</kotlin.version>
<kotlin.version>1.7.10</kotlin.version>
<commons-compress.version>1.21</commons-compress.version>
<commons-text.version>1.9</commons-text.version>
<hamcrest-date.version>2.0.8</hamcrest-date.version>
<spring-cloud.version>2021.0.2</spring-cloud.version>
<testcontainers.version>1.17.2</testcontainers.version>
<spring-cloud.version>2021.0.3</spring-cloud.version>
<testcontainers.version>1.17.3</testcontainers.version>
</properties>
<dependencyManagement>
......@@ -91,7 +91,7 @@
<dependency>
<groupId>com.nimbusds</groupId>
<artifactId>nimbus-jose-jwt</artifactId>
<version>9.22</version>
<version>9.24.3</version>
</dependency>
......@@ -140,7 +140,7 @@
<plugin>
<groupId>com.rudikershaw.gitbuildhook</groupId>
<artifactId>git-build-hook-maven-plugin</artifactId>
<version>3.2.0</version>
<version>3.3.0</version>
<configuration>
<gitConfig>
<core.hooksPath>.etc/git-hooks</core.hooksPath>
......@@ -199,7 +199,7 @@
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>5.4.0</version>
<version>6.0.0</version>
<executions>
<execution>
<goals>
......@@ -218,6 +218,7 @@
</modelPackage>
<configOptions>
<sourceFolder>src/main/kotlin</sourceFolder>
<documentationProvider>none</documentationProvider>
<dateLibrary>java8</dateLibrary>
<interfaceOnly>true</interfaceOnly>
<useTags>true</useTags>
......
package fr.gouv.stopc.submissioncode.controller
import com.fasterxml.jackson.databind.exc.MismatchedInputException
import fr.gouv.stopc.submissioncode.api.model.ErrorDetails
import fr.gouv.stopc.submissioncode.api.model.ErrorResponse
import fr.gouv.stopc.submissioncode.api.model.ErrorResponseErrors
import org.slf4j.LoggerFactory.getLogger
import org.springframework.http.HttpHeaders
import org.springframework.http.HttpStatus
......@@ -38,9 +38,9 @@ class RestExceptionHandler(private val servletRequest: HttpServletRequest) : Res
): ResponseEntity<Any> {
return badRequestAndLogErrors(
ex.fieldErrors.map {
ErrorResponseErrors(it.field, it.code, it.defaultMessage)
ErrorDetails(it.field, it.code ?: "", it.defaultMessage ?: "")
} + ex.globalErrors.map {
ErrorResponseErrors("", it.code, it.defaultMessage)
ErrorDetails("", it.code ?: "", it.defaultMessage ?: "")
}
)
}
......@@ -48,9 +48,9 @@ class RestExceptionHandler(private val servletRequest: HttpServletRequest) : Res
@ExceptionHandler
fun handle(ex: ConstraintViolationException): ResponseEntity<Any> {
val errors = ex.constraintViolations.map {
ErrorResponseErrors(
ErrorDetails(
field = it.propertyPath.toString(),
code = it.constraintDescriptor.annotation.annotationClass.simpleName,
code = it.constraintDescriptor.annotation.annotationClass.java.simpleName,
message = it.message
)
}
......@@ -65,25 +65,25 @@ class RestExceptionHandler(private val servletRequest: HttpServletRequest) : Res
): ResponseEntity<Any> {
val cause = ex.cause
val error = if (cause is MismatchedInputException) {
ErrorResponseErrors(
ErrorDetails(
field = cause.path
.map { if (it.fieldName != null) ".${it.fieldName}" else "[${it.index}]" }
.joinToString("")
.removePrefix("."),
code = "HttpMessageNotReadable",
message = ex.rootCause!!.message
message = ex.rootCause?.message ?: ""
)
} else {
ErrorResponseErrors(
ErrorDetails(
field = "",
code = ex::class.simpleName,
message = ex.message
code = ex::class.java.simpleName,
message = ex.message ?: ""
)
}
return badRequestAndLogErrors(listOf(error))
}
private fun badRequestAndLogErrors(errors: List<ErrorResponseErrors>): ResponseEntity<Any> {
private fun badRequestAndLogErrors(errors: List<ErrorDetails>): ResponseEntity<Any> {
val errorResponseBody = ErrorResponse(
status = HttpStatus.BAD_REQUEST.value(),
error = HttpStatus.BAD_REQUEST.reasonPhrase,
......
......@@ -42,6 +42,23 @@ components:
path: /api/v1/resource
timestamp: "2021-06-01T11:28:23.603Z"
schemas:
ErrorDetails:
type: object
description: details about the error
properties:
field:
type: string
description: the field name having an error
code:
type: string
description: an error code
message:
type: string
description: an error message
required:
- field
- code
- message
ErrorResponse:
type: object
properties:
......@@ -64,18 +81,7 @@ components:
errors:
type: array
items:
type: object
description: details about the error
properties:
field:
type: string
description: the field name having an error
code:
type: string
description: an error code
message:
type: string
description: an error message
$ref: "#/components/schemas/ErrorDetails"
minLength: 1
required:
- status
......
......@@ -388,7 +388,7 @@ class VerifyControllerTest {
.body("valid", equalTo(false))
assertThat(output.all)
.containsPattern("JWT could not be parsed: Invalid JWS header: Invalid JSON: Unexpected token [^ ]+ at position 5., aaaaaaa.aaaaaaa.aaaaaaa")
.contains("JWT could not be parsed: Invalid JWS header: Invalid JSON: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path \$, aaaaaaa.aaaaaaa.aaaaaaa")
}
@Test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment