mirror of
https://github.com/google/nomulus.git
synced 2025-07-25 20:18:34 +02:00
Remove isNearingExpiration() after shouldReceiveExpiringNotification() being added to code base (#1255)
* Resolve merge conflict
This commit is contained in:
parent
4d0078607f
commit
c4c5ac85da
2 changed files with 0 additions and 40 deletions
|
@ -201,22 +201,6 @@ public class CertificateChecker {
|
||||||
return checkCertificate(getCertificate(certificateString));
|
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. */
|
/** Converts the given string to a certificate object. */
|
||||||
public X509Certificate getCertificate(String certificateStr) {
|
public X509Certificate getCertificate(String certificateStr) {
|
||||||
X509Certificate certificate;
|
X509Certificate certificate;
|
||||||
|
|
|
@ -218,30 +218,6 @@ class CertificateCheckerTest {
|
||||||
assertThat(thrown).hasMessageThat().contains("Unable to read given certificate");
|
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
|
@Test
|
||||||
void test_getCertificate_throwsException_invalidCertificateString() {
|
void test_getCertificate_throwsException_invalidCertificateString() {
|
||||||
IllegalArgumentException thrown =
|
IllegalArgumentException thrown =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue