active_fulfillment 3.0.0.pre4 → 3.0.0.pre5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ff356b4c8f350a78ca0475c4415257fa803f83a9
4
- data.tar.gz: 971bb598f5bd8ff27cb73eb0e0c5810453586714
3
+ metadata.gz: ec1ce2a917a90a5c9fcd77faa2cf28603fae713a
4
+ data.tar.gz: 4b4cfa6be54fe07ec5d3bcd87b7c3b6057260103
5
5
  SHA512:
6
- metadata.gz: 2d7ce7cbb4a2dd194df82e42f7677678e92ccecfa5b01b7f9990622252bfaac22cb2b8542fdb3f55c5c6a553ff35e4e460cf223087ccb1f070fc71ef136a451f
7
- data.tar.gz: d1632004e3c03275a02bd0f1c2eabdef9cede7ca047fa75523d34a581d3ebc87466194d8701d2aa2c162fa092d1240b3a3c5f2e3be69aa782df284b85ebaf9c4
6
+ metadata.gz: a1baba64efc3e9a507a41a8c14853684366ecb1076e4588756758f6d3fdca89b725614c012a15d15b60c453d9b7cceecde03585bfea28957437db8ee2411a8cf
7
+ data.tar.gz: 3c17fc456c50f3a887ac3a16c008c80d3983021eba2e877b2f848c69e7f0363d6f3343f156fd04340d927dd9c97bb101dac8be4db1d1c079f340fce49fc4bf6d
@@ -184,11 +184,13 @@ module ActiveFulfillment
184
184
  uri = URI.parse("https://#{endpoint}/#{ACTIONS[service]}/#{VERSION}")
185
185
  query = build_full_query(verb, uri, params)
186
186
  headers = build_headers(query)
187
+ log_query = query
188
+ [@options[:login], @options[:app_id], @mws_auth_token].each { |key| log_query.gsub!(/#{key}/, '[filtered]') if key.present? }
187
189
 
190
+ logger.info "[#{self.class}][#{op.to_s}] query=#{log_query}"
188
191
  data = ssl_post(uri.to_s, query, headers)
189
- if service == :inventory
190
- logger.info "[#{self.class}][inventory] query=#{build_full_query(verb, uri, params.except('AWSAccessKeyId', 'MWSAuthToken'))} response=#{data}"
191
- end
192
+ logger.info "[#{self.class}][#{op.to_s}] response=#{data}"
193
+
192
194
  response = parse_response(service, op, data)
193
195
  Response.new(success?(response), message_from(response), response)
194
196
  rescue ActiveUtils::ResponseError => e
@@ -196,6 +198,7 @@ module ActiveFulfillment
196
198
  end
197
199
 
198
200
  def handle_error(e)
201
+ logger.info "[#{self.class}][ResponseError] response=#{e.response.try(:body)}, message=#{e.message}"
199
202
  response = parse_error(e.response)
200
203
  if response.fetch(:faultstring, "").match(/^Requested order \'.+\' not found$/)
201
204
  Response.new(true, nil, {:status => SUCCESS, :tracking_numbers => {}, :tracking_companies => {}, :tracking_urls => {}})
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module ActiveFulfillment
3
- VERSION = "3.0.0.pre4"
3
+ VERSION = "3.0.0.pre5"
4
4
  end
@@ -5,8 +5,8 @@ class AmazonMarketplaceWebServiceTest < Minitest::Test
5
5
 
6
6
  def setup
7
7
  @service = ActiveFulfillment::AmazonMarketplaceWebService.new(
8
- :login => 'l',
9
- :password => 'p'
8
+ :login => 'login',
9
+ :password => 'password'
10
10
  )
11
11
 
12
12
  @options = {
@@ -87,7 +87,7 @@ class AmazonMarketplaceWebServiceTest < Minitest::Test
87
87
  expected_keys = ["AWSAccessKeyId", "Action", "FeedType", "Merchant", "SignatureMethod", "SignatureVersion", "Timestamp", "Version"]
88
88
  opts = @service.build_basic_api_query(options)
89
89
  assert_equal expected_keys.sort, opts.keys.map(&:to_s).sort
90
- assert_equal "l", opts["AWSAccessKeyId"]
90
+ assert_equal "login", opts["AWSAccessKeyId"]
91
91
  assert_equal ActiveFulfillment::AmazonMarketplaceWebService::SIGNATURE_VERSION, opts["SignatureVersion"]
92
92
  assert_equal "Hmac#{ActiveFulfillment::AmazonMarketplaceWebService::SIGNATURE_METHOD}", opts["SignatureMethod"]
93
93
  assert_equal ActiveFulfillment::AmazonMarketplaceWebService::VERSION, opts["Version"]
@@ -279,10 +279,10 @@ class AmazonMarketplaceWebServiceTest < Minitest::Test
279
279
  @service.expects(:ssl_post).returns(xml_fixture('amazon_mws/inventory_list_inventory_supply'))
280
280
 
281
281
  @service.class.logger.expects(:info).with do |message|
282
- assert_match /ListInventorySupplyResult/, message
283
- assert /MWSAuthToken/ !~ message
284
- assert /AWSAccessKeyId/ !~ message
285
- end
282
+ assert_match /ListInventorySupply/, message unless message.include?('ListInventorySupplyResult')
283
+ assert /@service[:login]/ !~ message
284
+ assert /@service[:password]/ !~ message
285
+ end.twice
286
286
 
287
287
  response = @service.fetch_stock_levels
288
288
  assert response.success?
@@ -412,6 +412,25 @@ class AmazonMarketplaceWebServiceTest < Minitest::Test
412
412
  assert_equal 'Something has gone terribly wrong!', response.faultstring
413
413
  end
414
414
 
415
+ def test_fetch_tracking_numbers_400
416
+ response = mock('response')
417
+ response.stubs(:code).returns(400)
418
+ response.stubs(:message).returns("Error fetching tracking")
419
+ response.stubs(:body).returns(xml_fixture('amazon_mws/tracking_response_error'))
420
+
421
+ @service.expects(:ssl_post).raises(ActiveUtils::ResponseError.new(response))
422
+
423
+ @service.class.logger.expects(:info).with do |message|
424
+ assert_match /Something has gone terribly wrong/, message unless message.include?('GetFulfillmentOrder')
425
+ assert /@service[:login]/ !~ message
426
+ assert /@service[:password]/ !~ message
427
+ end.twice
428
+
429
+ response = @service.fetch_tracking_data(['extern_id_1154539615776'])
430
+ assert !response.success?
431
+ assert_equal 'Something has gone terribly wrong!', response.faultstring
432
+ end
433
+
415
434
  def test_404_error
416
435
  http_response = build_mock_response(response_from_404, "Not Found", "404")
417
436
  @service.expects(:ssl_post).raises(ActiveUtils::ResponseError.new(http_response))
@@ -440,7 +459,7 @@ class AmazonMarketplaceWebServiceTest < Minitest::Test
440
459
 
441
460
  private
442
461
  def build_mock_response(response, message, code = "200")
443
- http_response = mock(:code => code, :message => message)
462
+ http_response = stub(:code => code, :message => message)
444
463
  http_response.stubs(:body).returns(response)
445
464
  http_response
446
465
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_fulfillment
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.pre4
4
+ version: 3.0.0.pre5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Fauser
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-09-16 00:00:00.000000000 Z
12
+ date: 2015-11-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport