active_fulfillment 2.1.9 → 3.0.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +68 -0
- data/lib/active_fulfillment.rb +5 -5
- data/lib/active_fulfillment/base.rb +10 -0
- data/lib/active_fulfillment/response.rb +26 -0
- data/lib/active_fulfillment/service.rb +56 -0
- data/lib/active_fulfillment/services.rb +5 -0
- data/lib/active_fulfillment/services/amazon_mws.rb +473 -0
- data/lib/active_fulfillment/services/james_and_james.rb +122 -0
- data/lib/active_fulfillment/services/shipwire.rb +266 -0
- data/lib/active_fulfillment/services/shopify_api.rb +125 -0
- data/lib/active_fulfillment/services/webgistix.rb +334 -0
- data/lib/active_fulfillment/version.rb +4 -0
- data/test/remote/amazon_mws_test.rb +20 -17
- data/test/remote/james_and_james_test.rb +77 -0
- data/test/remote/shipwire_test.rb +25 -25
- data/test/remote/webgistix_test.rb +21 -21
- data/test/test_helper.rb +27 -52
- data/test/unit/base_test.rb +4 -4
- data/test/unit/services/amazon_mws_test.rb +56 -26
- data/test/unit/services/james_and_james_test.rb +90 -0
- data/test/unit/services/shipwire_test.rb +18 -18
- data/test/unit/services/shopify_api_test.rb +7 -20
- data/test/unit/services/webgistix_test.rb +35 -35
- metadata +32 -114
- data/CHANGELOG +0 -62
- data/lib/active_fulfillment/fulfillment/base.rb +0 -12
- data/lib/active_fulfillment/fulfillment/response.rb +0 -28
- data/lib/active_fulfillment/fulfillment/service.rb +0 -58
- data/lib/active_fulfillment/fulfillment/services.rb +0 -5
- data/lib/active_fulfillment/fulfillment/services/amazon.rb +0 -389
- data/lib/active_fulfillment/fulfillment/services/amazon_mws.rb +0 -454
- data/lib/active_fulfillment/fulfillment/services/shipwire.rb +0 -268
- data/lib/active_fulfillment/fulfillment/services/shopify_api.rb +0 -125
- data/lib/active_fulfillment/fulfillment/services/webgistix.rb +0 -338
- data/lib/active_fulfillment/fulfillment/version.rb +0 -6
- data/test/fixtures.yml +0 -16
- data/test/fixtures/xml/amazon/inventory_get_response.xml +0 -17
- data/test/fixtures/xml/amazon/inventory_list_response.xml +0 -29
- data/test/fixtures/xml/amazon/inventory_list_response_with_next_1.xml +0 -30
- data/test/fixtures/xml/amazon/inventory_list_response_with_next_2.xml +0 -29
- data/test/fixtures/xml/amazon/tracking_response_1.xml +0 -56
- data/test/fixtures/xml/amazon/tracking_response_2.xml +0 -38
- data/test/fixtures/xml/amazon/tracking_response_error.xml +0 -13
- data/test/fixtures/xml/amazon/tracking_response_not_found.xml +0 -13
- data/test/fixtures/xml/amazon_mws/fulfillment_get_fulfillment_order.xml +0 -114
- data/test/fixtures/xml/amazon_mws/fulfillment_get_fulfillment_order_2.xml +0 -90
- data/test/fixtures/xml/amazon_mws/fulfillment_get_fullfillment_order_with_multiple_tracking_numbers.xml +0 -121
- data/test/fixtures/xml/amazon_mws/fulfillment_list_all_fulfillment_orders.xml +0 -70
- data/test/fixtures/xml/amazon_mws/inventory_list_inventory_item_supply.xml +0 -32
- data/test/fixtures/xml/amazon_mws/inventory_list_inventory_supply.xml +0 -75
- data/test/fixtures/xml/amazon_mws/inventory_list_inventory_supply_by_next_token.xml +0 -38
- data/test/fixtures/xml/amazon_mws/tracking_response_error.xml +0 -9
- data/test/fixtures/xml/amazon_mws/tracking_response_not_found.xml +0 -9
- data/test/fixtures/xml/shipwire/fulfillment_failure_response.xml +0 -7
- data/test/fixtures/xml/shipwire/invalid_login_response.xml +0 -7
- data/test/fixtures/xml/shipwire/inventory_get_response.xml +0 -44
- data/test/fixtures/xml/shipwire/successful_empty_tracking_response.xml +0 -8
- data/test/fixtures/xml/shipwire/successful_live_tracking_response.xml +0 -53
- data/test/fixtures/xml/shipwire/successful_tracking_response.xml +0 -16
- data/test/fixtures/xml/shipwire/successful_tracking_response_with_tracking_urls.xml +0 -31
- data/test/fixtures/xml/webgistix/multiple_tracking_response.xml +0 -21
- data/test/fixtures/xml/webgistix/tracking_response.xml +0 -14
- data/test/remote/amazon_test.rb +0 -124
- data/test/unit/services/amazon_test.rb +0 -271
@@ -1,16 +0,0 @@
|
|
1
|
-
<?xml version="1.0"?>
|
2
|
-
<TrackingUpdateResponse>
|
3
|
-
<Status>Test</Status>
|
4
|
-
<Order id="2986" shipped="YES" shipper="UPS GD" handling="1.00" shipping="13.66" total="14.66">
|
5
|
-
<TrackingNumber>1ZW682E90326614239</TrackingNumber>
|
6
|
-
</Order>
|
7
|
-
<Order id="2987" shipped="YES" shipper="UPS GD" handling="1.50" shipping="9.37" total="10.87">
|
8
|
-
<TrackingNumber>1ZW682E90326795080</TrackingNumber>
|
9
|
-
</Order>
|
10
|
-
<Order id="2988" shipped="NO" shipper="UPS GD" handling="" shipping="" total="">
|
11
|
-
<TrackingNumber></TrackingNumber>
|
12
|
-
</Order>
|
13
|
-
<TotalOrders>3</TotalOrders>
|
14
|
-
<TotalShippedOrders>2</TotalShippedOrders>
|
15
|
-
<Bookmark>2006-04-28 20:35:45</Bookmark>
|
16
|
-
</TrackingUpdateResponse>
|
@@ -1,31 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<TrackingUpdateResponse>
|
3
|
-
<Status>Test</Status>
|
4
|
-
<Order id="40298"
|
5
|
-
shipwireId="1234567890-1234569-1"
|
6
|
-
warehouse="Chicago"
|
7
|
-
shipped="YES"
|
8
|
-
shipper="USPS FC"
|
9
|
-
shipperFullName="USPS First-Class Mail Parcel + Delivery Confirmation"
|
10
|
-
shipDate="2011-04-08 09:33:10"
|
11
|
-
delivered="NO"
|
12
|
-
expectedDeliveryDate="2011-04-15 00:00:00"
|
13
|
-
handling="0.00"
|
14
|
-
shipping="4.47"
|
15
|
-
packaging="0.00"
|
16
|
-
total="4.47"
|
17
|
-
returned="NO"
|
18
|
-
href="https://app.shipwire.com/c/t/xxx1:yyy3"
|
19
|
-
affiliateStatus="shipwireFulfilled"
|
20
|
-
manuallyEdited="NO">
|
21
|
-
<TrackingNumber carrier="USPS"
|
22
|
-
delivered="NO"
|
23
|
-
href="http://trkcnfrm1.smi.usps.com/PTSInternetWeb/InterLabelInquiry.do?origTrackNum=9400110200793596422990">
|
24
|
-
9400110200793596422990</TrackingNumber>
|
25
|
-
</Order>
|
26
|
-
<TotalOrders>1</TotalOrders>
|
27
|
-
<TotalShippedOrders>1</TotalShippedOrders>
|
28
|
-
<TotalProducts>8</TotalProducts>
|
29
|
-
<Bookmark>2011-10-22 14:13:16</Bookmark>
|
30
|
-
<ProcessingTime units="ms">1192</ProcessingTime>
|
31
|
-
</TrackingUpdateResponse>
|
@@ -1,21 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<Orders>
|
3
|
-
<Shipment>
|
4
|
-
<InvoiceNumber>#8305090.1</InvoiceNumber>
|
5
|
-
<WebgistixOrderNumber>1234512</WebgistixOrderNumber>
|
6
|
-
<Method>FedEx Home Delivery</Method>
|
7
|
-
<DateShipped>2012-12-10 04:55:00 PM</DateShipped>
|
8
|
-
<ShipmentTrackingNumber>345678070437428</ShipmentTrackingNumber>
|
9
|
-
<ShippingCost>12.5000</ShippingCost>
|
10
|
-
<WeightInPounds>7.1</WeightInPounds>
|
11
|
-
</Shipment>
|
12
|
-
<Shipment>
|
13
|
-
<InvoiceNumber>#8305090.1</InvoiceNumber>
|
14
|
-
<WebgistixOrderNumber>1234513</WebgistixOrderNumber>
|
15
|
-
<Method>FedEx 2Day</Method>
|
16
|
-
<DateShipped>2012-12-11 10:12:00 AM</DateShipped>
|
17
|
-
<ShipmentTrackingNumber>546932544227</ShipmentTrackingNumber>
|
18
|
-
<ShippingCost>23.2800</ShippingCost>
|
19
|
-
<WeightInPounds>0.71</WeightInPounds>
|
20
|
-
</Shipment>
|
21
|
-
</Orders>
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<Orders>
|
3
|
-
<Shipment>
|
4
|
-
<InvoiceNumber>AB12345</InvoiceNumber>
|
5
|
-
<WebgistixOrderNumber>67891</WebgistixOrderNumber>
|
6
|
-
<Method>UPS Ground</Method>
|
7
|
-
<DateShipped>10/25/2009</DateShipped>
|
8
|
-
<ShipmentTrackingNumber>1Z8E5A380396682872</ShipmentTrackingNumber>
|
9
|
-
</Shipment>
|
10
|
-
<Shipment>
|
11
|
-
<InvoiceNumber>XY4567</InvoiceNumber>
|
12
|
-
<ShipmentTrackingNumber>Not Shipped</ShipmentTrackingNumber>
|
13
|
-
</Shipment>
|
14
|
-
</Orders>
|
data/test/remote/amazon_test.rb
DELETED
@@ -1,124 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class RemoteAmazonTest < Test::Unit::TestCase
|
4
|
-
# In order for these tests to work you must have a live account with Amazon.
|
5
|
-
# You can sign up at http://amazonservices.com/fulfillment/
|
6
|
-
# The SKUs must also exist in your inventory. You do not want the SKUs you
|
7
|
-
# use for testing to actually have inventory in the Amazon warehouse, or else
|
8
|
-
# the shipments will actually be fulfillable
|
9
|
-
def setup
|
10
|
-
@service = AmazonService.new( fixtures(:amazon) )
|
11
|
-
|
12
|
-
@options = {
|
13
|
-
:shipping_method => 'Standard',
|
14
|
-
:order_date => Time.now.utc.yesterday,
|
15
|
-
:comment => "Delayed due to tornados"
|
16
|
-
}
|
17
|
-
|
18
|
-
@address = { :name => 'Johnny Chase',
|
19
|
-
:address1 => '100 Information Super Highway',
|
20
|
-
:address2 => 'Suite 66',
|
21
|
-
:city => 'Beverly Hills',
|
22
|
-
:state => 'CA',
|
23
|
-
:country => 'US',
|
24
|
-
:zip => '90210'
|
25
|
-
}
|
26
|
-
|
27
|
-
@line_items = [
|
28
|
-
{ :sku => 'SETTLERS8',
|
29
|
-
:quantity => 1 #,
|
30
|
-
#:comment => 'Awesome'
|
31
|
-
}
|
32
|
-
]
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_successful_order_submission
|
36
|
-
response = @service.fulfill(ActiveMerchant::Utils.generate_unique_id, @address, @line_items, @options)
|
37
|
-
assert response.success?
|
38
|
-
assert !response.test?
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_order_multiple_line_items
|
42
|
-
@line_items.push(
|
43
|
-
{ :sku => 'CARCASSONNE',
|
44
|
-
:quantity => 2
|
45
|
-
}
|
46
|
-
)
|
47
|
-
|
48
|
-
response = @service.fulfill(ActiveMerchant::Utils.generate_unique_id, @address, @line_items, @options)
|
49
|
-
assert response.success?
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_invalid_credentials_during_fulfillment
|
53
|
-
service = AmazonService.new(
|
54
|
-
:login => 'y',
|
55
|
-
:password => 'p')
|
56
|
-
|
57
|
-
response = service.fulfill(ActiveMerchant::Utils.generate_unique_id, @address, @line_items, @options)
|
58
|
-
assert !response.success?
|
59
|
-
assert_equal "aws:Client.InvalidClientTokenId The AWS Access Key Id you provided does not exist in our records.", response.message
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_list_orders
|
63
|
-
response = @service.fetch_current_orders
|
64
|
-
assert response.success?
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_get_inventory
|
68
|
-
response = @service.fetch_stock_levels(:sku => '2R-JAXZ-P0IB')
|
69
|
-
assert response.success?
|
70
|
-
assert_equal 0, response.stock_levels['2R-JAXZ-P0IB']
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_list_inventory
|
74
|
-
response = @service.fetch_stock_levels(:start_time => 1.year.ago)
|
75
|
-
assert response.success?
|
76
|
-
assert_equal 0, response.stock_levels['SETTLERS']
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_fetch_tracking_data
|
80
|
-
response = @service.fetch_tracking_data(['123456']) # an actual order
|
81
|
-
assert response.success?
|
82
|
-
assert_equal Hash.new, response.tracking_numbers # no tracking numbers in testing
|
83
|
-
assert_equal Hash.new, response.tracking_companies
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_fetch_tracking_numbers
|
87
|
-
response = @service.fetch_tracking_numbers(['123456']) # an actual order
|
88
|
-
assert response.success?
|
89
|
-
assert_equal Hash.new, response.tracking_numbers # no tracking numbers in testing
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_fetch_tracking_numbers_ignores_not_found
|
93
|
-
response = @service.fetch_tracking_numbers(['#1337-1'])
|
94
|
-
assert response.success?
|
95
|
-
assert_equal Hash.new, response.tracking_numbers
|
96
|
-
end
|
97
|
-
|
98
|
-
def test_valid_credentials
|
99
|
-
assert @service.valid_credentials?
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_invalid_credentials
|
103
|
-
service = AmazonService.new(
|
104
|
-
:login => 'your@email.com',
|
105
|
-
:password => 'password')
|
106
|
-
assert !service.valid_credentials?
|
107
|
-
end
|
108
|
-
|
109
|
-
def test_get_status_fails
|
110
|
-
service = AmazonService.new(
|
111
|
-
:login => 'your@email.com',
|
112
|
-
:password => 'password')
|
113
|
-
response = service.status
|
114
|
-
assert !response.success?
|
115
|
-
assert_equal "aws:Client.InvalidClientTokenId The AWS Access Key Id you provided does not exist in our records.", response.message
|
116
|
-
end
|
117
|
-
|
118
|
-
def test_get_status
|
119
|
-
service = AmazonService.new(fixtures(:amazon))
|
120
|
-
response = service.status
|
121
|
-
assert response.success?
|
122
|
-
end
|
123
|
-
|
124
|
-
end
|
@@ -1,271 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class AmazonTest < Test::Unit::TestCase
|
4
|
-
def setup
|
5
|
-
@service = AmazonService.new(
|
6
|
-
:login => 'l',
|
7
|
-
:password => 'p'
|
8
|
-
)
|
9
|
-
|
10
|
-
@options = {
|
11
|
-
:shipping_method => 'Standard',
|
12
|
-
:order_date => Time.now.utc.yesterday,
|
13
|
-
:comment => "Delayed due to tornados"
|
14
|
-
}
|
15
|
-
|
16
|
-
@address = { :name => 'Johnny Chase',
|
17
|
-
:address1 => '100 Information Super Highway',
|
18
|
-
:address2 => 'Suite 66',
|
19
|
-
:city => 'Beverly Hills',
|
20
|
-
:state => 'CA',
|
21
|
-
:country => 'US',
|
22
|
-
:zip => '90210'
|
23
|
-
}
|
24
|
-
|
25
|
-
@line_items = [
|
26
|
-
{ :sku => 'SETTLERS1',
|
27
|
-
:quantity => 1,
|
28
|
-
:comment => 'Awesome'
|
29
|
-
}
|
30
|
-
]
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_successful_fulfillment
|
34
|
-
@service.expects(:ssl_post).returns(successful_fulfillment_response)
|
35
|
-
response = @service.fulfill('12345678', @address, @line_items, @options)
|
36
|
-
assert response.success?
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_invalid_arguments
|
40
|
-
http_response = build_mock_response(invalid_create_response, "", "500")
|
41
|
-
@service.expects(:ssl_post).raises(ActiveMerchant::ResponseError.new(http_response))
|
42
|
-
response = @service.fulfill('12345678', @address, @line_items, @options)
|
43
|
-
assert !response.success?
|
44
|
-
assert_equal "aws:Client.MissingParameter The request must contain the parameter Item.", response.params['response_comment']
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_missing_order_comment
|
48
|
-
@options.delete(:comment)
|
49
|
-
assert_raise(ArgumentError) { @service.fulfill('12345678', @address, @line_items, @options) }
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_missing_order_date
|
53
|
-
@options.delete(:order_date)
|
54
|
-
assert_raise(ArgumentError) { @service.fulfill('12345678', @address, @line_items, @options) }
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_missing_shipping_method
|
58
|
-
@options.delete(:shipping_method)
|
59
|
-
assert_raise(ArgumentError) { @service.fulfill('12345678', @address, @line_items, @options) }
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_get_inventory
|
63
|
-
@service.expects(:ssl_post).returns(xml_fixture('amazon/inventory_get_response'))
|
64
|
-
|
65
|
-
response = @service.fetch_stock_levels(:sku => '2R-JAXZ-P0IB')
|
66
|
-
assert response.success?
|
67
|
-
assert_equal 142, response.stock_levels['2R-JAXZ-P0IB']
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_list_inventory
|
71
|
-
@service.expects(:ssl_post).returns(xml_fixture('amazon/inventory_list_response'))
|
72
|
-
|
73
|
-
response = @service.fetch_stock_levels
|
74
|
-
assert response.success?
|
75
|
-
assert_equal 202, response.stock_levels['GN-00-01A']
|
76
|
-
assert_equal 199, response.stock_levels['GN-00-02A']
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_list_inventory_multipage
|
80
|
-
@service.expects(:ssl_post).twice.returns(
|
81
|
-
xml_fixture('amazon/inventory_list_response_with_next_1'),
|
82
|
-
xml_fixture('amazon/inventory_list_response_with_next_2')
|
83
|
-
)
|
84
|
-
|
85
|
-
response = @service.fetch_stock_levels
|
86
|
-
assert response.success?
|
87
|
-
assert_equal 42, response.stock_levels['GN-01-01A']
|
88
|
-
assert_equal 80, response.stock_levels['GN-01-02A']
|
89
|
-
assert_equal 123, response.stock_levels['GN-02-01A']
|
90
|
-
assert_equal 555, response.stock_levels['GN-02-02A']
|
91
|
-
end
|
92
|
-
|
93
|
-
def test_fetch_tracking_numbers
|
94
|
-
@service.expects(:ssl_post).twice.returns(
|
95
|
-
xml_fixture('amazon/tracking_response_1'),
|
96
|
-
xml_fixture('amazon/tracking_response_2')
|
97
|
-
)
|
98
|
-
|
99
|
-
response = @service.fetch_tracking_numbers(['TEST-00000001', 'TEST-00000002'])
|
100
|
-
assert response.success?
|
101
|
-
assert_equal %w{UPS00000001}, response.tracking_numbers['TEST-00000001']
|
102
|
-
assert_nil response.tracking_numbers['TEST-00000002']
|
103
|
-
end
|
104
|
-
|
105
|
-
def test_fetch_tracking_numbers_ignores_not_found
|
106
|
-
response = mock('response')
|
107
|
-
response.stubs(:code).returns(500)
|
108
|
-
response.stubs(:message).returns('Internal Server Error')
|
109
|
-
response.stubs(:body).returns(xml_fixture('amazon/tracking_response_not_found'))
|
110
|
-
|
111
|
-
@service.expects(:ssl_post).times(3).
|
112
|
-
returns(xml_fixture('amazon/tracking_response_1')).
|
113
|
-
raises(ActiveMerchant::ResponseError.new(response)).
|
114
|
-
returns(xml_fixture('amazon/tracking_response_2'))
|
115
|
-
|
116
|
-
response = @service.fetch_tracking_numbers(['TEST-00000001', '#1337-1', 'TEST-00000002'])
|
117
|
-
assert response.success?
|
118
|
-
assert_equal %w{UPS00000001}, response.tracking_numbers['TEST-00000001']
|
119
|
-
end
|
120
|
-
|
121
|
-
def test_fetch_tracking_numbers_aborts_on_error
|
122
|
-
response = mock('response')
|
123
|
-
response.stubs(:code).returns(500)
|
124
|
-
response.stubs(:message).returns('Internal Server Error')
|
125
|
-
response.stubs(:body).returns(xml_fixture('amazon/tracking_response_error'))
|
126
|
-
|
127
|
-
@service.expects(:ssl_post).twice.
|
128
|
-
returns(xml_fixture('amazon/tracking_response_1')).
|
129
|
-
raises(ActiveMerchant::ResponseError.new(response))
|
130
|
-
|
131
|
-
response = @service.fetch_tracking_numbers(['TEST-00000001', 'ERROR', 'TEST-00000002'])
|
132
|
-
assert !response.success?
|
133
|
-
assert_equal 'Something bad happened!', response.faultstring
|
134
|
-
end
|
135
|
-
|
136
|
-
def test_fetch_tracking_data
|
137
|
-
@service.expects(:ssl_post).returns(xml_fixture('amazon/tracking_response_1'))
|
138
|
-
|
139
|
-
response = @service.fetch_tracking_data(['TEST-00000001'])
|
140
|
-
assert response.success?
|
141
|
-
assert_equal %w{UPS00000001}, response.tracking_numbers['TEST-00000001']
|
142
|
-
assert_equal %W{UPS}, response.tracking_companies['TEST-00000001']
|
143
|
-
assert_equal({}, response.tracking_urls)
|
144
|
-
end
|
145
|
-
|
146
|
-
def test_404_error
|
147
|
-
http_response = build_mock_response(response_from_404, "Not Found", "404")
|
148
|
-
@service.expects(:ssl_post).raises(ActiveMerchant::ResponseError.new(http_response))
|
149
|
-
|
150
|
-
response = @service.fulfill('12345678', @address, @line_items, @options)
|
151
|
-
assert !response.success?
|
152
|
-
assert_equal "404: Not Found", response.message
|
153
|
-
assert_equal "404", response.params["http_code"]
|
154
|
-
assert_equal "Not Found", response.params["http_message"]
|
155
|
-
assert_equal response_from_404, response.params["http_body"]
|
156
|
-
end
|
157
|
-
|
158
|
-
def test_soap_fault
|
159
|
-
http_response = build_mock_response(invalid_create_response, "500", "")
|
160
|
-
@service.expects(:ssl_post).raises(ActiveMerchant::ResponseError.new(http_response))
|
161
|
-
|
162
|
-
response = @service.fulfill('12345678', @address, @line_items, @options)
|
163
|
-
assert !response.success?
|
164
|
-
assert_equal 'aws:Client.MissingParameter', response.params['faultcode']
|
165
|
-
assert_equal 'The request must contain the parameter Item.', response.params['faultstring']
|
166
|
-
assert_equal 'aws:Client.MissingParameter The request must contain the parameter Item.', response.message
|
167
|
-
end
|
168
|
-
|
169
|
-
def test_valid_credentials
|
170
|
-
@service.expects(:ssl_post).returns(successful_status_response)
|
171
|
-
assert @service.valid_credentials?
|
172
|
-
end
|
173
|
-
|
174
|
-
def test_invalid_credentials
|
175
|
-
http_response = build_mock_response(invalid_login_response, "500", "")
|
176
|
-
@service.expects(:ssl_post).raises(ActiveMerchant::ResponseError.new(http_response))
|
177
|
-
assert !@service.valid_credentials?
|
178
|
-
end
|
179
|
-
|
180
|
-
def test_successful_service_status
|
181
|
-
@service.expects(:ssl_request).returns(successful_status_response)
|
182
|
-
|
183
|
-
response = @service.status
|
184
|
-
assert response.success?
|
185
|
-
end
|
186
|
-
|
187
|
-
private
|
188
|
-
|
189
|
-
def build_mock_response(response, message, code = "200")
|
190
|
-
http_response = mock(:code => code, :message => message)
|
191
|
-
http_response.stubs(:body).returns(response)
|
192
|
-
http_response
|
193
|
-
end
|
194
|
-
|
195
|
-
def response_for_empty_request
|
196
|
-
'<ns:GetErrorResponse xmlns:ns="http://xino.amazonaws.com/doc/"><ns:Error><ns:Code>MissingDateHeader</ns:Code><ns:Message>Authorized request must have a "date" or "x-amz-date" header.</ns:Message></ns:Error><ns:RequestID>79ceaffe-e5a3-46a5-b36a-9ce958d68939</ns:RequestID></ns:GetErrorResponse>'
|
197
|
-
end
|
198
|
-
|
199
|
-
|
200
|
-
def invalid_login_response
|
201
|
-
<<-XML
|
202
|
-
<?xml version="1.0"?>
|
203
|
-
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:aws="http://webservices.amazon.com/AWSFault/2005-15-09">
|
204
|
-
<env:Body>
|
205
|
-
<env:Fault>
|
206
|
-
<faultcode>aws:Client.InvalidClientTokenId</faultcode>
|
207
|
-
<faultstring>The AWS Access Key Id you provided does not exist in our records.</faultstring>
|
208
|
-
<detail>
|
209
|
-
<aws:RequestId xmlns:aws="http://webservices.amazon.com/AWSFault/2005-15-09">51de28ce-c380-46c4-bf95-62bbf8cc4682</aws:RequestId>
|
210
|
-
</detail>
|
211
|
-
</env:Fault>
|
212
|
-
</env:Body>
|
213
|
-
</env:Envelope>
|
214
|
-
XML
|
215
|
-
end
|
216
|
-
|
217
|
-
def invalid_create_response
|
218
|
-
<<-XML
|
219
|
-
<?xml version="1.0"?>
|
220
|
-
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:aws="http://webservices.amazon.com/AWSFault/2005-15-09">
|
221
|
-
<env:Body>
|
222
|
-
<env:Fault>
|
223
|
-
<faultcode>aws:Client.MissingParameter</faultcode>
|
224
|
-
<faultstring>The request must contain the parameter Item.</faultstring>
|
225
|
-
<detail>
|
226
|
-
<aws:RequestId xmlns:aws="http://webservices.amazon.com/AWSFault/2005-15-09">edc852d3-937f-40f5-9d72-97b7da897b38</aws:RequestId>
|
227
|
-
</detail>
|
228
|
-
</env:Fault>
|
229
|
-
</env:Body>
|
230
|
-
</env:Envelope>
|
231
|
-
XML
|
232
|
-
end
|
233
|
-
|
234
|
-
def response_from_404
|
235
|
-
'<html><head><title>Apache Tomcat/5.5.9 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 404 - Servlet XinoServlet is not available</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>Servlet XinoServlet is not available</u></p><p><b>description</b> <u>The requested resource (Servlet XinoServlet is not available) is not available.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/5.5.9</h3></body></html>'
|
236
|
-
end
|
237
|
-
|
238
|
-
def successful_fulfillment_response
|
239
|
-
<<-XML
|
240
|
-
<?xml version="1.0"?>
|
241
|
-
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
|
242
|
-
<env:Body>
|
243
|
-
<ns1:CreateFulfillmentOrderResponse xmlns:ns1="http://fba-outbound.amazonaws.com/doc/2007-08-02/">
|
244
|
-
<ns1:ResponseMetadata>
|
245
|
-
<ns1:RequestId>ccd0116d-a476-48ac-810e-778eebe5e5e2</ns1:RequestId>
|
246
|
-
</ns1:ResponseMetadata>
|
247
|
-
</ns1:CreateFulfillmentOrderResponse>
|
248
|
-
</env:Body>
|
249
|
-
</env:Envelope>
|
250
|
-
XML
|
251
|
-
end
|
252
|
-
|
253
|
-
|
254
|
-
def successful_status_response
|
255
|
-
<<-XML
|
256
|
-
<?xml version="1.0"?>
|
257
|
-
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
|
258
|
-
<env:Body>
|
259
|
-
<ns1:GetServiceStatusResponse xmlns:ns1="http://fba-outbound.amazonaws.com/doc/2007-08-02/">
|
260
|
-
<ns1:GetServiceStatusResult>
|
261
|
-
<ns1:Status>2009-06-05T18:36:19Z service available [Version: 2007-08-02]</ns1:Status>
|
262
|
-
</ns1:GetServiceStatusResult>
|
263
|
-
<ns1:ResponseMetadata>
|
264
|
-
<ns1:RequestId>1e04fabc-fbaa-4ae5-836a-f0c60f1d301a</ns1:RequestId>
|
265
|
-
</ns1:ResponseMetadata>
|
266
|
-
</ns1:GetServiceStatusResponse>
|
267
|
-
</env:Body>
|
268
|
-
</env:Envelope>
|
269
|
-
XML
|
270
|
-
end
|
271
|
-
end
|