active_fulfillment 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +26 -0
- data/Rakefile +60 -0
- data/VERSION +1 -0
- data/active_fulfillment.gemspec +74 -0
- data/init.rb +1 -0
- data/lib/active_fulfillment/fulfillment/base.rb +12 -0
- data/lib/active_fulfillment/fulfillment/response.rb +32 -0
- data/lib/active_fulfillment/fulfillment/service.rb +31 -0
- data/lib/active_fulfillment/fulfillment/services/amazon.rb +230 -0
- data/lib/active_fulfillment/fulfillment/services/shipwire.rb +236 -0
- data/lib/active_fulfillment/fulfillment/services/webgistix.rb +207 -0
- data/lib/active_fulfillment/fulfillment/services.rb +3 -0
- data/lib/active_fulfillment.rb +50 -0
- data/lib/active_merchant/common/connection.rb +172 -0
- data/lib/active_merchant/common/country.rb +319 -0
- data/lib/active_merchant/common/error.rb +26 -0
- data/lib/active_merchant/common/post_data.rb +24 -0
- data/lib/active_merchant/common/posts_data.rb +47 -0
- data/lib/active_merchant/common/requires_parameters.rb +16 -0
- data/lib/active_merchant/common/utils.rb +18 -0
- data/lib/active_merchant/common/validateable.rb +76 -0
- data/lib/active_merchant/common.rb +14 -0
- data/lib/certs/cacert.pem +7815 -0
- data/test/fixtures.yml +11 -0
- data/test/remote/amazon_test.rb +93 -0
- data/test/remote/shipwire_test.rb +145 -0
- data/test/remote/webgistix_test.rb +80 -0
- data/test/test_helper.rb +60 -0
- data/test/unit/base_test.rb +17 -0
- data/test/unit/services/amazon_test.rb +187 -0
- data/test/unit/services/shipwire_test.rb +164 -0
- data/test/unit/services/webgistix_test.rb +145 -0
- metadata +106 -0
data/test/fixtures.yml
ADDED
@@ -0,0 +1,93 @@
|
|
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(generate_order_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(generate_order_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(generate_order_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_valid_credentials
|
68
|
+
assert @service.valid_credentials?
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_invalid_credentials
|
72
|
+
service = AmazonService.new(
|
73
|
+
:login => 'your@email.com',
|
74
|
+
:password => 'password')
|
75
|
+
assert !service.valid_credentials?
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_get_status_fails
|
79
|
+
service = AmazonService.new(
|
80
|
+
:login => 'your@email.com',
|
81
|
+
:password => 'password')
|
82
|
+
response = service.status
|
83
|
+
assert !response.success?
|
84
|
+
assert_equal "aws:Client.InvalidClientTokenId The AWS Access Key Id you provided does not exist in our records.", response.message
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_get_status
|
88
|
+
service = AmazonService.new(fixtures(:amazon))
|
89
|
+
response = service.status
|
90
|
+
assert response.success?
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RemoteShipwireTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Base.mode = :test
|
6
|
+
|
7
|
+
@shipwire = ShipwireService.new( fixtures(:shipwire) )
|
8
|
+
|
9
|
+
@options = {
|
10
|
+
:warehouse => 'LAX',
|
11
|
+
:shipping_method => 'UPS Ground',
|
12
|
+
:email => 'cody@example.com'
|
13
|
+
}
|
14
|
+
|
15
|
+
@us_address = {
|
16
|
+
:name => 'Steve Jobs',
|
17
|
+
:company => 'Apple Computer Inc.',
|
18
|
+
:address1 => '1 Infinite Loop',
|
19
|
+
:city => 'Cupertino',
|
20
|
+
:state => 'CA',
|
21
|
+
:country => 'US',
|
22
|
+
:zip => '95014',
|
23
|
+
:email => 'steve@apple.com'
|
24
|
+
}
|
25
|
+
|
26
|
+
@uk_address = {
|
27
|
+
:name => 'Bob Diamond',
|
28
|
+
:company => 'Barclays Bank PLC',
|
29
|
+
:address1 => '1 Churchill Place',
|
30
|
+
:city => 'London',
|
31
|
+
:country => 'GB',
|
32
|
+
:zip => 'E14 5HP',
|
33
|
+
:email => 'bob@barclays.co.uk'
|
34
|
+
}
|
35
|
+
|
36
|
+
@line_items = [ { :sku => 'AF0001', :quantity => 25 } ]
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_invalid_credentials_during_fulfillment
|
40
|
+
shipwire = ShipwireService.new(
|
41
|
+
:login => 'your@email.com',
|
42
|
+
:password => 'password')
|
43
|
+
|
44
|
+
response = shipwire.fulfill('123456', @us_address, @line_items, @options)
|
45
|
+
assert !response.success?
|
46
|
+
assert response.test?
|
47
|
+
assert_equal 'Error', response.params['status']
|
48
|
+
assert_equal "Could not verify e-mail/password combination", response.message
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_successful_order_submission_to_us
|
52
|
+
response = @shipwire.fulfill('123456', @us_address, @line_items, @options)
|
53
|
+
assert response.success?
|
54
|
+
assert response.test?
|
55
|
+
assert response.params['transaction_id']
|
56
|
+
assert_equal '1', response.params['total_orders']
|
57
|
+
assert_equal '1', response.params['total_items']
|
58
|
+
assert_equal '0', response.params['status']
|
59
|
+
assert_equal 'Successfully submitted the order', response.message
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_successful_order_submission_to_uk
|
63
|
+
response = @shipwire.fulfill('123456', @uk_address, @line_items, @options)
|
64
|
+
assert response.success?
|
65
|
+
assert response.test?
|
66
|
+
assert response.params['transaction_id']
|
67
|
+
assert_equal '1', response.params['total_orders']
|
68
|
+
assert_equal '1', response.params['total_items']
|
69
|
+
assert_equal '0', response.params['status']
|
70
|
+
assert_equal 'Successfully submitted the order', response.message
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_order_multiple_line_items
|
74
|
+
@line_items.push({ :sku => 'AF0002', :quantity => 25 })
|
75
|
+
|
76
|
+
response = @shipwire.fulfill('123456', @us_address, @line_items, @options)
|
77
|
+
assert response.success?
|
78
|
+
assert response.test?
|
79
|
+
assert response.params['transaction_id']
|
80
|
+
assert_equal '1', response.params['total_orders']
|
81
|
+
assert_equal '2', response.params['total_items']
|
82
|
+
assert_equal '0', response.params['status']
|
83
|
+
assert_equal 'Successfully submitted the order', response.message
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_no_sku_is_sent_with_fulfillment
|
87
|
+
options = {
|
88
|
+
:shipping_method => 'UPS Ground'
|
89
|
+
}
|
90
|
+
|
91
|
+
line_items = [ { :quantity => 1, :description => 'Libtech Snowboard' } ]
|
92
|
+
|
93
|
+
response = @shipwire.fulfill('123456', @us_address, line_items, options)
|
94
|
+
|
95
|
+
assert response.success?
|
96
|
+
assert response.test?
|
97
|
+
assert_not_nil response.params['transaction_id']
|
98
|
+
assert_equal "1", response.params['total_orders']
|
99
|
+
assert_equal "0", response.params['total_items']
|
100
|
+
assert_equal "0", response.params['status']
|
101
|
+
assert_equal 'Successfully submitted the order', response.message
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_invalid_credentials_during_inventory
|
105
|
+
shipwire = ShipwireService.new(
|
106
|
+
:login => 'your@email.com',
|
107
|
+
:password => 'password'
|
108
|
+
)
|
109
|
+
|
110
|
+
response = shipwire.fetch_stock_levels
|
111
|
+
|
112
|
+
assert !response.success?
|
113
|
+
assert response.test?
|
114
|
+
assert_equal 'Error', response.params['status']
|
115
|
+
assert_equal "Error with EmailAddress, valid email is required. There is an error in XML document.", response.message
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_get_inventory
|
119
|
+
response = @shipwire.fetch_stock_levels
|
120
|
+
assert response.success?
|
121
|
+
assert response.test?
|
122
|
+
assert_equal 14, response.stock_levels["GD802-024"]
|
123
|
+
assert_equal 32, response.stock_levels["GD201-500"]
|
124
|
+
assert_equal "2", response.params["total_products"]
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_fetch_tracking_numbers
|
128
|
+
response = @shipwire.fetch_tracking_numbers
|
129
|
+
assert response.success?
|
130
|
+
assert response.test?
|
131
|
+
assert_equal Hash.new, response.tracking_numbers
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_valid_credentials
|
135
|
+
assert @shipwire.valid_credentials?
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_invalid_credentials
|
139
|
+
service = ShipwireService.new(
|
140
|
+
:login => 'your@email.com',
|
141
|
+
:password => 'password'
|
142
|
+
)
|
143
|
+
assert !service.valid_credentials?
|
144
|
+
end
|
145
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RemoteWebgistixTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Base.mode = :test
|
6
|
+
|
7
|
+
@service = WebgistixService.new( fixtures(:webgistix) )
|
8
|
+
|
9
|
+
@options = {
|
10
|
+
:shipping_method => 'Ground',
|
11
|
+
:email => 'buyer@jadedpallet.com'
|
12
|
+
}
|
13
|
+
|
14
|
+
@address = { :name => 'Fred Brooks',
|
15
|
+
:address1 => '1234 Penny Lane',
|
16
|
+
:city => 'Jonsetown',
|
17
|
+
:state => 'NC',
|
18
|
+
:country => 'US',
|
19
|
+
:zip => '23456'
|
20
|
+
}
|
21
|
+
|
22
|
+
@line_items = [
|
23
|
+
{ :sku => 'WX-01-4001',
|
24
|
+
:quantity => 2
|
25
|
+
}
|
26
|
+
]
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_successful_order_submission
|
31
|
+
response = @service.fulfill('123456', @address, @line_items, @options)
|
32
|
+
assert response.success?
|
33
|
+
assert response.test?
|
34
|
+
assert_equal WebgistixService::SUCCESS_MESSAGE, response.message
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_order_multiple_line_items
|
38
|
+
@line_items.push(
|
39
|
+
{ :sku => 'WX-01-1020',
|
40
|
+
:quantity => 3
|
41
|
+
}
|
42
|
+
)
|
43
|
+
|
44
|
+
response = @service.fulfill('123456', @address, @line_items, @options)
|
45
|
+
assert response.success?
|
46
|
+
assert response.test?
|
47
|
+
assert_equal WebgistixService::SUCCESS_MESSAGE, response.message
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_invalid_sku_during_fulfillment
|
51
|
+
line_items = [ { :sku => 'invalid', :quantity => 1 } ]
|
52
|
+
response = @service.fulfill('123456', @address, line_items, @options)
|
53
|
+
assert !response.success?
|
54
|
+
assert response.test?
|
55
|
+
assert_equal WebgistixService::FAILURE_MESSAGE, response.message
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_invalid_credentials_during_fulfillment
|
59
|
+
service = WebgistixService.new(
|
60
|
+
:login => 'your@email.com',
|
61
|
+
:password => 'password')
|
62
|
+
|
63
|
+
response = service.fulfill('123456', @address, @line_items, @options)
|
64
|
+
assert !response.success?
|
65
|
+
assert response.test?
|
66
|
+
assert_equal "Access Denied", response.message
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_valid_credentials
|
70
|
+
assert @service.valid_credentials?
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_invalid_credentials
|
74
|
+
service = WebgistixService.new(
|
75
|
+
:login => 'your@email.com',
|
76
|
+
:password => 'password')
|
77
|
+
|
78
|
+
assert !service.valid_credentials?
|
79
|
+
end
|
80
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require 'digest/md5'
|
6
|
+
require 'active_fulfillment'
|
7
|
+
|
8
|
+
begin
|
9
|
+
require 'mocha'
|
10
|
+
rescue LoadError
|
11
|
+
require 'rubygems'
|
12
|
+
require 'mocha'
|
13
|
+
end
|
14
|
+
|
15
|
+
module Test
|
16
|
+
module Unit
|
17
|
+
class TestCase
|
18
|
+
include ActiveMerchant::Fulfillment
|
19
|
+
|
20
|
+
LOCAL_CREDENTIALS = ENV['HOME'] + '/.active_merchant/fixtures.yml' unless defined?(LOCAL_CREDENTIALS)
|
21
|
+
DEFAULT_CREDENTIALS = File.dirname(__FILE__) + '/fixtures.yml' unless defined?(DEFAULT_CREDENTIALS)
|
22
|
+
|
23
|
+
def generate_order_id
|
24
|
+
md5 = Digest::MD5.new
|
25
|
+
now = Time.now
|
26
|
+
md5 << now.to_s
|
27
|
+
md5 << String(now.usec)
|
28
|
+
md5 << String(rand(0))
|
29
|
+
md5 << String($$)
|
30
|
+
md5 << self.class.name
|
31
|
+
md5.hexdigest
|
32
|
+
end
|
33
|
+
|
34
|
+
def all_fixtures
|
35
|
+
@@fixtures ||= load_fixtures
|
36
|
+
end
|
37
|
+
|
38
|
+
def fixtures(key)
|
39
|
+
data = all_fixtures[key] || raise(StandardError, "No fixture data was found for '#{key}'")
|
40
|
+
|
41
|
+
data.dup
|
42
|
+
end
|
43
|
+
|
44
|
+
def load_fixtures
|
45
|
+
file = File.exists?(LOCAL_CREDENTIALS) ? LOCAL_CREDENTIALS : DEFAULT_CREDENTIALS
|
46
|
+
yaml_data = YAML.load(File.read(file))
|
47
|
+
symbolize_keys(yaml_data)
|
48
|
+
|
49
|
+
yaml_data
|
50
|
+
end
|
51
|
+
|
52
|
+
def symbolize_keys(hash)
|
53
|
+
return unless hash.is_a?(Hash)
|
54
|
+
|
55
|
+
hash.symbolize_keys!
|
56
|
+
hash.each{|k,v| symbolize_keys(v)}
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class BaseTest < Test::Unit::TestCase
|
4
|
+
include ActiveMerchant::Fulfillment
|
5
|
+
|
6
|
+
def test_get_shipwire_by_string
|
7
|
+
assert_equal ShipwireService, Base.service('shipwire')
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_get_shipwire_by_name
|
11
|
+
assert_equal ShipwireService, Base.service(:shipwire)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_get_unknown_service
|
15
|
+
assert_raise(NameError){ Base.service(:polar_north) }
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,187 @@
|
|
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_404_error
|
63
|
+
http_response = build_mock_response(response_from_404, "Not Found", "404")
|
64
|
+
@service.expects(:ssl_post).raises(ActiveMerchant::ResponseError.new(http_response))
|
65
|
+
|
66
|
+
response = @service.fulfill('12345678', @address, @line_items, @options)
|
67
|
+
assert !response.success?
|
68
|
+
assert_equal "404: Not Found", response.message
|
69
|
+
assert_equal "404", response.params["http_code"]
|
70
|
+
assert_equal "Not Found", response.params["http_message"]
|
71
|
+
assert_equal response_from_404, response.params["http_body"]
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_soap_fault
|
75
|
+
http_response = build_mock_response(invalid_create_response, "500", "")
|
76
|
+
@service.expects(:ssl_post).raises(ActiveMerchant::ResponseError.new(http_response))
|
77
|
+
|
78
|
+
response = @service.fulfill('12345678', @address, @line_items, @options)
|
79
|
+
assert !response.success?
|
80
|
+
assert_equal 'aws:Client.MissingParameter', response.params['faultcode']
|
81
|
+
assert_equal 'The request must contain the parameter Item.', response.params['faultstring']
|
82
|
+
assert_equal 'aws:Client.MissingParameter The request must contain the parameter Item.', response.message
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_valid_credentials
|
86
|
+
@service.expects(:ssl_post).returns(successful_status_response)
|
87
|
+
assert @service.valid_credentials?
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_invalid_credentials
|
91
|
+
http_response = build_mock_response(invalid_login_response, "500", "")
|
92
|
+
@service.expects(:ssl_post).raises(ActiveMerchant::ResponseError.new(http_response))
|
93
|
+
assert !@service.valid_credentials?
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_successful_service_status
|
97
|
+
@service.expects(:ssl_request).returns(successful_status_response)
|
98
|
+
|
99
|
+
response = @service.status
|
100
|
+
assert response.success?
|
101
|
+
end
|
102
|
+
|
103
|
+
private
|
104
|
+
|
105
|
+
def build_mock_response(response, message, code = "200")
|
106
|
+
http_response = mock(:code => code, :message => message)
|
107
|
+
http_response.stubs(:body).returns(response)
|
108
|
+
http_response
|
109
|
+
end
|
110
|
+
|
111
|
+
def response_for_empty_request
|
112
|
+
'<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>'
|
113
|
+
end
|
114
|
+
|
115
|
+
|
116
|
+
def invalid_login_response
|
117
|
+
<<-XML
|
118
|
+
<?xml version="1.0"?>
|
119
|
+
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:aws="http://webservices.amazon.com/AWSFault/2005-15-09">
|
120
|
+
<env:Body>
|
121
|
+
<env:Fault>
|
122
|
+
<faultcode>aws:Client.InvalidClientTokenId</faultcode>
|
123
|
+
<faultstring>The AWS Access Key Id you provided does not exist in our records.</faultstring>
|
124
|
+
<detail>
|
125
|
+
<aws:RequestId xmlns:aws="http://webservices.amazon.com/AWSFault/2005-15-09">51de28ce-c380-46c4-bf95-62bbf8cc4682</aws:RequestId>
|
126
|
+
</detail>
|
127
|
+
</env:Fault>
|
128
|
+
</env:Body>
|
129
|
+
</env:Envelope>
|
130
|
+
XML
|
131
|
+
end
|
132
|
+
|
133
|
+
def invalid_create_response
|
134
|
+
<<-XML
|
135
|
+
<?xml version="1.0"?>
|
136
|
+
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:aws="http://webservices.amazon.com/AWSFault/2005-15-09">
|
137
|
+
<env:Body>
|
138
|
+
<env:Fault>
|
139
|
+
<faultcode>aws:Client.MissingParameter</faultcode>
|
140
|
+
<faultstring>The request must contain the parameter Item.</faultstring>
|
141
|
+
<detail>
|
142
|
+
<aws:RequestId xmlns:aws="http://webservices.amazon.com/AWSFault/2005-15-09">edc852d3-937f-40f5-9d72-97b7da897b38</aws:RequestId>
|
143
|
+
</detail>
|
144
|
+
</env:Fault>
|
145
|
+
</env:Body>
|
146
|
+
</env:Envelope>
|
147
|
+
XML
|
148
|
+
end
|
149
|
+
|
150
|
+
def response_from_404
|
151
|
+
'<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>'
|
152
|
+
end
|
153
|
+
|
154
|
+
def successful_fulfillment_response
|
155
|
+
<<-XML
|
156
|
+
<?xml version="1.0"?>
|
157
|
+
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
|
158
|
+
<env:Body>
|
159
|
+
<ns1:CreateFulfillmentOrderResponse xmlns:ns1="http://fba-outbound.amazonaws.com/doc/2007-08-02/">
|
160
|
+
<ns1:ResponseMetadata>
|
161
|
+
<ns1:RequestId>ccd0116d-a476-48ac-810e-778eebe5e5e2</ns1:RequestId>
|
162
|
+
</ns1:ResponseMetadata>
|
163
|
+
</ns1:CreateFulfillmentOrderResponse>
|
164
|
+
</env:Body>
|
165
|
+
</env:Envelope>
|
166
|
+
XML
|
167
|
+
end
|
168
|
+
|
169
|
+
|
170
|
+
def successful_status_response
|
171
|
+
<<-XML
|
172
|
+
<?xml version="1.0"?>
|
173
|
+
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
|
174
|
+
<env:Body>
|
175
|
+
<ns1:GetServiceStatusResponse xmlns:ns1="http://fba-outbound.amazonaws.com/doc/2007-08-02/">
|
176
|
+
<ns1:GetServiceStatusResult>
|
177
|
+
<ns1:Status>2009-06-05T18:36:19Z service available [Version: 2007-08-02]</ns1:Status>
|
178
|
+
</ns1:GetServiceStatusResult>
|
179
|
+
<ns1:ResponseMetadata>
|
180
|
+
<ns1:RequestId>1e04fabc-fbaa-4ae5-836a-f0c60f1d301a</ns1:RequestId>
|
181
|
+
</ns1:ResponseMetadata>
|
182
|
+
</ns1:GetServiceStatusResponse>
|
183
|
+
</env:Body>
|
184
|
+
</env:Envelope>
|
185
|
+
XML
|
186
|
+
end
|
187
|
+
end
|