Description
Some tests currently rely on new Date() (or similar system time calls), which makes them dependent on the actual current time. This can lead to non-deterministic behavior and potential failures in the future.
This is especially problematic for scenarios involving certificates, where validity periods (issue and expiration dates) are fixed values. Even if certificates have long expiration times, tests that implicitly depend on the current time may break as time progresses.
Problems
Tests may pass or fail depending on when they are executed.
Future test runs could fail unexpectedly (e.g., due to expired certificates).
Reduced reproducibility and reliability of the test suite.
Proposed Solution
Replace direct calls to new Date() (or System.currentTimeMillis()) with controlled time sources.
Use fixed timestamps or mocked clocks (e.g., Clock in Java).
Introduce utilities or helpers to provide deterministic time values across tests.
Example
Instead of:
Use:
Clock fixedClock = Clock.fixed(Instant.parse("2026-01-01T00:00:00Z"), ZoneOffset.UTC);
Date now = Date.from(fixedClock.instant());
or any alternative for fix time/date.
Acceptance Criteria
- All tests are deterministic with respect to time.
- No direct reliance on system time in tests.
- Tests remain stable and future-proof regardless of execution date.
Description
Some tests currently rely on new Date() (or similar system time calls), which makes them dependent on the actual current time. This can lead to non-deterministic behavior and potential failures in the future.
This is especially problematic for scenarios involving certificates, where validity periods (issue and expiration dates) are fixed values. Even if certificates have long expiration times, tests that implicitly depend on the current time may break as time progresses.
Problems
Tests may pass or fail depending on when they are executed.
Future test runs could fail unexpectedly (e.g., due to expired certificates).
Reduced reproducibility and reliability of the test suite.
Proposed Solution
Replace direct calls to new Date() (or System.currentTimeMillis()) with controlled time sources.
Use fixed timestamps or mocked clocks (e.g., Clock in Java).
Introduce utilities or helpers to provide deterministic time values across tests.
Example
Instead of:
Use:
or any alternative for fix time/date.
Acceptance Criteria