/** @test */ public function it_can_parse_a_certificate_days_to_expiration() { $monitor = new SSLCertificateMonitor(['url' => 'https://www.example.com/']); $certificate = $this->certificate; $certificate['validTo_time_t'] = strtotime('+2 days'); $monitor->processCertificate($certificate); $this->assertEquals(2, $monitor->getCertificateDaysUntilExpiration()); $certificate['validTo_time_t'] = strtotime('-2 days'); $monitor->processCertificate($certificate); $this->assertEquals(-2, $monitor->getCertificateDaysUntilExpiration()); }
/** @test */ public function it_throws_an_exception_for_nonexistent_url() { $sslCertificateMonitor = new SSLCertificateMonitor([]); $this->setExpectedException(InvalidConfiguration::class); $sslCertificateMonitor->runMonitor(); }
/** * @param SSLCertificateMonitor $sslCertificateMonitor */ public function sslCertificateExpiring(SSLCertificateMonitor $sslCertificateMonitor) { $this->sendNotification('whenSSLCertificateInvalid', "SSL Certificate Expiring: {$sslCertificateMonitor->getUrl()}", "SSL Certificate for {$sslCertificateMonitor->getUrl()} is expiring on {$sslCertificateMonitor->getCertificateExpiration()} ({$sslCertificateMonitor->getCertificateDaysUntilExpiration()} days).", BaseSender::TYPE_ERROR); }