Commit 0dbadc7a 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 cf82e161
......@@ -1113,6 +1113,7 @@ class CryptoServiceGrpcServerTest {
(stub, req, observer) -> stub.deleteId(req, observer),
(t) -> fail(),
res);
assertTrue(!res.isError());
assertTrue(ByteUtils.isNotEmpty(response.getIdA().toByteArray()));
assertTrue(Arrays.equals(clientIdentifierBundle.get().getId(), response.getIdA().toByteArray()));
......@@ -1144,10 +1145,10 @@ class CryptoServiceGrpcServerTest {
(stub, req, observer) -> stub.deleteId(req, observer),
(t) -> fail(),
res);
assertTrue(!res.isError());
assertTrue(response.hasError());
assertTrue(response.getError().getCode() == 400);
}
@Test
......@@ -1427,7 +1428,7 @@ class CryptoServiceGrpcServerTest {
when(this.cryptographicStorageService.getServerKeys(this.currentEpochId,
this.serverConfigurationService.getServiceTimeStart(),
4))
.thenReturn(serverKeys);
.thenReturn(serverKeys);
// Given
GetIdFromStatusRequest request = GetIdFromStatusRequest
......
......@@ -23,7 +23,7 @@ import org.springframework.batch.item.data.builder.MongoItemWriterBuilder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.core.task.SyncTaskExecutor;
import org.springframework.core.task.TaskExecutor;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
......@@ -228,7 +228,7 @@ public class ContactsProcessingConfiguration {
public TaskExecutor taskExecutor() {
return new SimpleAsyncTaskExecutor();
return new SyncTaskExecutor();
}
public Step contactWorkerStep(StepBuilderFactory stepBuilderFactory, MongoItemReader<Contact> mongoItemReader) {
......@@ -268,7 +268,7 @@ public class ContactsProcessingConfiguration {
@Value("#{stepExecutionContext[start]}") final int start,
@Value("#{stepExecutionContext[end]}") final int end) {
log.info("{} currently reading registrations from itemId collections from id={} - to id= {} ", name, start, end);
log.info("{} currently reading Contact(s) from itemId collections from id={} - to id= {} ", name, start, end);
List<String> itemIdentifiers = (List<String>)itemIdMappingService.getItemIdMappingsBetweenIds(start, end);
......@@ -288,7 +288,7 @@ public class ContactsProcessingConfiguration {
@Value("#{stepExecutionContext[name]}") final String name,
@Value("#{stepExecutionContext[start]}") final int start,
@Value("#{stepExecutionContext[end]}") final int end) {
log.info("{} currently reading registrations from itemId collections from id={} - to id= {} ", name, start, end);
log.info("{} currently reading Registration(s) from itemId collections from id={} - to id= {} ", name, start, end);
List<byte[]> itemIdentifiers = (List<byte[]>)itemIdMappingService.getItemIdMappingsBetweenIds(start, end);
......@@ -308,7 +308,7 @@ public class ContactsProcessingConfiguration {
@Value("#{stepExecutionContext[name]}") final String name,
@Value("#{stepExecutionContext[start]}") final long start,
@Value("#{stepExecutionContext[end]}") final long end) {
log.info("{} currently reading registrations from itemId collections from id={} - to id= {} ", name, start, end);
log.info("{} currently reading Registration(s) from itemId collections from id={} - to id= {} ", name, start, end);
List<byte[]> itemIdentifiers = (List<byte[]>)itemIdMappingService.getItemIdMappingsBetweenIds(start, end);
......
......@@ -15,6 +15,7 @@ import fr.gouv.stopc.robertserver.database.model.Registration;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@AllArgsConstructor
public class PurgeOldEpochExpositionsProcessor implements ItemProcessor<Registration, Registration> {
......
......@@ -60,8 +60,10 @@ 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;
@Slf4j
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
@ExtendWith(SpringExtension.class)
......@@ -452,7 +454,6 @@ public class ContactProcessorTest {
System.arraycopy(ebid, 0, helloMessage, encryptedCountryCode.length, ebid.length);
System.arraycopy(time, 0, helloMessage, encryptedCountryCode.length + ebid.length, time.length);
doReturn(Optional.of(
GetInfoFromHelloMessageResponse.newBuilder()
.setIdA(ByteString.copyFrom(this.registration.get().getPermanentIdentifier()))
......
......@@ -18,6 +18,7 @@ import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import test.fr.gouv.stopc.robertserver.batch.utils.ProcessorTestUtils;
import fr.gouv.stopc.robert.server.batch.RobertServerBatchApplication;
import fr.gouv.stopc.robert.server.batch.configuration.ContactsProcessingConfiguration;
......@@ -30,7 +31,6 @@ import fr.gouv.stopc.robertserver.database.model.EpochExposition;
import fr.gouv.stopc.robertserver.database.model.Registration;
import fr.gouv.stopc.robertserver.database.service.IRegistrationService;
import test.fr.gouv.stopc.robertserver.batch.utils.ProcessorTestUtils;
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
@ExtendWith(SpringExtension.class)
......
package test.fr.gouv.stopc.robertserver.batch.processor;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
......@@ -33,7 +32,6 @@ import fr.gouv.stopc.robert.server.common.utils.TimeUtils;
import fr.gouv.stopc.robertserver.database.model.EpochExposition;
import fr.gouv.stopc.robertserver.database.model.Registration;
import fr.gouv.stopc.robertserver.database.service.IRegistrationService;
import test.fr.gouv.stopc.robertserver.batch.utils.ProcessorTestUtils;
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
......
......@@ -4,8 +4,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import fr.gouv.stopc.robert.server.common.utils.TimeUtils;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import java.time.LocalDate;
......@@ -14,6 +12,9 @@ import java.time.ZoneId;
import java.time.ZonedDateTime;
import fr.gouv.stopc.robert.server.common.utils.TimeUtils;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class TimeUtilsTest {
......
......@@ -12,6 +12,7 @@ import org.springframework.util.CollectionUtils;
import fr.gouv.stopc.robertserver.database.model.Contact;
import fr.gouv.stopc.robertserver.database.repository.ContactRepository;
import fr.gouv.stopc.robertserver.database.service.ContactService;
import org.springframework.util.CollectionUtils;
@Service
......
......@@ -42,14 +42,14 @@ public class RegistrationService implements IRegistrationService {
}
@Override
public void saveAll(final List<Registration> registrations) {
public void saveAll(final List<Registration> registrations) {
if (!CollectionUtils.isEmpty(registrations)) {
this.registrationRepository.saveAll(registrations);
}
}
if (!CollectionUtils.isEmpty(registrations)) {
this.registrationRepository.saveAll(registrations);
}
}
@Override
@Override
public void delete(Registration registration) {
Optional.ofNullable(registration).ifPresent(this.registrationRepository::delete);
}
......@@ -64,53 +64,53 @@ public class RegistrationService implements IRegistrationService {
return this.registrationRepository.findAll();
}
/**
* {@inheritDoc}
*/
@Override
public Long countNbUsersAtRiskAgain() {
return this.registrationRepository.countNbUsersAtRiskAgain();
}
/**
* {@inheritDoc}
*/
@Override
public Long countNbUsersAtRiskAndNotNotified() {
return this.registrationRepository.countNbUsersAtRiskAndNotNotified();
}
/**
* {@inheritDoc}
*/
@Override
public Long countNbUsersNotified() {
return this.registrationRepository.countNbUsersNotified();
}
/**
* {@inheritDoc}
*/
@Override
public Long countNbExposedUsersButNotAtRisk() {
return this.registrationRepository.countNbExposedUsersButNotAtRisk();
}
/**
* {@inheritDoc}
*/
@Override
public Long countNbNotifiedUsersScoredAgain() {
return this.registrationRepository.countNbNotifiedUsersScoredAgain();
}
@Override
public Long count() {
return this.registrationRepository.count();
}
@Override
public Long countNbUsersWithOldEpochExpositions(int minEpochId) {
return this.registrationRepository.countNbUsersWithOldEpochExpositions(minEpochId);
}
/**
* {@inheritDoc}
*/
@Override
public Long countNbUsersAtRiskAgain() {
return this.registrationRepository.countNbUsersAtRiskAgain();
}
/**
* {@inheritDoc}
*/
@Override
public Long countNbUsersAtRiskAndNotNotified() {
return this.registrationRepository.countNbUsersAtRiskAndNotNotified();
}
/**
* {@inheritDoc}
*/
@Override
public Long countNbUsersNotified() {
return this.registrationRepository.countNbUsersNotified();
}
/**
* {@inheritDoc}
*/
@Override
public Long countNbExposedUsersButNotAtRisk() {
return this.registrationRepository.countNbExposedUsersButNotAtRisk();
}
/**
* {@inheritDoc}
*/
@Override
public Long countNbNotifiedUsersScoredAgain() {
return this.registrationRepository.countNbNotifiedUsersScoredAgain();
}
@Override
public Long count() {
return this.registrationRepository.count();
}
@Override
public Long countNbUsersWithOldEpochExpositions(int minEpochId) {
return this.registrationRepository.countNbUsersWithOldEpochExpositions(minEpochId);
}
}
......@@ -234,4 +234,5 @@ public class AuthRequestValidationServiceImpl implements AuthRequestValidationSe
}
return Optional.empty();
}
}
......@@ -174,6 +174,7 @@ public class DeleteHistoryControllerWsRestTest {
}
/** Test the access for API V1, should not be used since API V2 */
@Test
public void testAccessV1() {
deleteHistoryWithExposedEpochsSucceeds(UriComponentsBuilder.fromUriString(this.pathPrefix_V1).path(UriConstants.DELETE_HISTORY).build().encode().toUri());
......
......@@ -169,7 +169,7 @@ public class RegisterControllerWsRestTest {
RegisterInternalVo.builder().captcha("mycaptcha").build()
, this.headers), String.class).getStatusCode());
}
@Test
public void testCaptchaFailure() {
this.body = RegisterVo.builder()
......
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