static boolean shouldRefresh(AwsTemporaryCredentials credentials) {
        Instant expiration = Optional.ofNullable(credentials).map(AwsTemporaryCredentials::expiration).orElse(Instant.EPOCH);
        return Duration.between(Instant.now(), expiration).toMinutes() < MIN_EXPIRY.toMinutes();
    }
@Test
    void refreshes_correctly() {
        Clock clock = Clock.systemUTC();
        // Does not require refresh when expires in 10 minutes
        assertFalse(AwsCredentials.shouldRefresh(getCredentials(clock.instant().plus(Duration.ofMinutes(10)))));

        // Requires refresh when expires in 3 minutes
        assertTrue(AwsCredentials.shouldRefresh(getCredentials(clock.instant().plus(Duration.ofMinutes(3)))));

        // Requires refresh when expired
        assertTrue(AwsCredentials.shouldRefresh(getCredentials(clock.instant().minus(Duration.ofMinutes(1)))));

        // Refreshes when no credentials provided
        assertTrue(AwsCredentials.shouldRefresh(null));
    }