Commit 6d2458cf authored by Deniro StopCovid's avatar Deniro StopCovid

feat: Use the property var robert.server.request-time-delta-tolerance mapped...

feat: Use the property var robert.server.request-time-delta-tolerance mapped on the env var ROBERT_SERVER_REQUEST_TIME_DELTA_TOLERANCE
parent d336aa4e
......@@ -19,7 +19,7 @@
<groupId>fr.gouv.stopc</groupId>
<artifactId>robert-server</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
<name>robert-server</name>
<packaging>pom</packaging>
<description>Projet principal</description>
......
......@@ -13,7 +13,7 @@
<parent>
<groupId>fr.gouv.stopc</groupId>
<artifactId>robert-server</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>
<artifactId>robert-crypto-grpc-server-messaging</artifactId>
......
......@@ -13,7 +13,7 @@
<parent>
<groupId>fr.gouv.stopc</groupId>
<artifactId>robert-server</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>
......
......@@ -13,7 +13,7 @@
<parent>
<groupId>fr.gouv.stopc</groupId>
<artifactId>robert-server</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>
<artifactId>robert-crypto-grpc-server</artifactId>
......
......@@ -13,7 +13,7 @@
<parent>
<groupId>fr.gouv.stopc</groupId>
<artifactId>robert-server</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>
<artifactId>robert-server-batch</artifactId>
......
package test.fr.gouv.stopc.robertserver.batch.processor;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
......@@ -38,6 +38,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.ByteString;
import fr.gouv.stopc.robert.crypto.grpc.server.client.service.ICryptoServerGrpcClient;
import fr.gouv.stopc.robert.crypto.grpc.server.messaging.GetInfoFromHelloMessageResponse;
import fr.gouv.stopc.robert.server.batch.RobertServerBatchApplication;
......@@ -60,7 +61,6 @@ import fr.gouv.stopc.robertserver.database.model.Registration;
import fr.gouv.stopc.robertserver.database.service.ContactService;
import fr.gouv.stopc.robertserver.database.service.IRegistrationService;
import lombok.extern.slf4j.Slf4j;
import test.fr.gouv.stopc.robertserver.batch.utils.ProcessorTestUtils;
......
......@@ -13,7 +13,7 @@
<parent>
<groupId>fr.gouv.stopc</groupId>
<artifactId>robert-server</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>
<artifactId>robert-server-common</artifactId>
......
......@@ -11,7 +11,6 @@ import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import fr.gouv.stopc.robert.server.common.utils.TimeUtils;
import lombok.extern.slf4j.Slf4j;
......@@ -39,7 +38,7 @@ public class TimeUtilsTest {
final ZonedDateTime zdt = ldt.atZone(ZoneId.of("UTC"));
return TimeUtils.convertUnixMillistoNtpSeconds(zdt.toInstant().toEpochMilli());
}
@Test
void testGetDateFromEpochTimezone() {
for (int i = 0; i < 96 * 2; i++) {
......
......@@ -13,7 +13,7 @@
<parent>
<groupId>fr.gouv.stopc</groupId>
<artifactId>robert-server</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>
<artifactId>robert-server-crypto</artifactId>
......
......@@ -13,7 +13,7 @@
<parent>
<groupId>fr.gouv.stopc</groupId>
<artifactId>robert-server</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>
......
......@@ -13,7 +13,7 @@
<parent>
<groupId>fr.gouv.stopc</groupId>
<artifactId>robert-server</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>
......
......@@ -13,7 +13,7 @@
<parent>
<groupId>fr.gouv.stopc</groupId>
<artifactId>robert-server</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
</parent>
......
......@@ -6,7 +6,7 @@ import org.springframework.web.client.RestTemplate;
@Configuration
public class Config {
@Bean
public RestTemplate restTemplate() {
......
package fr.gouv.stopc.robertserver.ws.controller;
import javax.validation.Valid;
import javax.ws.rs.Consumes;
import javax.ws.rs.Produces;
......
......@@ -532,4 +532,5 @@ public class DeleteHistoryControllerWsRestTest {
verify(this.registrationService, times(saveRegistrationCalls)).saveRegistration(ArgumentMatchers.any());
}
}
}
......@@ -96,6 +96,7 @@ public class CaptchaServiceImplTest {
when(this.propertyLoader.getCaptchaChallengeTimestampTolerance()).thenReturn(3600);
// When
boolean isVerified = this.captchaServiceImpl.verifyCaptcha(this.registerVo);
......
......@@ -6,7 +6,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
......@@ -96,7 +95,7 @@ public class RestApiServiceImplTest {
// Then
assertFalse(response.isPresent());
verify(this.restTemplate, never()).getForEntity(any(URI.class), any(Class.class));
verify(this.restTemplate, never()).getForEntity(any(URI.class), any());
}
@Test
......@@ -107,7 +106,7 @@ public class RestApiServiceImplTest {
// Then
assertFalse(response.isPresent());
verify(this.restTemplate, never()).getForEntity(any(URI.class), any(Class.class));
verify(this.restTemplate, never()).getForEntity(any(URI.class), any());
}
@Test
......@@ -118,7 +117,7 @@ public class RestApiServiceImplTest {
// Then
assertFalse(response.isPresent());
verify(this.restTemplate, never()).getForEntity(any(URI.class), any(Class.class));
verify(this.restTemplate, never()).getForEntity(any(URI.class), any());
}
@Test
......@@ -129,14 +128,14 @@ public class RestApiServiceImplTest {
// Then
assertFalse(response.isPresent());
verify(this.restTemplate, never()).getForEntity(any(URI.class), any(Class.class));
verify(this.restTemplate, never()).getForEntity(any(URI.class), any());
}
@Test
public void testVerifyReportTokenAnExceptionIsThrownFails() {
// Given
when(this.restTemplate.getForEntity(any(URI.class), any(Class.class))).thenThrow(
when(this.restTemplate.getForEntity(any(URI.class), any())).thenThrow(
new HttpClientErrorException(HttpStatus.BAD_REQUEST));
// When
......@@ -144,7 +143,7 @@ public class RestApiServiceImplTest {
// Then
assertFalse(response.isPresent());
verify(this.restTemplate).getForEntity(any(URI.class), any(Class.class));
verify(this.restTemplate).getForEntity(any(URI.class), any());
}
@Test
......@@ -153,7 +152,7 @@ public class RestApiServiceImplTest {
// Given
VerifyResponseDto verified = VerifyResponseDto.builder().valid(true).build();
when(this.restTemplate.getForEntity(any(URI.class), any(Class.class))).thenReturn(ResponseEntity.ok(verified));
when(this.restTemplate.getForEntity(any(URI.class), any())).thenReturn(ResponseEntity.ok(verified));
// When
Optional<VerifyResponseDto> response = this.restApiServiceImpl.verifyReportToken("token", "type");
......@@ -161,7 +160,7 @@ public class RestApiServiceImplTest {
// Then
assertTrue(response.isPresent());
assertEquals(verified, response.get());
verify(this.restTemplate).getForEntity(any(URI.class), any(Class.class));
verify(this.restTemplate).getForEntity(any(URI.class), any());
}
@Test
......@@ -174,7 +173,7 @@ public class RestApiServiceImplTest {
this.restApiServiceImpl.registerPushNotif(pushInfo);
// Then
verify(this.restTemplate, never()).postForEntity(any(URI.class), any(PushInfoVo.class), any(Class.class));
verify(this.restTemplate, never()).postForEntity(any(URI.class), any(PushInfoVo.class), any());
}
@Test
......@@ -183,14 +182,14 @@ public class RestApiServiceImplTest {
// Given
PushInfoVo pushInfo = PushInfoVo.builder().build();
when(this.restTemplate.postForEntity(any(URI.class), any(PushInfoVo.class), any(Class.class)))
when(this.restTemplate.postForEntity(any(URI.class), any(PushInfoVo.class), any()))
.thenThrow(new HttpClientErrorException(HttpStatus.BAD_REQUEST));
// When
this.restApiServiceImpl.registerPushNotif(pushInfo);
// Then
verify(this.restTemplate).postForEntity(any(URI.class), any(PushInfoVo.class), any(Class.class));
verify(this.restTemplate).postForEntity(any(URI.class), any(PushInfoVo.class), any());
}
@Test
......@@ -200,14 +199,14 @@ public class RestApiServiceImplTest {
// Given
PushInfoVo pushInfo = PushInfoVo.builder().build();
when(this.restTemplate.postForEntity(any(URI.class), any(PushInfoVo.class), any(Class.class)))
when(this.restTemplate.postForEntity(any(URI.class), any(PushInfoVo.class), any()))
.thenReturn(ResponseEntity.status(HttpStatus.CREATED).build());
// When
this.restApiServiceImpl.registerPushNotif(pushInfo);
// Then
verify(this.restTemplate).postForEntity(any(URI.class), any(PushInfoVo.class), any(Class.class));
verify(this.restTemplate).postForEntity(any(URI.class), any(PushInfoVo.class), any());
} catch (Exception e) {
fail(SHOULD_NOT_FAIL);
......@@ -224,7 +223,7 @@ public class RestApiServiceImplTest {
this.restApiServiceImpl.unregisterPushNotif(pushToken);
// Then
verify(this.restTemplate, never()).getForEntity(any(URI.class), any(Class.class));
verify(this.restTemplate, never()).getForEntity(any(URI.class), any());
}
@Test
......@@ -237,7 +236,7 @@ public class RestApiServiceImplTest {
this.restApiServiceImpl.unregisterPushNotif(pushToken);
// Then
verify(this.restTemplate, never()).getForEntity(any(URI.class), any(Class.class));
verify(this.restTemplate, never()).getForEntity(any(URI.class), any());
}
@Test
......
package test.fr.gouv.stopc.robertserver.ws.vo.mapper;
import fr.gouv.stopc.robert.server.common.utils.TimeUtils;
import fr.gouv.stopc.robertserver.database.model.Contact;
import fr.gouv.stopc.robertserver.ws.vo.HelloMessageDetailVo;
import fr.gouv.stopc.robertserver.ws.vo.ContactVo;
import fr.gouv.stopc.robertserver.ws.vo.mapper.ContactMapper;
import lombok.extern.slf4j.Slf4j;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import org.bson.internal.Base64;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
......@@ -13,12 +17,13 @@ import org.mockito.InjectMocks;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.util.CollectionUtils;
import java.util.*;
import static org.junit.jupiter.api.Assertions.*;
import fr.gouv.stopc.robert.server.common.utils.TimeUtils;
import fr.gouv.stopc.robertserver.database.model.Contact;
import fr.gouv.stopc.robertserver.ws.vo.ContactVo;
import fr.gouv.stopc.robertserver.ws.vo.HelloMessageDetailVo;
import fr.gouv.stopc.robertserver.ws.vo.mapper.ContactMapper;
@ExtendWith(SpringExtension.class)
@Slf4j
public class ContactMapperTest {
@InjectMocks
private ContactMapper contactMapper;
......
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