Remove isNearingExpiration() after shouldReceiveExpiringNotification() being added to code base (#1255)

* Resolve merge conflict
This commit is contained in:
Rachel Guan 2021-07-26 18:23:14 -04:00 committed by GitHub
parent 4d0078607f
commit c4c5ac85da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 40 deletions

View file

@ -201,22 +201,6 @@ public class CertificateChecker {
return checkCertificate(getCertificate(certificateString));
}
/**
* Returns whether the certificate is nearing expiration.
*
* <p>Note that this is <i>all</i> that it checks. The certificate itself may well be expired or
* not yet valid and this message will still return false. So you definitely want to pair a call
* to this method with a call to {@link #checkCertificate} to determine other issues with the
* certificate that may be occurring.
*/
public boolean isNearingExpiration(X509Certificate certificate) {
Date nearingExpirationDate =
DateTime.parse(certificate.getNotAfter().toInstant().toString())
.minusDays(expirationWarningDays)
.toDate();
return clock.nowUtc().toDate().after(nearingExpirationDate);
}
/** Converts the given string to a certificate object. */
public X509Certificate getCertificate(String certificateStr) {
X509Certificate certificate;

View file

@ -218,30 +218,6 @@ class CertificateCheckerTest {
assertThat(thrown).hasMessageThat().contains("Unable to read given certificate");
}
@Test
void test_isNearingExpiration_yesItIs() throws Exception {
fakeClock.setTo(DateTime.parse("2021-09-20T00:00:00Z"));
X509Certificate certificate =
SelfSignedCaCertificate.create(
SSL_HOST,
DateTime.parse("2020-09-02T00:00:00Z"),
DateTime.parse("2021-10-01T00:00:00Z"))
.cert();
assertThat(certificateChecker.isNearingExpiration(certificate)).isTrue();
}
@Test
void test_isNearingExpiration_noItsNot() throws Exception {
fakeClock.setTo(DateTime.parse("2021-07-20T00:00:00Z"));
X509Certificate certificate =
SelfSignedCaCertificate.create(
SSL_HOST,
DateTime.parse("2020-09-02T00:00:00Z"),
DateTime.parse("2021-10-01T00:00:00Z"))
.cert();
assertThat(certificateChecker.isNearingExpiration(certificate)).isFalse();
}
@Test
void test_getCertificate_throwsException_invalidCertificateString() {
IllegalArgumentException thrown =