braintree 2.5.1 → 2.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -39,7 +39,6 @@ require "braintree/errors"
39
39
  require "braintree/gateway"
40
40
  require "braintree/http"
41
41
  require "braintree/resource_collection"
42
- require "braintree/ssl_expiration_check"
43
42
  require "braintree/subscription"
44
43
  require "braintree/subscription_gateway"
45
44
  require "braintree/subscription_search"
@@ -65,5 +64,3 @@ require "braintree/xml/libxml"
65
64
  require "braintree/xml/rexml"
66
65
  require "braintree/xml/parser"
67
66
 
68
- Braintree::SSLExpirationCheck.check_dates
69
-
@@ -6,7 +6,7 @@ module Braintree
6
6
  class << self
7
7
  attr_writer :custom_user_agent, :logger, :merchant_id, :public_key, :private_key
8
8
  end
9
- attr_reader :logger, :merchant_id, :public_key, :private_key
9
+ attr_reader :merchant_id, :public_key, :private_key
10
10
 
11
11
  def self.expectant_reader(*attributes) # :nodoc:
12
12
  attributes.each do |attribute|
@@ -77,6 +77,10 @@ module Braintree
77
77
  Http.new(self)
78
78
  end
79
79
 
80
+ def logger
81
+ @logger ||= self.class._default_logger
82
+ end
83
+
80
84
  def port # :nodoc:
81
85
  case @environment
82
86
  when :development
@@ -2,7 +2,7 @@ module Braintree
2
2
  module Version
3
3
  Major = 2
4
4
  Minor = 5
5
- Tiny = 1
5
+ Tiny = 2
6
6
 
7
7
  String = "#{Major}.#{Minor}.#{Tiny}"
8
8
  end
@@ -63,6 +63,18 @@ describe Braintree::Configuration do
63
63
  end
64
64
  end
65
65
 
66
+ describe "logger" do
67
+ it "defaults to logging to stdout with log_level info" do
68
+ config = Braintree::Configuration.new
69
+ config.logger.level.should == Logger::INFO
70
+ end
71
+
72
+ it "lazily initializes so that you can do Braintree::Configuration.logger.level = when configuring the client lib" do
73
+ config = Braintree::Configuration.new :logger => nil
74
+ config.logger.should_not == nil
75
+ end
76
+ end
77
+
66
78
  describe "self.environment" do
67
79
  it "raises an exception if it hasn't been set yet" do
68
80
  Braintree::Configuration.instance_variable_set(:@environment, nil)
@@ -1,7 +1,7 @@
1
1
  require File.dirname(__FILE__) + "/spec_helper"
2
2
 
3
3
  describe Braintree do
4
- xit "ssl warning -- doesn't produce warnings if loading braintree.rb twice" do
4
+ it "doesn't produce warnings if loading braintree.rb twice" do
5
5
  lib_dir = File.dirname(__FILE__) + "/../../lib"
6
6
  braintree_file = "#{lib_dir}/braintree.rb"
7
7
  File.exist?(braintree_file).should == true
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: braintree
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
5
4
  prerelease: false
6
5
  segments:
7
6
  - 2
8
7
  - 5
9
- - 1
10
- version: 2.5.1
8
+ - 2
9
+ version: 2.5.2
11
10
  platform: ruby
12
11
  authors:
13
12
  - Braintree Payment Solutions
@@ -22,11 +21,9 @@ dependencies:
22
21
  name: builder
23
22
  prerelease: false
24
23
  requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
24
  requirements:
27
25
  - - ">="
28
26
  - !ruby/object:Gem::Version
29
- hash: 3
30
27
  segments:
31
28
  - 0
32
29
  version: "0"
@@ -64,7 +61,6 @@ files:
64
61
  - lib/braintree/http.rb
65
62
  - lib/braintree/modification.rb
66
63
  - lib/braintree/resource_collection.rb
67
- - lib/braintree/ssl_expiration_check.rb
68
64
  - lib/braintree/subscription.rb
69
65
  - lib/braintree/subscription_gateway.rb
70
66
  - lib/braintree/subscription_search.rb
@@ -97,7 +93,6 @@ files:
97
93
  - spec/integration/braintree/customer_spec.rb
98
94
  - spec/integration/braintree/error_codes_spec.rb
99
95
  - spec/integration/braintree/http_spec.rb
100
- - spec/integration/braintree/ssl_expiration_check_spec.rb
101
96
  - spec/integration/braintree/subscription_spec.rb
102
97
  - spec/integration/braintree/test/transaction_amounts_spec.rb
103
98
  - spec/integration/braintree/transaction_search_spec.rb
@@ -147,27 +142,23 @@ rdoc_options: []
147
142
  require_paths:
148
143
  - lib
149
144
  required_ruby_version: !ruby/object:Gem::Requirement
150
- none: false
151
145
  requirements:
152
146
  - - ">="
153
147
  - !ruby/object:Gem::Version
154
- hash: 3
155
148
  segments:
156
149
  - 0
157
150
  version: "0"
158
151
  required_rubygems_version: !ruby/object:Gem::Requirement
159
- none: false
160
152
  requirements:
161
153
  - - ">="
162
154
  - !ruby/object:Gem::Version
163
- hash: 3
164
155
  segments:
165
156
  - 0
166
157
  version: "0"
167
158
  requirements: []
168
159
 
169
160
  rubyforge_project: braintree
170
- rubygems_version: 1.3.7
161
+ rubygems_version: 1.3.6
171
162
  signing_key:
172
163
  specification_version: 3
173
164
  summary: Braintree Gateway Ruby Client Library
@@ -1,27 +0,0 @@
1
- module Braintree
2
- module SSLExpirationCheck # :nodoc:
3
- class << self
4
- attr_reader :ssl_expiration_dates_checked
5
- end
6
-
7
- def self.check_dates # :nodoc:
8
- {
9
- "Sandbox" => sandbox_expiration_date,
10
- "Production" => production_expiration_date
11
- }.each do |host, expiration_date|
12
- if Date.today + (3 * 30) > expiration_date
13
- Configuration.logger.warn "[Braintree] The SSL Certificate for the #{host} environment will expire on #{expiration_date}. Please check for an updated client library."
14
- end
15
- end
16
- @ssl_expiration_dates_checked = true
17
- end
18
-
19
- def self.production_expiration_date # :nodoc:
20
- Date.civil(2012, 1, 8)
21
- end
22
-
23
- def self.sandbox_expiration_date # :nodoc:
24
- Date.civil(2010, 12, 1)
25
- end
26
- end
27
- end
@@ -1,93 +0,0 @@
1
- require File.dirname(__FILE__) + "/../spec_helper"
2
-
3
- # Helper method to confirm we have the right values
4
- def fetch_expiration_date(host, port=443)
5
- cmd = "echo | openssl s_client -connect #{host}:#{port} 2>&1 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | openssl x509 -noout -subject -dates | grep notAfter"
6
- date = `#{cmd}`.sub(/^.*=/, '')
7
-
8
- Date.parse(date)
9
- end
10
-
11
- describe Braintree::SSLExpirationCheck do
12
- SANDBOX = "sandbox.braintreegateway.com"
13
- PRODUCTION = "www.braintreegateway.com"
14
-
15
- describe "check_dates" do
16
- it "is done when the client library is loaded" do
17
- Braintree::SSLExpirationCheck.ssl_expiration_dates_checked.should == true
18
- end
19
-
20
- describe "Sandbox Cert" do
21
- it "logs when the cert is expired" do
22
- Braintree::SSLExpirationCheck.stub(:sandbox_expiration_date).and_return(Date.today - 1)
23
-
24
- output = StringIO.new
25
- Braintree::Configuration.logger = Logger.new(output)
26
- Braintree::Configuration.logger.level = Logger::WARN
27
-
28
- Braintree::SSLExpirationCheck.check_dates
29
-
30
- 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\./)
31
- end
32
-
33
- it "logs when the cert is close to expiring" do
34
- Braintree::SSLExpirationCheck.stub(:sandbox_expiration_date).and_return(Date.today)
35
- output = StringIO.new
36
- Braintree::Configuration.logger = Logger.new(output)
37
- Braintree::Configuration.logger.level = Logger::WARN
38
-
39
- Braintree::SSLExpirationCheck.check_dates
40
-
41
- 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\./)
42
- end
43
-
44
- it "doesn't log when the cert is not expired" do
45
- Braintree::SSLExpirationCheck.stub(:sandbox_expiration_date).and_return(Date.today + 365)
46
- output = StringIO.new
47
- Braintree::Configuration.logger = Logger.new(output)
48
- Braintree::Configuration.logger.level = Logger::WARN
49
-
50
- Braintree::SSLExpirationCheck.check_dates
51
-
52
- output.string.should == ""
53
- end
54
- end
55
-
56
- # We assume that testing logging for one is good enough for all, so we won't duplicate those tests from above
57
- it "checks the sandbox cert" do
58
- Braintree::SSLExpirationCheck.stub(:sandbox_expiration_date).and_return(Date.today)
59
- output = StringIO.new
60
- Braintree::Configuration.logger = Logger.new(output)
61
- Braintree::Configuration.logger.level = Logger::WARN
62
-
63
- Braintree::SSLExpirationCheck.check_dates
64
-
65
- 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\./)
66
- end
67
-
68
- it "checks the production server cert" do
69
- Braintree::SSLExpirationCheck.stub(:production_expiration_date).and_return(Date.today)
70
- output = StringIO.new
71
- Braintree::Configuration.logger = Logger.new(output)
72
- Braintree::Configuration.logger.level = Logger::WARN
73
-
74
- Braintree::SSLExpirationCheck.check_dates
75
-
76
- 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\./)
77
- end
78
- end
79
-
80
- describe "production_expiration_date" do
81
- it "is the date the production cert expires" do
82
- Braintree::SSLExpirationCheck.production_expiration_date.should be_a(Date)
83
- Braintree::SSLExpirationCheck.production_expiration_date.should == fetch_expiration_date(PRODUCTION)
84
- end
85
- end
86
-
87
- describe "sandbox_expiration_date" do
88
- it "is the date the Sandbox cert expires" do
89
- Braintree::SSLExpirationCheck.sandbox_expiration_date.should be_a(Date)
90
- Braintree::SSLExpirationCheck.sandbox_expiration_date.should == fetch_expiration_date(SANDBOX)
91
- end
92
- end
93
- end