module RSpec::WebserviceMatchers::EnforceHttpsEverywhere
Public Instance Methods
get_info(domain_name)
click to toggle source
# File lib/rspec/webservice_matchers/enforce_https_everywhere.rb, line 28 def get_info(domain_name) status, headers = WebTest::Util.head(domain_name) location = headers['location'] /^(https?)/ =~ location protocol = Regexp.last_match(1) || nil [status, location, protocol] end
higher_level_errors(status, protocol, cert_is_valid)
click to toggle source
# File lib/rspec/webservice_matchers/enforce_https_everywhere.rb, line 46 def higher_level_errors(status, protocol, cert_is_valid) errors = [] unless permanent_redirect?(status) errors << "received status #{status} instead of 301" end if protocol && (protocol != 'https') errors << "destination uses protocol #{protocol.upcase}" end errors << "there's no valid SSL certificate" unless cert_is_valid WebTest::Util.error_message(errors) end
meets_expectations?(status, protocol, valid_cert)
click to toggle source
# File lib/rspec/webservice_matchers/enforce_https_everywhere.rb, line 36 def meets_expectations?(status, protocol, valid_cert) permanent_redirect?(status) && (protocol == 'https') && valid_cert end