active_utils 1.0.5 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -63,7 +63,17 @@ class ConnectionTest < Test::Unit::TestCase
63
63
  end
64
64
  end
65
65
 
66
+ def test_override_max_retries
67
+ assert_not_equal 1, @connection.max_retries
68
+ @connection.max_retries = 1
69
+ assert_equal 1, @connection.max_retries
70
+ end
66
71
 
72
+ def test_override_ssl_version
73
+ assert_not_equal :SSLv3, @connection.ssl_version
74
+ @connection.ssl_version = :SSLv3
75
+ assert_equal :SSLv3, @connection.ssl_version
76
+ end
67
77
 
68
78
  def test_default_read_timeout
69
79
  assert_equal ActiveMerchant::Connection::READ_TIMEOUT, @connection.read_timeout
@@ -88,8 +98,30 @@ class ConnectionTest < Test::Unit::TestCase
88
98
  assert_equal false, @connection.verify_peer
89
99
  end
90
100
 
101
+ def test_default_ca_file
102
+ assert_equal ActiveMerchant::Connection::CA_FILE, @connection.ca_file
103
+ assert_equal ActiveMerchant::Connection::CA_FILE, @connection.send(:http).ca_file
104
+ end
105
+
106
+ def test_override_ca_file
107
+ @connection.ca_file = "/bogus"
108
+ assert_equal "/bogus", @connection.ca_file
109
+ assert_equal "/bogus", @connection.send(:http).ca_file
110
+ end
111
+
112
+ def test_default_ca_path
113
+ assert_equal ActiveMerchant::Connection::CA_PATH, @connection.ca_path
114
+ assert_equal ActiveMerchant::Connection::CA_PATH, @connection.send(:http).ca_path
115
+ end
116
+
117
+ def test_override_ca_path
118
+ @connection.ca_path = "/bogus"
119
+ assert_equal "/bogus", @connection.ca_path
120
+ assert_equal "/bogus", @connection.send(:http).ca_path
121
+ end
122
+
91
123
  def test_unrecoverable_exception
92
- @connection.logger.expects(:error).once
124
+ @connection.logger.expects(:info).once
93
125
  Net::HTTP.any_instance.expects(:post).raises(EOFError)
94
126
 
95
127
  assert_raises(ActiveMerchant::ConnectionError) do
@@ -98,7 +130,7 @@ class ConnectionTest < Test::Unit::TestCase
98
130
  end
99
131
 
100
132
  def test_failure_then_success_with_recoverable_exception
101
- @connection.logger.expects(:error).never
133
+ @connection.logger.expects(:info).never
102
134
  Net::HTTP.any_instance.expects(:post).times(2).raises(Errno::ECONNREFUSED).then.returns(@ok)
103
135
 
104
136
  assert_nothing_raised do
@@ -107,7 +139,7 @@ class ConnectionTest < Test::Unit::TestCase
107
139
  end
108
140
 
109
141
  def test_failure_limit_reached
110
- @connection.logger.expects(:error).once
142
+ @connection.logger.expects(:info).once
111
143
  Net::HTTP.any_instance.expects(:post).times(ActiveMerchant::Connection::MAX_RETRIES).raises(Errno::ECONNREFUSED)
112
144
 
113
145
  assert_raises(ActiveMerchant::ConnectionError) do
@@ -23,7 +23,7 @@ class NetworkConnectionRetriesTest < Test::Unit::TestCase
23
23
  end
24
24
 
25
25
  def test_unrecoverable_exception_logged_if_logger_provided
26
- @logger.expects(:error).once
26
+ @logger.expects(:info).once
27
27
  assert_raises(ActiveMerchant::ConnectionError) do
28
28
  retry_exceptions :logger => @logger do
29
29
  raise EOFError
@@ -52,7 +52,7 @@ class NetworkConnectionRetriesTest < Test::Unit::TestCase
52
52
  end
53
53
 
54
54
  def test_failure_limit_reached_logs_final_error
55
- @logger.expects(:error).once
55
+ @logger.expects(:info).times(3)
56
56
  @requester.expects(:post).times(ActiveMerchant::NetworkConnectionRetries::DEFAULT_RETRIES).raises(Errno::ECONNREFUSED)
57
57
 
58
58
  assert_raises(ActiveMerchant::ConnectionError) do
@@ -72,6 +72,18 @@ class NetworkConnectionRetriesTest < Test::Unit::TestCase
72
72
  end
73
73
  end
74
74
 
75
+ def test_failure_then_success_logs_success
76
+ @logger.expects(:info).with(regexp_matches(/dropped/))
77
+ @logger.expects(:info).with(regexp_matches(/success/))
78
+ @requester.expects(:post).times(2).raises(EOFError).then.returns(@ok)
79
+
80
+ assert_nothing_raised do
81
+ retry_exceptions(:logger => @logger, :retry_safe => true) do
82
+ @requester.post
83
+ end
84
+ end
85
+ end
86
+
75
87
  def test_mixture_of_failures_with_retry_safe_enabled
76
88
  @requester.expects(:post).times(3).raises(Errno::ECONNRESET).
77
89
  raises(Errno::ECONNREFUSED).
@@ -13,6 +13,29 @@ class PostsDataTest < Test::Unit::TestCase
13
13
  @poster = SSLPoster.new
14
14
  end
15
15
 
16
+ def test_ssl_request_retried_three_times_by_default
17
+ requester = stubs(:requester)
18
+ requester.expects(:post).raises(Errno::ECONNREFUSED).times(3)
19
+ Connection.any_instance.stubs(:http => requester)
20
+
21
+ assert_raises ActiveMerchant::ConnectionError do
22
+ @poster.raw_ssl_request(:post, "https://shopify.com", "", {})
23
+ end
24
+ end
25
+
26
+ def test_ssl_request_never_retried_if_max_retries_set
27
+ SSLPoster.max_retries = 1
28
+ requester = stubs(:requester)
29
+ requester.expects(:post).raises(Errno::ECONNREFUSED).times(1)
30
+ Connection.any_instance.stubs(:http => requester)
31
+
32
+ assert_raises ActiveMerchant::ConnectionError do
33
+ @poster.raw_ssl_request(:post, "https://shopify.com", "", {})
34
+ end
35
+ ensure
36
+ SSLPoster.max_retries = ActiveMerchant::Connection::MAX_RETRIES
37
+ end
38
+
16
39
  def test_logger_warns_if_ssl_strict_disabled
17
40
  @poster.logger = stub()
18
41
  @poster.logger.expects(:warn).with("PostsDataTest::SSLPoster using ssl_strict=false, which is insecure")
metadata CHANGED
@@ -1,60 +1,80 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
5
4
  prerelease:
5
+ version: 2.0.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Shopify
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-07 00:00:00.000000000 Z
12
+ date: 2013-07-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: activesupport
16
- requirement: &70097925445800 !ruby/object:Gem::Requirement
17
- none: false
15
+ version_requirements: !ruby/object:Gem::Requirement
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 2.3.11
20
+ none: false
21
+ name: activesupport
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70097925445800
25
- - !ruby/object:Gem::Dependency
26
- name: i18n
27
- requirement: &70097925445380 !ruby/object:Gem::Requirement
24
+ requirement: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ! '>='
27
+ - !ruby/object:Gem::Version
28
+ version: 2.3.11
28
29
  none: false
30
+ - !ruby/object:Gem::Dependency
31
+ version_requirements: !ruby/object:Gem::Requirement
29
32
  requirements:
30
33
  - - ! '>='
31
34
  - !ruby/object:Gem::Version
32
35
  version: '0'
36
+ none: false
37
+ name: i18n
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *70097925445380
36
- - !ruby/object:Gem::Dependency
37
- name: rake
38
- requirement: &70097925444920 !ruby/object:Gem::Requirement
40
+ requirement: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
39
45
  none: false
46
+ - !ruby/object:Gem::Dependency
47
+ version_requirements: !ruby/object:Gem::Requirement
40
48
  requirements:
41
49
  - - ! '>='
42
50
  - !ruby/object:Gem::Version
43
51
  version: '0'
52
+ none: false
53
+ name: rake
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *70097925444920
47
- - !ruby/object:Gem::Dependency
48
- name: mocha
49
- requirement: &70097925444500 !ruby/object:Gem::Requirement
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
50
61
  none: false
62
+ - !ruby/object:Gem::Dependency
63
+ version_requirements: !ruby/object:Gem::Requirement
51
64
  requirements:
52
65
  - - ! '>='
53
66
  - !ruby/object:Gem::Version
54
67
  version: '0'
68
+ none: false
69
+ name: mocha
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *70097925444500
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ none: false
58
78
  description:
59
79
  email:
60
80
  - developers@jadedpixel.com
@@ -96,20 +116,20 @@ rdoc_options: []
96
116
  require_paths:
97
117
  - lib
98
118
  required_ruby_version: !ruby/object:Gem::Requirement
99
- none: false
100
119
  requirements:
101
120
  - - ! '>='
102
121
  - !ruby/object:Gem::Version
103
122
  version: '0'
104
- required_rubygems_version: !ruby/object:Gem::Requirement
105
123
  none: false
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
125
  requirements:
107
126
  - - ! '>='
108
127
  - !ruby/object:Gem::Version
109
128
  version: '0'
129
+ none: false
110
130
  requirements: []
111
131
  rubyforge_project: active_utils
112
- rubygems_version: 1.8.11
132
+ rubygems_version: 1.8.23
113
133
  signing_key:
114
134
  specification_version: 3
115
135
  summary: Common utils used by active_merchant, active_fulfillment, and active_shipping