Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
TousAntiCovid sources
Cléa Server
Commits
615c6a7d
Commit
615c6a7d
authored
Apr 20, 2021
by
calocedre TAC
Browse files
Merge remote-tracking branch 'origin/develop' into feat/stat-consumer
parents
9b2a2c50
1f616d1a
Changes
7
Hide whitespace changes
Inline
Side-by-side
clea-batch/src/main/resources/logback-spring.xml
0 → 100644
View file @
615c6a7d
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property
name=
"LOG_DIR"
value=
"${CLEA_BATCH_LOG_FILE_PATH:-/logs}"
/>
<property
name=
"LOG_FILENAME"
value=
"${CLEA_BATCH_LOG_FILE_NAME:-clea-batch}"
/>
<property
name=
"ERROR_LOG_FILENAME"
value=
"${CLEA_BATCH_ERROR_LOG_FILE_NAME:-clea-batch}.error"
/>
<appender
name=
"RollingFile"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<file>
${LOG_DIR}/${LOG_FILENAME}.log
</file>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<Pattern>
%d %p %C{1.} [%t][%file:%line] %m%n
</Pattern>
</encoder>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"
>
<!-- rollover daily and when the file reaches 10 MegaBytes -->
<fileNamePattern>
${LOG_DIR}/${LOG_FILENAME}.%d{yyyy-MM-dd}.%i.log.gz
</fileNamePattern>
<maxFileSize>
10MB
</maxFileSize>
</rollingPolicy>
</appender>
<appender
name=
"RollingErrorFile"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<file>
${LOG_DIR}/${ERROR_LOG_FILENAME}.log
</file>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<Pattern>
%d %p %C{1.} [%t][%file:%line] %m%n
</Pattern>
</encoder>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"
>
<!-- rollover daily and when the file reaches 10 MegaBytes -->
<fileNamePattern>
${LOG_DIR}/${ERROR_LOG_FILENAME}.%d{yyyy-MM-dd}.%i.log.gz
</fileNamePattern>
<maxFileSize>
10MB
</maxFileSize>
</rollingPolicy>
</appender>
<springProfile
name=
"dev"
>
<include
resource=
"org/springframework/boot/logging/logback/base.xml"
/>
<logger
name=
"org.springframework"
level=
"OFF"
/>
</springProfile>
<springProfile
name=
"!dev"
>
<!-- LOG everything at INFO level -->
<root
level=
"info"
>
<appender-ref
ref=
"RollingFile"
/>
</root>
<!-- at TRACE level -->
<logger
name=
"trace"
level=
"trace"
additivity=
"false"
>
<appender-ref
ref=
"RollingFile"
/>
</logger>
<!-- at WARN level -->
<logger
name=
"warn"
level=
"warn"
additivity=
"false"
>
<appender-ref
ref=
"RollingFile"
/>
</logger>
<!-- at TRACE level -->
<logger
name=
"error"
level=
"error"
additivity=
"false"
>
<appender-ref
ref=
"RollingErrorFile"
/>
</logger>
</springProfile>
</configuration>
clea-venue-consumer/src/main/java/fr/gouv/clea/consumer/service/impl/DecodedVisitService.java
View file @
615c6a7d
...
...
@@ -80,7 +80,11 @@ public class DecodedVisitService implements IDecodedVisitService {
if
(
qrCodeRenewalInterval
==
0
)
{
return
false
;
}
return
Duration
.
between
(
visit
.
getQrCodeScanTime
(),
visit
.
getQrCodeValidityStartTime
()).
abs
().
toSeconds
()
boolean
isDrifting
=
Duration
.
between
(
visit
.
getQrCodeScanTime
(),
visit
.
getQrCodeValidityStartTime
()).
abs
().
toSeconds
()
>
(
qrCodeRenewalInterval
+
driftBetweenDeviceAndOfficialTimeInSecs
+
cleaClockDriftInSecs
);
if
(!
isDrifting
&&
visit
.
getQrCodeScanTime
().
isBefore
(
visit
.
getQrCodeValidityStartTime
()))
{
visit
.
setQrCodeScanTime
(
visit
.
getQrCodeValidityStartTime
());
}
return
isDrifting
;
}
}
clea-venue-consumer/src/main/resources/logback-spring.xml
0 → 100644
View file @
615c6a7d
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property
name=
"LOG_DIR"
value=
"${CLEA_VENUE_CONSUMER_LOG_FILE_PATH:-/logs}"
/>
<property
name=
"LOG_FILENAME"
value=
"${CLEA_VENUE_CONSUMER_LOG_FILE_NAME:-clea-venue-consumer}"
/>
<property
name=
"ERROR_LOG_FILENAME"
value=
"${CLEA_VENUE_CONSUMER_ERROR_LOG_FILE_NAME:-clea-venue-consumer}.error"
/>
<appender
name=
"RollingFile"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<file>
${LOG_DIR}/${LOG_FILENAME}.log
</file>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<Pattern>
%d %p %C{1.} [%t][%file:%line] %m%n
</Pattern>
</encoder>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"
>
<!-- rollover daily and when the file reaches 10 MegaBytes -->
<fileNamePattern>
${LOG_DIR}/${LOG_FILENAME}.%d{yyyy-MM-dd}.%i.log.gz
</fileNamePattern>
<maxFileSize>
10MB
</maxFileSize>
</rollingPolicy>
</appender>
<appender
name=
"RollingErrorFile"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<file>
${LOG_DIR}/${ERROR_LOG_FILENAME}.log
</file>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<Pattern>
%d %p %C{1.} [%t][%file:%line] %m%n
</Pattern>
</encoder>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"
>
<!-- rollover daily and when the file reaches 10 MegaBytes -->
<fileNamePattern>
${LOG_DIR}/${ERROR_LOG_FILENAME}.%d{yyyy-MM-dd}.%i.log.gz
</fileNamePattern>
<maxFileSize>
10MB
</maxFileSize>
</rollingPolicy>
</appender>
<springProfile
name=
"dev"
>
<include
resource=
"org/springframework/boot/logging/logback/base.xml"
/>
<logger
name=
"org.springframework"
level=
"OFF"
/>
</springProfile>
<springProfile
name=
"!dev"
>
<!-- LOG everything at INFO level -->
<root
level=
"info"
>
<appender-ref
ref=
"RollingFile"
/>
</root>
<!-- at TRACE level -->
<logger
name=
"trace"
level=
"trace"
additivity=
"false"
>
<appender-ref
ref=
"RollingFile"
/>
</logger>
<!-- at WARN level -->
<logger
name=
"warn"
level=
"warn"
additivity=
"false"
>
<appender-ref
ref=
"RollingFile"
/>
</logger>
<!-- at TRACE level -->
<logger
name=
"error"
level=
"error"
additivity=
"false"
>
<appender-ref
ref=
"RollingErrorFile"
/>
</logger>
</springProfile>
</configuration>
clea-venue-consumer/src/test/java/fr/gouv/clea/consumer/service/impl/DecodedVisitServiceTest.java
View file @
615c6a7d
package
fr.gouv.clea.consumer.service.impl
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
java.time.Instant
;
import
java.time.temporal.ChronoUnit
;
import
java.util.Optional
;
import
java.util.UUID
;
import
org.apache.commons.lang3.RandomUtils
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.DisplayName
;
import
org.junit.jupiter.api.DisplayNameGeneration
;
import
org.junit.jupiter.api.DisplayNameGenerator
;
import
org.junit.jupiter.api.Test
;
import
fr.gouv.clea.consumer.model.DecodedVisit
;
import
fr.gouv.clea.consumer.model.Visit
;
import
fr.gouv.clea.consumer.service.IDecodedVisitService
;
...
...
@@ -9,21 +26,8 @@ import fr.inria.clea.lsp.LocationSpecificPart;
import
fr.inria.clea.lsp.LocationSpecificPartDecoder
;
import
fr.inria.clea.lsp.exception.CleaEncodingException
;
import
fr.inria.clea.lsp.exception.CleaEncryptionException
;
import
org.apache.commons.lang3.RandomUtils
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.DisplayName
;
import
org.junit.jupiter.api.Test
;
import
java.time.Instant
;
import
java.time.temporal.ChronoUnit
;
import
java.util.Optional
;
import
java.util.UUID
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
mockito
.
Mockito
.
any
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
when
;
@DisplayNameGeneration
(
DisplayNameGenerator
.
ReplaceUnderscores
.
class
)
class
DecodedVisitServiceTest
{
private
final
LocationSpecificPartDecoder
decoder
=
mock
(
LocationSpecificPartDecoder
.
class
);
...
...
@@ -46,7 +50,6 @@ class DecodedVisitServiceTest {
@DisplayName
(
"check with max CRIexp for LSP"
)
void
maxCRIexp
()
throws
CleaEncryptionException
,
CleaEncodingException
{
int
CRIexp
=
0x1F
;
// qrCodeRenewalInterval = 0
when
(
decoder
.
decrypt
(
any
(
EncryptedLocationSpecificPart
.
class
)))
.
thenReturn
(
LocationSpecificPart
.
builder
()
...
...
@@ -55,7 +58,6 @@ class DecodedVisitServiceTest {
.
locationTemporarySecretKey
(
locationTemporarySecretKey
)
.
build
()
);
when
(
cleaEciesEncoder
.
computeLocationTemporaryPublicId
(
locationTemporarySecretKey
))
.
thenReturn
(
uuid
);
...
...
@@ -71,11 +73,9 @@ class DecodedVisitServiceTest {
}
@Test
@DisplayName
(
"check with drifting LSP"
)
void
testDrifting
()
throws
CleaEncryptionException
,
CleaEncodingException
{
void
should_visit_be_rejected_when_scantime_over_allowed_drift
()
throws
CleaEncryptionException
,
CleaEncodingException
{
int
CRIexp
=
10
;
// qrCodeRenewalInterval=2^10(=1024). 1024+300+300=1624
Instant
qrCodeValidityStartTime
=
now
.
truncatedTo
(
ChronoUnit
.
SECONDS
).
plus
(
2000
,
ChronoUnit
.
SECONDS
);
when
(
decoder
.
decrypt
(
any
(
EncryptedLocationSpecificPart
.
class
)))
.
thenReturn
(
LocationSpecificPart
.
builder
()
...
...
@@ -85,7 +85,6 @@ class DecodedVisitServiceTest {
.
locationTemporarySecretKey
(
locationTemporarySecretKey
)
.
build
()
);
when
(
cleaEciesEncoder
.
computeLocationTemporaryPublicId
(
locationTemporarySecretKey
))
.
thenReturn
(
uuid
);
...
...
@@ -98,14 +97,12 @@ class DecodedVisitServiceTest {
);
assertThat
(
optional
).
isEmpty
();
}
}
@Test
@DisplayName
(
"check with non drifting LSP"
)
void
testNonDrifting
()
throws
CleaEncryptionException
,
CleaEncodingException
{
void
should_visit_be_accepted_and_scantime_updated_when_scantime_inside_allowed_drift_and_scantime_before_qr_validity_start
()
throws
CleaEncryptionException
,
CleaEncodingException
{
int
CRIexp
=
10
;
// qrCodeRenewalInterval=2^10(=1024). 1024+300+300=1624
Instant
qrCodeValidityStartTime
=
Instant
.
now
().
truncatedTo
(
ChronoUnit
.
SECONDS
).
plus
(
1600
,
ChronoUnit
.
SECONDS
);
Instant
qrCodeValidityStartTime
=
now
.
truncatedTo
(
ChronoUnit
.
SECONDS
).
plus
(
1600
,
ChronoUnit
.
SECONDS
);
when
(
decoder
.
decrypt
(
any
(
EncryptedLocationSpecificPart
.
class
)))
.
thenReturn
(
LocationSpecificPart
.
builder
()
...
...
@@ -115,7 +112,6 @@ class DecodedVisitServiceTest {
.
locationTemporarySecretKey
(
locationTemporarySecretKey
)
.
build
()
);
when
(
cleaEciesEncoder
.
computeLocationTemporaryPublicId
(
locationTemporarySecretKey
))
.
thenReturn
(
uuid
);
...
...
@@ -128,8 +124,9 @@ class DecodedVisitServiceTest {
);
assertThat
(
optional
).
isPresent
();
assertThat
(
optional
.
get
().
getQrCodeScanTime
()).
isEqualTo
(
optional
.
get
().
getQrCodeValidityStartTime
());
}
@Test
@DisplayName
(
"check with non valid temporaryLocationPublicId"
)
void
nonValidTemporaryLocationPublicId
()
throws
CleaEncryptionException
,
CleaEncodingException
{
...
...
clea-ws-rest/src/main/resources/logback-spring.xml
0 → 100644
View file @
615c6a7d
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property
name=
"LOG_DIR"
value=
"${CLEA_WS_REST_LOG_FILE_PATH:-/logs}"
/>
<property
name=
"LOG_FILENAME"
value=
"${CLEA_WS_REST_LOG_FILE_NAME:-clea-ws-rest}"
/>
<property
name=
"ERROR_LOG_FILENAME"
value=
"${CLEA_WS_REST_ERROR_LOG_FILE_NAME:-clea-ws-rest}.error"
/>
<appender
name=
"RollingFile"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<file>
${LOG_DIR}/${LOG_FILENAME}.log
</file>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<Pattern>
%d %p %C{1.} [%t][%file:%line] %m%n
</Pattern>
</encoder>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"
>
<!-- rollover daily and when the file reaches 10 MegaBytes -->
<fileNamePattern>
${LOG_DIR}/${LOG_FILENAME}.%d{yyyy-MM-dd}.%i.log.gz
</fileNamePattern>
<maxFileSize>
10MB
</maxFileSize>
</rollingPolicy>
</appender>
<appender
name=
"RollingErrorFile"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<file>
${LOG_DIR}/${ERROR_LOG_FILENAME}.log
</file>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<Pattern>
%d %p %C{1.} [%t][%file:%line] %m%n
</Pattern>
</encoder>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"
>
<!-- rollover daily and when the file reaches 10 MegaBytes -->
<fileNamePattern>
${LOG_DIR}/${ERROR_LOG_FILENAME}.%d{yyyy-MM-dd}.%i.log.gz
</fileNamePattern>
<maxFileSize>
10MB
</maxFileSize>
</rollingPolicy>
</appender>
<springProfile
name=
"dev"
>
<include
resource=
"org/springframework/boot/logging/logback/base.xml"
/>
<logger
name=
"org.springframework"
level=
"OFF"
/>
</springProfile>
<springProfile
name=
"!dev"
>
<!-- LOG everything at INFO level -->
<root
level=
"info"
>
<appender-ref
ref=
"RollingFile"
/>
</root>
<!-- at TRACE level -->
<logger
name=
"trace"
level=
"trace"
additivity=
"false"
>
<appender-ref
ref=
"RollingFile"
/>
</logger>
<!-- at WARN level -->
<logger
name=
"warn"
level=
"warn"
additivity=
"false"
>
<appender-ref
ref=
"RollingFile"
/>
</logger>
<!-- at TRACE level -->
<logger
name=
"error"
level=
"error"
additivity=
"false"
>
<appender-ref
ref=
"RollingErrorFile"
/>
</logger>
</springProfile>
</configuration>
docker-compose.yml
View file @
615c6a7d
...
...
@@ -5,6 +5,8 @@ services:
build
:
./clea-ws-rest/
environment
:
SPRING_PROFILES_ACTIVE
:
dev,docker
CLEA_WS_REST_LOG_FILE_PATH
:
/logs
CLEA_WS_REST_LOG_FILE_NAME
:
-clea-ws-rest
depends_on
:
-
kafka
ports
:
...
...
@@ -18,6 +20,8 @@ services:
build
:
./clea-venue-consumer/
environment
:
SPRING_PROFILES_ACTIVE
:
dev,docker
CLEA_VENUE_CONSUMER_LOG_FILE_PATH
:
-/logs
CLEA_VENUE_CONSUMER_LOG_FILE_NAME
:
-clea-venue-consumer
depends_on
:
-
postgres
-
kafka
...
...
@@ -32,6 +36,8 @@ services:
build
:
./clea-batch/
environment
:
SPRING_PROFILES_ACTIVE
:
docker
CLEA_BATCH_LOG_FILE_PATH
:
-/logs
CLEA_BATCHLOG_FILE_NAME
:
-clea-batch
ports
:
-
"
15000:15000"
depends_on
:
...
...
docker-compose/docker-compose.yml
View file @
615c6a7d
...
...
@@ -6,6 +6,8 @@ services:
build
:
../clea-ws-rest/
environment
:
SPRING_PROFILES_ACTIVE
:
dev,docker
CLEA_WS_REST_LOG_FILE_PATH
:
-/logs
CLEA_WS_REST_LOG_FILE_NAME
:
-clea-ws-rest
depends_on
:
-
kafka
ports
:
...
...
@@ -20,6 +22,8 @@ services:
environment
:
SPRING_PROFILES_ACTIVE
:
dev,docker
SPRING_JPA_HIBERNATE_DDL_AUTO
:
none
CLEA_VENUE_CONSUMER_LOG_FILE_PATH
:
-/logs
CLEA_VENUE_CONSUMER_LOG_FILE_NAME
:
-clea-venue-consumer
depends_on
:
-
postgres
-
kafka
...
...
@@ -35,7 +39,9 @@ services:
environment
:
SPRING_PROFILES_ACTIVE
:
docker
BUCKET
:
clea-batch
ports
:
CLEA_BATCH_LOG_FILE_PATH
:
-/logs
CLEA_BATCHLOG_FILE_NAME
:
-clea-batch
ports
:
-
"
15000:15000"
depends_on
:
-
postgres
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment