Sha256: cf8082b60cab64aa3e2533b101e9db9aa51c841df4e9d94a6c4571e113aa32c9

Contents?: true

Size: 967 Bytes

Versions: 2

Compression:

Stored size: 967 Bytes

Contents

require 'spec_helper'
require 'haravan_theme'
require 'net/http'
require 'uri'
require 'digest'

module Smoke
  describe "CA Certificate Validity" do
    before do
      WebMock.disable!
      unless ENV['VERIFY_CERT']
        puts "Not testing CA certificates unless VERIFY_CERT variable is set"
        skip
      end
    end

    after do
      WebMock.enable!
    end

    it "verifies that the local certificate matches with that on haxx.se" do
      assert_equal digest(local_file), digest(remote_file)
    end

    def local_file
      File.read(HaravanTheme::CA_CERT_FILE)
    end

    def remote_file
      cert_uri = URI(HaravanTheme::REMOTE_CERT_FILE)
      response = Net::HTTP.get_response(cert_uri)
      if response.code == '200'
        response.body
      else
        flunk "Could not connect to #{cert_uri}. Verify that certificate is still hosted."
      end
    end

    def digest(message)
      Digest::MD5.hexdigest(message)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
haravan_theme-0.0.26 spec/smoke/ca_cert_spec.rb
haravan_theme-0.0.25 spec/smoke/ca_cert_spec.rb