Skip to content

Commit 0d04e0d

Browse files
committed
Update mock dates in example app tests
The test user certificate expired on 2026-07-09, which made auth token validation fail with CertificateExpiredException. Mock the validation clock to a date within the certificate validity period, like commit 8ab06e0 did for the library tests.
1 parent 07f35b9 commit 0d04e0d

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

‎example/src/test/java/eu/webeid/example/WebApplicationTest.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public void validateOcspResponse(XadesSignature xadesSignature) {
103103
session.setAttribute("challenge-nonce", new ChallengeNonce(ObjectMother.VALID_CHALLENGE_NONCE, DateAndTime.utcNow().plusMinutes(1)));
104104

105105
Dates.setMockedSignatureDate(Dates.getSigningDateTime());
106+
Dates.setMockedAuthTokenValidationDate(Dates.getAuthTokenValidationDateTime());
106107

107108
// Act and assert
108109
mvcBuilder.build().perform(get("/auth/challenge"));

‎example/src/test/java/eu/webeid/example/testutil/Dates.java‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
package eu.webeid.example.testutil;
2424

2525
import eu.europa.esig.dss.model.BLevelParameters;
26+
import eu.webeid.security.util.DateAndTime;
2627
import mockit.Mock;
2728
import mockit.MockUp;
2829

@@ -37,6 +38,12 @@ public static ZonedDateTime getSigningDateTime() {
3738
ZoneId.of("Europe/Tallinn"));
3839
}
3940

41+
public static ZonedDateTime getAuthTokenValidationDateTime() {
42+
// Ensure that the certificates do not expire.
43+
return ZonedDateTime.of(2021, 7, 23, 0, 0, 0, 0,
44+
ZoneId.of("UTC"));
45+
}
46+
4047
public static void setMockedSignatureDate(ZonedDateTime mockedDateTime) {
4148
new MockUp<BLevelParameters>() {
4249
@Mock
@@ -45,4 +52,13 @@ public Date getSigningDate() {
4552
}
4653
};
4754
}
55+
56+
public static void setMockedAuthTokenValidationDate(ZonedDateTime mockedDateTime) {
57+
new MockUp<DateAndTime.DefaultClock>() {
58+
@Mock
59+
public Date now() {
60+
return Date.from(mockedDateTime.toInstant());
61+
}
62+
};
63+
}
4864
}

0 commit comments

Comments
 (0)