Commit 080c4f27 authored by calocedre TAC's avatar calocedre TAC
Browse files

Merge branch 'fix/clea-lib/java/qrCodeValidityStarTime-static' into 'master'

Fix: Starting a new Period with a Static QR Code

See merge request !31
parents 68f986f1 d1699aa2
Pipeline #238197 passed with stages
in 8 minutes and 17 seconds
......@@ -64,7 +64,9 @@ public class Location {
* @throws CleaEncryptionException
*/
public String newDeepLink(Instant periodStartTime, Instant qrCodeValidityStartTime) throws CleaCryptoException {
this.setPeriodStartTime(periodStartTime);
if(!this.locationSpecificPart.getPeriodStartTime().equals(periodStartTime)){
this.setPeriodStartTime(periodStartTime);
}
this.setQrCodeValidityStartTime(periodStartTime, qrCodeValidityStartTime);
return COUNTRY_SPECIFIC_PREFIX + this.getLocationSpecificPartEncryptedBase64();
}
......@@ -95,6 +97,7 @@ public class Location {
this.locationSpecificPart.setPeriodStartTime(periodStartTime);
this.locationSpecificPart.setLocationTemporarySecretKey(locationTemporarySecretKey);
this.locationSpecificPart.setLocationTemporaryPublicId(currentLocationTemporaryPublicId);
this.locationSpecificPart.setQrCodeValidityStartTime(null);
if (Objects.nonNull(this.contact)) {
this.contact.setPeriodStartTime(periodStartTime);
}
......
......@@ -12,6 +12,7 @@ import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import fr.inria.clea.lsp.exception.CleaCryptoException;
import fr.inria.clea.lsp.exception.CleaEncryptionException;
// @ExtendWith(MockitoJUnitRunner.class)
public class LocationTest {
......@@ -81,6 +82,24 @@ public class LocationTest {
assertThat(lsp.getQrCodeValidityStartTime()).isNotEqualTo(newQrCodeValidityStartTime);
}
@Test
public void testWhenSettingQrCodeValidityStartTimeWithNoQrCodeRenewalIntervalThenQrValidityStartTimeUpdatedWhenNewPeriod() throws CleaEncryptionException {
int qrCodeRenewalIntervalExponentCompact = 0x1F;
int periodDuration = 3;
lsp = newLocationSpecificPart(qrCodeRenewalIntervalExponentCompact, periodDuration);
location = newLocation(locationContact, lsp);
location.setQrCodeValidityStartTime(periodStartTime, periodStartTime);
assertThat(lsp.getQrCodeValidityStartTime()).isEqualTo(periodStartTime);
periodStartTime = periodStartTime.plus(3, ChronoUnit.HOURS);
location.setPeriodStartTime(periodStartTime);
location.setQrCodeValidityStartTime(periodStartTime, periodStartTime);
assertThat(lsp.getQrCodeValidityStartTime()).isEqualTo(periodStartTime);
}
@Test
public void testNewDeepLink() throws CleaCryptoException {
int qrCodeRenewalIntervalExponentCompact = 2;
......
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