Permalink
Browse files

2.5.2

  • Loading branch information...
braintreeps committed Sep 3, 2010
1 parent 52830f1 commit fcadea18e11d8feca05e9144e2d6013cc7083f15
View
@@ -1,6 +1,11 @@
+== 2.5.2
+
+* removed ssl expiration check
+* lazy initialize Configuration.logger when directly instantiating configuration
+
== 2.5.1
-* lazy initialize Configuration.logger at the class level
+* lazy initialize Configuration.logger to fix bug with ssl expiration check
== 2.5.0
View
@@ -39,7 +39,6 @@ module Braintree
require "braintree/gateway"
require "braintree/http"
require "braintree/resource_collection"
-require "braintree/ssl_expiration_check"
require "braintree/subscription"
require "braintree/subscription_gateway"
require "braintree/subscription_search"
@@ -65,5 +64,3 @@ module Braintree
require "braintree/xml/rexml"
require "braintree/xml/parser"
-Braintree::SSLExpirationCheck.check_dates
-
@@ -6,7 +6,7 @@ class Configuration
class << self
attr_writer :custom_user_agent, :logger, :merchant_id, :public_key, :private_key
end
- attr_reader :logger, :merchant_id, :public_key, :private_key
+ attr_reader :merchant_id, :public_key, :private_key
def self.expectant_reader(*attributes) # :nodoc:
attributes.each do |attribute|
@@ -77,6 +77,10 @@ def http # :nodoc:
Http.new(self)
end
+ def logger
+ @logger ||= self.class._default_logger
+ end
+
def port # :nodoc:
case @environment
when :development
@@ -1,27 +0,0 @@
-module Braintree
- module SSLExpirationCheck # :nodoc:
- class << self
- attr_reader :ssl_expiration_dates_checked
- end
-
- def self.check_dates # :nodoc:
- {
- "Sandbox" => sandbox_expiration_date,
- "Production" => production_expiration_date
- }.each do |host, expiration_date|
- if Date.today + (3 * 30) > expiration_date
- Configuration.logger.warn "[Braintree] The SSL Certificate for the #{host} environment will expire on #{expiration_date}. Please check for an updated client library."
- end
- end
- @ssl_expiration_dates_checked = true
- end
-
- def self.production_expiration_date # :nodoc:
- Date.civil(2012, 1, 8)
- end
-
- def self.sandbox_expiration_date # :nodoc:
- Date.civil(2010, 12, 1)
- end
- end
-end
View
@@ -2,7 +2,7 @@ module Braintree
module Version
Major = 2
Minor = 5
- Tiny = 1
+ Tiny = 2
String = "#{Major}.#{Minor}.#{Tiny}"
end
@@ -1,93 +0,0 @@
-require File.dirname(__FILE__) + "/../spec_helper"
-
-# Helper method to confirm we have the right values
-def fetch_expiration_date(host, port=443)
- cmd = "echo | openssl s_client -connect #{host}:#{port} 2>&1 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | openssl x509 -noout -subject -dates | grep notAfter"
- date = `#{cmd}`.sub(/^.*=/, '')
-
- Date.parse(date)
-end
-
-describe Braintree::SSLExpirationCheck do
- SANDBOX = "sandbox.braintreegateway.com"
- PRODUCTION = "www.braintreegateway.com"
-
- describe "check_dates" do
- it "is done when the client library is loaded" do
- Braintree::SSLExpirationCheck.ssl_expiration_dates_checked.should == true
- end
-
- describe "Sandbox Cert" do
- it "logs when the cert is expired" do
- Braintree::SSLExpirationCheck.stub(:sandbox_expiration_date).and_return(Date.today - 1)
-
- output = StringIO.new
- Braintree::Configuration.logger = Logger.new(output)
- Braintree::Configuration.logger.level = Logger::WARN
-
- Braintree::SSLExpirationCheck.check_dates
-
- output.string.should match(/\[Braintree\] The SSL Certificate for the Sandbox environment will expire on \d{4}-\d{2}-\d{2}\. Please check for an updated client library\./)
- end
-
- it "logs when the cert is close to expiring" do
- Braintree::SSLExpirationCheck.stub(:sandbox_expiration_date).and_return(Date.today)
- output = StringIO.new
- Braintree::Configuration.logger = Logger.new(output)
- Braintree::Configuration.logger.level = Logger::WARN
-
- Braintree::SSLExpirationCheck.check_dates
-
- output.string.should match(/\[Braintree\] The SSL Certificate for the Sandbox environment will expire on \d{4}-\d{2}-\d{2}\. Please check for an updated client library\./)
- end
-
- it "doesn't log when the cert is not expired" do
- Braintree::SSLExpirationCheck.stub(:sandbox_expiration_date).and_return(Date.today + 365)
- output = StringIO.new
- Braintree::Configuration.logger = Logger.new(output)
- Braintree::Configuration.logger.level = Logger::WARN
-
- Braintree::SSLExpirationCheck.check_dates
-
- output.string.should == ""
- end
- end
-
- # We assume that testing logging for one is good enough for all, so we won't duplicate those tests from above
- it "checks the sandbox cert" do
- Braintree::SSLExpirationCheck.stub(:sandbox_expiration_date).and_return(Date.today)
- output = StringIO.new
- Braintree::Configuration.logger = Logger.new(output)
- Braintree::Configuration.logger.level = Logger::WARN
-
- Braintree::SSLExpirationCheck.check_dates
-
- output.string.should match(/\[Braintree\] The SSL Certificate for the Sandbox environment will expire on \d{4}-\d{2}-\d{2}\. Please check for an updated client library\./)
- end
-
- it "checks the production server cert" do
- Braintree::SSLExpirationCheck.stub(:production_expiration_date).and_return(Date.today)
- output = StringIO.new
- Braintree::Configuration.logger = Logger.new(output)
- Braintree::Configuration.logger.level = Logger::WARN
-
- Braintree::SSLExpirationCheck.check_dates
-
- output.string.should match(/\[Braintree\] The SSL Certificate for the Production environment will expire on \d{4}-\d{2}-\d{2}\. Please check for an updated client library\./)
- end
- end
-
- describe "production_expiration_date" do
- it "is the date the production cert expires" do
- Braintree::SSLExpirationCheck.production_expiration_date.should be_a(Date)
- Braintree::SSLExpirationCheck.production_expiration_date.should == fetch_expiration_date(PRODUCTION)
- end
- end
-
- describe "sandbox_expiration_date" do
- it "is the date the Sandbox cert expires" do
- Braintree::SSLExpirationCheck.sandbox_expiration_date.should be_a(Date)
- Braintree::SSLExpirationCheck.sandbox_expiration_date.should == fetch_expiration_date(SANDBOX)
- end
- end
-end
@@ -63,6 +63,18 @@
end
end
+ describe "logger" do
+ it "defaults to logging to stdout with log_level info" do
+ config = Braintree::Configuration.new
+ config.logger.level.should == Logger::INFO
+ end
+
+ it "lazily initializes so that you can do Braintree::Configuration.logger.level = when configuring the client lib" do
+ config = Braintree::Configuration.new :logger => nil
+ config.logger.should_not == nil
+ end
+ end
+
describe "self.environment" do
it "raises an exception if it hasn't been set yet" do
Braintree::Configuration.instance_variable_set(:@environment, nil)
@@ -1,7 +1,7 @@
require File.dirname(__FILE__) + "/spec_helper"
describe Braintree do
- xit "ssl warning -- doesn't produce warnings if loading braintree.rb twice" do
+ it "doesn't produce warnings if loading braintree.rb twice" do
lib_dir = File.dirname(__FILE__) + "/../../lib"
braintree_file = "#{lib_dir}/braintree.rb"
File.exist?(braintree_file).should == true

0 comments on commit fcadea1

Please sign in to comment.