Skip to content

Commit

Permalink
Update dependency org.sonatype.gradle.plugins.scan to v2.8.2 {patch} (#…
Browse files Browse the repository at this point in the history
…985)

* Update dependency org.sonatype.gradle.plugins.scan to v2.8.2 {patch}

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Fixes flaky tests

{patch}

Signed-off-by: Esta Nagy <nagyesta@gmail.com>

---------

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Esta Nagy <nagyesta@gmail.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Esta Nagy <nagyesta@gmail.com>
  • Loading branch information
renovate[bot] and nagyesta committed May 10, 2024
1 parent e255c4a commit 3b2fdf8
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 13 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ openApiUi = "2.5.0"

abortMissionPlugin = "5.0.34"
dockerPlugin = "0.36.0"
indexScanPlugin = "2.8.1"
indexScanPlugin = "2.8.2"
lombokPlugin = "8.6"
springBootPlugin = "3.2.5"
gitVersionerPlugin = "1.6.7"
Expand Down
39 changes: 39 additions & 0 deletions gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
<sha256 value="64e01794db4659829862a44574e066bf6940678fb1657e26668bf6414596244d" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="ch.qos.logback" name="logback-classic" version="1.3.14">
<artifact name="logback-classic-1.3.14.jar">
<sha256 value="f9b07a6dba4df3899381df7e597df450134e1879b1f3a757456b3cd1c8d94e2f" origin="Generated by Gradle"/>
</artifact>
<artifact name="logback-classic-1.3.14.pom">
<sha256 value="232ae1c31f05e90ae4e4bba1846492318de1519d60d2b873b43a18f6c261a3a2" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="ch.qos.logback" name="logback-classic" version="1.4.14">
<artifact name="logback-classic-1.4.14.jar">
<sha256 value="8e832f7263ca606ae36dabb2d8b24c2f43d82cf634e81dad9d1640fa6ee3c596" origin="Generated by Gradle"/>
Expand Down Expand Up @@ -90,6 +98,14 @@
<sha256 value="53074a2590e0d64da5bd5b09cfe4a9c1cfcbf987e503940e8184ee39fe855d14" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="ch.qos.logback" name="logback-core" version="1.3.14">
<artifact name="logback-core-1.3.14.jar">
<sha256 value="9f53159af18a9d438bc398c970db3bb7e17ddb07b04bbb3b01dfe3454dd18862" origin="Generated by Gradle"/>
</artifact>
<artifact name="logback-core-1.3.14.pom">
<sha256 value="f5f0e306475d0b9b6a055e130b1a0c4fb9d222034c93f0d1dd35461e3bc2e1da" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="ch.qos.logback" name="logback-core" version="1.4.14">
<artifact name="logback-core-1.4.14.jar">
<sha256 value="f8c2f05f42530b1852739507c1792f0080167850ed8f396444c6913d6617a293" origin="Generated by Gradle"/>
Expand Down Expand Up @@ -159,6 +175,11 @@
<sha256 value="c3c0f80dfb31aa922f8c60fe22c24b04eee41aa9a17466cdd85d81474196d1ef" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="ch.qos.logback" name="logback-parent" version="1.3.14">
<artifact name="logback-parent-1.3.14.pom">
<sha256 value="796dcc4cbfd42aeb7f72432445f5364619678928242b9f3e4749d4c4e0dd9dc4" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="ch.qos.logback" name="logback-parent" version="1.4.14">
<artifact name="logback-parent-1.4.14.pom">
<sha256 value="e5b75d3def04275764504a17a7c1aa1e3ee370a5b1a548884bbe157ebdde5efd" origin="Generated by Gradle"/>
Expand Down Expand Up @@ -1923,6 +1944,14 @@
<sha256 value="171a1af82b6759eb5740b3b8809aca80113deaf1153036f2f4445901dfd3f91d" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="commons-io" name="commons-io" version="2.16.1">
<artifact name="commons-io-2.16.1.jar">
<sha256 value="f41f7baacd716896447ace9758621f62c1c6b0a91d89acee488da26fc477c84f" origin="Generated by Gradle"/>
</artifact>
<artifact name="commons-io-2.16.1.pom">
<sha256 value="5777d292251c7895c04a4c57015683ec3b353a12486c9b3e7178e9b0b3c38fff" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="commons-logging" name="commons-logging" version="1.2">
<artifact name="commons-logging-1.2.jar">
<sha256 value="daddea1ea0be0f56978ab3006b8ac92834afeefbd9b7e4e6316fca57df0fa636" origin="Generated by Gradle"/>
Expand Down Expand Up @@ -5749,6 +5778,11 @@
<sha256 value="ab4b2a4d89bac557e9a670044479cded49188779411e60e9dce3e76737b904bd" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.sonatype.gradle.plugins" name="scan-gradle-plugin" version="2.8.2">
<artifact name="scan-gradle-plugin-2.8.2.jar">
<sha256 value="92560c1abb4bcc5729f1fa671e04fbd4709c7feb88cd63605d15115d0b31feef" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.sonatype.gradle.plugins.scan" name="org.sonatype.gradle.plugins.scan.gradle.plugin" version="2.6.2">
<artifact name="org.sonatype.gradle.plugins.scan.gradle.plugin-2.6.2.pom">
<sha256 value="900fccdb23c9527a6e29186c093d1e9ce9bafb63de37e01fb35ff1b5af1cadc1" origin="Generated by Gradle"/>
Expand All @@ -5769,6 +5803,11 @@
<sha256 value="8755dfb5806bdaec8a97e126937ca47916e7234b85f4a8efeaa794cea1430c2f" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.sonatype.gradle.plugins.scan" name="org.sonatype.gradle.plugins.scan.gradle.plugin" version="2.8.2">
<artifact name="org.sonatype.gradle.plugins.scan.gradle.plugin-2.8.2.pom">
<sha256 value="7bed4ff05d79b55952a99e05b05c11c0c1a0c04bc3e66ae3a03be00da7dcf9b2" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.sonatype.oss" name="oss-parent" version="5">
<artifact name="oss-parent-5.pom">
<sha256 value="1678d4120a585d8a630131aeec4c524d928398583b7eab616ee7d5a87f520d3d" origin="Generated by Gradle"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.time.Instant;
import java.time.Month;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.util.Deque;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

import static com.github.nagyesta.lowkeyvault.TestConstantsCertificates.CERT_NAME_1;
import static com.github.nagyesta.lowkeyvault.TestConstantsUri.HTTPS_LOCALHOST;
Expand All @@ -30,9 +31,11 @@

class VaultFakeImplIntegrationTest {

private static final int INT_800 = 800;
private static final int INITIAL_OFFSET_IN_DAYS = 800;
private static final int EXTRA_OFFSET_IN_DAYS = 15;
private static final int INT_MORE_THAN_TWO_YEARS_IN_DAYS = getMoreThanTwoYearsAvoidingLeapYear();
private static final int SECONDS_IN_1_DAY = 24 * 3600;
private static final int SECONDS_IN_800_DAYS = INT_800 * SECONDS_IN_1_DAY;
private static final int SECONDS_IN_MORE_THAN_TWO_YEARS = INT_MORE_THAN_TWO_YEARS_IN_DAYS * SECONDS_IN_1_DAY;
public static final int EXPECTED_VERSIONS_AFTER_RENEWAL = 3;

@Test
Expand All @@ -58,19 +61,19 @@ void testTimeShiftShouldCreateNewVersionsWhenAutoRotateIsTriggeredWithActiveCert
));

//when
underTest.timeShift(SECONDS_IN_800_DAYS, true);
underTest.timeShift(SECONDS_IN_MORE_THAN_TWO_YEARS, true);

//then
final Deque<String> versions = underTest.certificateVaultFake().getEntities().getVersions(originalCertId);
final List<ReadOnlyKeyVaultCertificateEntity> entities = versions.stream()
.map(v -> new VersionedCertificateEntityId(originalCertId.vault(), originalCertId.id(), v))
.map(certificateVaultFake.getEntities()::getReadOnlyEntity)
.collect(Collectors.toList());
.toList();
Assertions.assertEquals(EXPECTED_VERSIONS_AFTER_RENEWAL, entities.size());
final ReadOnlyKeyVaultCertificateEntity recreatedOriginal = entities.get(0);
final ReadOnlyKeyVaultCertificateEntity firstRenewal = entities.get(1);
final ReadOnlyKeyVaultCertificateEntity secondRenewal = entities.get(2);
assertTimestampsAreAdjustedAsExpected(approxNow, recreatedOriginal, INT_800);
assertTimestampsAreAdjustedAsExpected(approxNow, recreatedOriginal, INT_MORE_THAN_TWO_YEARS_IN_DAYS);
final OffsetDateTime firstRenewalDay = recreatedOriginal.getExpiry().map(v -> v.minusDays(triggerThresholdDays)).orElseThrow();
assertTimestampsAreAdjustedAsExpected(approxNow, firstRenewal, DAYS.between(firstRenewalDay, approxNow));
final OffsetDateTime secondRenewalDay = firstRenewal.getExpiry().map(v -> v.minusDays(triggerThresholdDays)).orElseThrow();
Expand Down Expand Up @@ -106,14 +109,14 @@ void testTimeShiftShouldCreateNewVersionsWhenAutoRotateIsTriggeredWithDifferentC
issuancePolicy.setContentType(CertContentType.PEM);

//when
underTest.timeShift(SECONDS_IN_800_DAYS, true);
underTest.timeShift(SECONDS_IN_MORE_THAN_TWO_YEARS, true);

//then
final Deque<String> versions = underTest.certificateVaultFake().getEntities().getVersions(originalCertId);
final List<ReadOnlyKeyVaultCertificateEntity> entities = versions.stream()
.map(v -> new VersionedCertificateEntityId(originalCertId.vault(), originalCertId.id(), v))
.map(certificateVaultFake.getEntities()::getReadOnlyEntity)
.collect(Collectors.toList());
.toList();
Assertions.assertEquals(EXPECTED_VERSIONS_AFTER_RENEWAL, entities.size());
assertRenewalUsedPem(underTest, entities.get(1));
assertRenewalUsedPem(underTest, entities.get(2));
Expand Down Expand Up @@ -143,19 +146,19 @@ void testTimeShiftShouldCreateNewVersionsUsingSameKeyWhenAutoRotateIsTriggeredWi
));

//when
underTest.timeShift(SECONDS_IN_800_DAYS, true);
underTest.timeShift(SECONDS_IN_MORE_THAN_TWO_YEARS, true);

//then
final Deque<String> versions = underTest.certificateVaultFake().getEntities().getVersions(originalCertId);
final List<ReadOnlyKeyVaultCertificateEntity> entities = versions.stream()
.map(v -> new VersionedCertificateEntityId(originalCertId.vault(), originalCertId.id(), v))
.map(certificateVaultFake.getEntities()::getReadOnlyEntity)
.collect(Collectors.toList());
.toList();
Assertions.assertEquals(EXPECTED_VERSIONS_AFTER_RENEWAL, entities.size());
final ReadOnlyKeyVaultCertificateEntity recreatedOriginal = entities.get(0);
final ReadOnlyKeyVaultCertificateEntity firstRenewal = entities.get(1);
final ReadOnlyKeyVaultCertificateEntity secondRenewal = entities.get(2);
assertTimestampsAreAdjustedAsExpected(approxNow, recreatedOriginal, INT_800);
assertTimestampsAreAdjustedAsExpected(approxNow, recreatedOriginal, INT_MORE_THAN_TWO_YEARS_IN_DAYS);
final OffsetDateTime firstRenewalDay = recreatedOriginal.getExpiry().map(v -> v.minusDays(triggerThresholdDays)).orElseThrow();
assertTimestampsAreAdjustedAsExpected(approxNow, firstRenewal, DAYS.between(firstRenewalDay, approxNow));
final OffsetDateTime secondRenewalDay = firstRenewal.getExpiry().map(v -> v.minusDays(triggerThresholdDays)).orElseThrow();
Expand Down Expand Up @@ -189,7 +192,7 @@ void testTimeShiftShouldNotCreateNewVersionsWhenAutoRotateIsTriggeredWithDeleted
certificateVaultFake.delete(originalCertId);

//when
underTest.timeShift(SECONDS_IN_800_DAYS, true);
underTest.timeShift(SECONDS_IN_MORE_THAN_TWO_YEARS, true);

//then
final boolean exists = underTest.certificateVaultFake().getDeletedEntities().containsName(originalCertId.id());
Expand Down Expand Up @@ -244,4 +247,24 @@ private static void assertTimestampsAreAdjustedAsExpected(
Assertions.assertEquals(DEFAULT_VALIDITY_MONTHS, MONTHS
.between(recreatedOriginal.getNotBefore().orElseThrow(), recreatedOriginal.getExpiry().orElseThrow()));
}

private static int getMoreThanTwoYearsAvoidingLeapYear() {
final Instant moreThanTwoYearsAgo = Instant.now().minus(INITIAL_OFFSET_IN_DAYS, DAYS);
if (isEndOfFebruary(moreThanTwoYearsAgo) || isBeginningOfMarch(moreThanTwoYearsAgo)) {
return INITIAL_OFFSET_IN_DAYS + EXTRA_OFFSET_IN_DAYS;
}
return INITIAL_OFFSET_IN_DAYS;
}

@SuppressWarnings("checkstyle:MagicNumber")
private static boolean isBeginningOfMarch(final Instant instant) {
return instant.atOffset(ZoneOffset.UTC).getMonth() == Month.MARCH
&& instant.atOffset(ZoneOffset.UTC).getDayOfMonth() < 5;
}

@SuppressWarnings("checkstyle:MagicNumber")
private static boolean isEndOfFebruary(final Instant instant) {
return instant.atOffset(ZoneOffset.UTC).getMonth() == Month.FEBRUARY
&& instant.atOffset(ZoneOffset.UTC).getDayOfMonth() > 27;
}
}

0 comments on commit 3b2fdf8

Please sign in to comment.