MAJ terminée. Nous sommes passés en version 14.6.2 . Pour consulter les "releases notes" associées c'est ici :

https://about.gitlab.com/releases/2022/01/11/security-release-gitlab-14-6-2-released/
https://about.gitlab.com/releases/2022/01/04/gitlab-14-6-1-released/

Commit 3763722f authored by Framboise Orange's avatar Framboise Orange
Browse files

Merge remote-tracking branch 'origin/develop'

parents 0459a9af 25c5088b
Pipeline #286813 passed with stage
in 3 minutes and 50 seconds
......@@ -160,7 +160,7 @@
</goals>
<configuration>
<inputSpec>
${project.basedir}/src/main/resources/api-analytics-v1.yaml
${project.basedir}/src/main/resources/openapi-analytics-v1.yml
</inputSpec>
<generatorName>kotlin-spring</generatorName>
<apiPackage>fr.gouv.tac.analytics.api</apiPackage>
......
......@@ -17,9 +17,13 @@ class AnalyticsController(private val analyticsService: AnalyticsService) : Anal
analyticsService.createAnalytics(
AnalyticsCreation(
installationUuid = analyticsRequest!!.installationUuid,
infos = analyticsRequest.infos,
events = analyticsRequest.events.map { AnalyticsEvent(it.name, it.timestamp, it.desc) },
errors = analyticsRequest.errors.map { AnalyticsEvent(it.name, it.timestamp, it.desc) }
infos = analyticsRequest.infos.orEmpty(),
events = analyticsRequest.events
?.map { AnalyticsEvent(it.name, it.timestamp, it.desc) }
.orEmpty(),
errors = analyticsRequest.errors
?.map { AnalyticsEvent(it.name, it.timestamp, it.desc) }
.orEmpty()
)
)
return ResponseEntity.ok().build()
......
......@@ -3,7 +3,7 @@ openapi: 3.0.0
info:
title: "tac analytics"
description: "#TOUS-ANTI-COVID, analytics API"
version: 1.1.0
version: 1.2.0
termsOfService: https://gitlab.inria.fr/stopcovid19/analytics-server
contact:
email: stopcovid@inria.fr
......@@ -155,9 +155,6 @@ components:
The errors list of the analytics.
required:
- installationUuid
- infos
- events
- errors
Information:
type: object
......@@ -176,11 +173,9 @@ components:
timestamp:
type: string
format: date-time
nullable: false
description: The BasicInfo timestamp. Date-time notation as defined by RFC 3339, section 5.6, for example, 2017-07-21T17:32:28Z
desc:
type: string
nullable: false
description: the basic info description
required:
- name
......
......@@ -9,9 +9,11 @@ import fr.gouv.tac.analytics.test.KafkaRecordAssert.Companion.assertThat
import fr.gouv.tac.analytics.test.RestAssuredManager.Companion.givenAuthenticated
import fr.gouv.tac.analytics.test.TemporalMatchers.isStringDateBetweenNowAndTenSecondsAgo
import io.restassured.http.ContentType.JSON
import org.hamcrest.Matchers.anEmptyMap
import org.hamcrest.Matchers.contains
import org.hamcrest.Matchers.emptyString
import org.hamcrest.Matchers.equalTo
import org.hamcrest.Matchers.hasSize
import org.hamcrest.Matchers.nullValue
import org.hamcrest.Matchers.startsWith
import org.junit.jupiter.api.Test
......@@ -54,6 +56,26 @@ class AnalyticsControllerCreateTest {
.hasJsonValue("errors[1].desc", "error2 description")
}
@Test
fun should_accept_null_infos_events_and_error_list() {
val analyticsRequest = ExampleData.analyticsRequest()
.copy(infos = null, events = null, errors = null)
givenAuthenticated()
.contentType(JSON)
.body(analyticsRequest)
.post("/api/v1/analytics")
.then()
.statusCode(OK.value())
.body(emptyString())
assertThat(KafkaManager.getSingleRecord("dev.analytics.cmd.create"))
.hasNoHeader("__TypeId__")
.hasNoKey()
.hasJsonValue("creationDate", isStringDateBetweenNowAndTenSecondsAgo())
.hasJsonValue("infos", anEmptyMap<String, String>())
.hasJsonValue("events", hasSize<TimestampedEvent>(0))
.hasJsonValue("errors", hasSize<TimestampedEvent>(0))
}
@Test
fun bad_request_on_empty_installationUuid() {
val analyticsRequest = ExampleData.analyticsRequest().copy(installationUuid = "")
......@@ -252,6 +274,58 @@ class AnalyticsControllerCreateTest {
.body("path", equalTo("/api/v1/analytics"))
}
@Test
fun bad_request_on_null_event_timestamp() {
val timestamp = OffsetDateTime.parse("2020-12-17T10:59:17.123Z")
val analyticsJsonRequest = """
{
"installationUuid": "${UUID.randomUUID()}",
"infos": {
"os": "Android",
"type": 0,
"load": 1.03,
"root": false
},
"timestamp": "$timestamp",
"events": [
{
"name": "eventName1",
"timestamp": null,
"desc": "event1 description"
},
{
"name": "eventName2",
"timestamp": "$timestamp"
}
],
"errors": [
{
"name": "errorName1",
"timestamp": "$timestamp"
},
{
"name": "errorName2",
"timestamp": "$timestamp",
"desc": "error2 description"
}
]
}
"""
givenAuthenticated()
.contentType(JSON)
.body(analyticsJsonRequest)
.post("/api/v1/analytics")
.then()
.statusCode(BAD_REQUEST.value())
.body("status", equalTo(400))
.body("error", equalTo("Bad Request"))
.body("timestamp", isStringDateBetweenNowAndTenSecondsAgo())
.body("path", equalTo("/api/v1/analytics"))
.body("errors", nullValue())
}
@Test
fun bad_request_on_empty_error_name() {
val timestamp = OffsetDateTime.parse("2020-12-17T10:59:17.123Z")
......
......@@ -15,7 +15,8 @@ class KafkaRecordAssert private constructor(private val actualRecord: ConsumerRe
actualRecord,
KafkaRecordAssert::class.java
) {
fun <T> hasJsonValue(jsonPath: String, matcher: Matcher<T>?): KafkaRecordAssert {
fun <T> hasJsonValue(jsonPath: String, matcher: Matcher<T>): KafkaRecordAssert {
val jsonValue = actualRecord.value()?.toPrettyString()
val jsonPathValue: T = JsonPath.compile(jsonPath).read(jsonValue)
assertThat(jsonPathValue).satisfies(HamcrestCondition(matcher))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment