Created
July 29, 2013 18:51
-
-
Save statik/6106682 to your computer and use it in GitHub Desktop.
Checking SSL expiration dates with cucumber
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: SSL Renewal Checks | |
We have a large list of SSL certificates | |
So that none of those expire | |
We can run a check for those soon expiring | |
Scenario Outline: Check SSL certificate expiration | |
When I sslcheck <website> | |
Then the SSL certificate should have at least 30 days remaining | |
Examples: | |
| website | | |
| https://recoverylibrary.com | | |
| https://www.patdeegan.com | | |
| https://training.personalmedicine.org | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/https' | |
require 'date' | |
When /^I sslcheck (.*)$/ do |path| | |
uri = URI.parse(path) | |
http = Net::HTTP.new(uri.host,uri.port) | |
http.use_ssl = true | |
http.verify_mode = OpenSSL::SSL::VERIFY_NONE | |
http.start do |h| | |
@cert = h.peer_cert | |
end | |
end | |
Then /^the SSL certificate should have at least (\d+) days remaining$/ do |days| | |
today = Date.today | |
expires = @cert.not_after.to_date | |
expect(today).to be < expires | |
remaining_days = (expires - today).to_i | |
expect(remaining_days).to be > days.to_i | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment