simple_aws 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.md +12 -0
- data/README.md +26 -26
- data/lib/{aws → simple_aws}/api.rb +4 -4
- data/lib/{aws → simple_aws}/auto_scaling.rb +6 -6
- data/lib/{aws → simple_aws}/call_types/action_param.rb +8 -8
- data/lib/{aws → simple_aws}/cloud_formation.rb +6 -6
- data/lib/{aws → simple_aws}/cloud_front.rb +17 -17
- data/lib/{aws → simple_aws}/cloud_watch.rb +6 -6
- data/lib/{aws → simple_aws}/core/connection.rb +4 -4
- data/lib/{aws → simple_aws}/core/request.rb +2 -2
- data/lib/{aws → simple_aws}/core/response.rb +4 -4
- data/lib/{aws → simple_aws}/core/util.rb +1 -1
- data/lib/{aws → simple_aws}/ec2.rb +6 -6
- data/lib/{aws → simple_aws}/elasti_cache.rb +6 -6
- data/lib/{aws → simple_aws}/elastic_beanstalk.rb +6 -6
- data/lib/{aws → simple_aws}/elb.rb +6 -6
- data/lib/{aws → simple_aws}/iam.rb +6 -6
- data/lib/{aws → simple_aws}/import_export.rb +6 -6
- data/lib/{aws → simple_aws}/map_reduce.rb +6 -6
- data/lib/{aws → simple_aws}/mechanical_turk.rb +5 -5
- data/lib/{aws → simple_aws}/rds.rb +6 -6
- data/lib/{aws → simple_aws}/s3.rb +15 -15
- data/lib/{aws → simple_aws}/ses.rb +6 -6
- data/lib/{aws → simple_aws}/signing/version2.rb +1 -1
- data/lib/{aws → simple_aws}/signing/version3.rb +1 -1
- data/lib/{aws → simple_aws}/sns.rb +6 -6
- data/lib/{aws → simple_aws}/sqs.rb +8 -8
- data/samples/cloud_front.rb +2 -2
- data/samples/ec2.rb +2 -2
- data/samples/elb.rb +2 -2
- data/samples/iam.rb +2 -2
- data/samples/s3.rb +2 -2
- data/samples/s3_batch_download.rb +2 -2
- data/samples/sqs.rb +2 -2
- data/samples/turk.rb +2 -2
- data/simple_aws.gemspec +1 -1
- data/test/{aws → simple_aws}/api_test.rb +3 -3
- data/test/{aws → simple_aws}/auto_scaling_test.rb +5 -5
- data/test/{aws → simple_aws}/call_types/action_param_test.rb +7 -7
- data/test/{aws → simple_aws}/cloud_formation_test.rb +5 -5
- data/test/{aws → simple_aws}/cloud_front_test.rb +11 -11
- data/test/{aws → simple_aws}/cloud_watch_test.rb +5 -5
- data/test/{aws → simple_aws}/core/connection_test.rb +16 -16
- data/test/{aws → simple_aws}/core/request_test.rb +3 -3
- data/test/{aws → simple_aws}/core/response_test.rb +23 -23
- data/test/{aws → simple_aws}/core/util_test.rb +7 -7
- data/test/{aws → simple_aws}/ec2_test.rb +5 -5
- data/test/{aws → simple_aws}/elasti_cache_test.rb +5 -5
- data/test/{aws → simple_aws}/elastic_beanstalk_test.rb +5 -5
- data/test/{aws → simple_aws}/elb_test.rb +5 -5
- data/test/{aws → simple_aws}/iam_test.rb +5 -5
- data/test/{aws → simple_aws}/import_export_test.rb +6 -6
- data/test/{aws → simple_aws}/map_reduce_test.rb +5 -5
- data/test/{aws → simple_aws}/mechanical_turk_test.rb +6 -6
- data/test/{aws → simple_aws}/rds_test.rb +5 -5
- data/test/{aws → simple_aws}/s3_test.rb +14 -14
- data/test/{aws → simple_aws}/ses.rb +6 -6
- data/test/{aws → simple_aws}/signing/version2_test.rb +8 -8
- data/test/{aws → simple_aws}/signing/version3.rb +8 -8
- data/test/{aws → simple_aws}/sns_test.rb +5 -5
- data/test/{aws → simple_aws}/sqs.rb +7 -7
- metadata +82 -81
@@ -1,6 +1,6 @@
|
|
1
|
-
require '
|
1
|
+
require 'simple_aws/api'
|
2
2
|
|
3
|
-
module
|
3
|
+
module SimpleAWS
|
4
4
|
|
5
5
|
##
|
6
6
|
# Amazon's Simple Storage Service
|
@@ -120,9 +120,9 @@ module AWS
|
|
120
120
|
# @param path [String] The path of the resource at hand
|
121
121
|
# @param options [Hash] Options as defined above
|
122
122
|
#
|
123
|
-
# @return [
|
123
|
+
# @return [SimpleAWS::Response] The results of the request
|
124
124
|
#
|
125
|
-
# @raise [
|
125
|
+
# @raise [SimpleAWS::UnsuccessfulResponse, SimpleAWS::UnknownErrorResponse] on response errors
|
126
126
|
##
|
127
127
|
def get(path, options = {})
|
128
128
|
call :get, path, options
|
@@ -134,9 +134,9 @@ module AWS
|
|
134
134
|
# @param path [String] The path of the resource at hand
|
135
135
|
# @param options [Hash] Options as defined above
|
136
136
|
#
|
137
|
-
# @return [
|
137
|
+
# @return [SimpleAWS::Response] The results of the request
|
138
138
|
#
|
139
|
-
# @raise [
|
139
|
+
# @raise [SimpleAWS::UnsuccessfulResponse, SimpleAWS::UnknownErrorResponse] on response errors
|
140
140
|
##
|
141
141
|
def put(path, options = {})
|
142
142
|
call :put, path, options
|
@@ -148,9 +148,9 @@ module AWS
|
|
148
148
|
# @param path [String] The path of the resource at hand
|
149
149
|
# @param options [Hash] Options as defined above
|
150
150
|
#
|
151
|
-
# @return [
|
151
|
+
# @return [SimpleAWS::Response] The results of the request
|
152
152
|
#
|
153
|
-
# @raise [
|
153
|
+
# @raise [SimpleAWS::UnsuccessfulResponse, SimpleAWS::UnknownErrorResponse] on response errors
|
154
154
|
##
|
155
155
|
def delete(path, options = {})
|
156
156
|
call :delete, path, options
|
@@ -162,9 +162,9 @@ module AWS
|
|
162
162
|
# @param path [String] The path of the resource at hand
|
163
163
|
# @param options [Hash] Options as defined above
|
164
164
|
#
|
165
|
-
# @return [
|
165
|
+
# @return [SimpleAWS::Response] The results of the request
|
166
166
|
#
|
167
|
-
# @raise [
|
167
|
+
# @raise [SimpleAWS::UnsuccessfulResponse, SimpleAWS::UnknownErrorResponse] on response errors
|
168
168
|
##
|
169
169
|
def head(path, options = {})
|
170
170
|
call :head, path, options
|
@@ -177,14 +177,14 @@ module AWS
|
|
177
177
|
# @param path [String] The path of the resource at hand
|
178
178
|
# @param options [Hash] Options as defined above
|
179
179
|
#
|
180
|
-
# @return [
|
180
|
+
# @return [SimpleAWS::Response] The results of the request
|
181
181
|
#
|
182
|
-
# @raise [
|
182
|
+
# @raise [SimpleAWS::UnsuccessfulResponse, SimpleAWS::UnknownErrorResponse] on response errors
|
183
183
|
##
|
184
184
|
def call(method, path, options = {})
|
185
185
|
request = self.build_request method, path, options
|
186
186
|
|
187
|
-
connection =
|
187
|
+
connection = SimpleAWS::Connection.new
|
188
188
|
connection.call finish_and_sign_request(request)
|
189
189
|
end
|
190
190
|
|
@@ -195,14 +195,14 @@ module AWS
|
|
195
195
|
# @param path [String] The path of the resource at hand
|
196
196
|
# @param options [Hash] Options as defined above
|
197
197
|
#
|
198
|
-
# @return [
|
198
|
+
# @return [SimpleAWS::Request] Completed but not yet signed request object
|
199
199
|
##
|
200
200
|
def build_request(method, path, options = {})
|
201
201
|
if options[:bucket]
|
202
202
|
path = "/#{options[:bucket]}/#{path}".gsub("//", "/")
|
203
203
|
end
|
204
204
|
|
205
|
-
request =
|
205
|
+
request = SimpleAWS::Request.new method, self.uri, path
|
206
206
|
|
207
207
|
(options[:params] || {}).each do |k, v|
|
208
208
|
request.params[k] = v
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
require '
|
1
|
+
require 'simple_aws/api'
|
2
|
+
require 'simple_aws/call_types/action_param'
|
3
|
+
require 'simple_aws/signing/version3'
|
4
4
|
|
5
|
-
module
|
5
|
+
module SimpleAWS
|
6
6
|
|
7
7
|
##
|
8
8
|
# Amazon's Simple Email Service
|
@@ -11,8 +11,8 @@ module AWS
|
|
11
11
|
#
|
12
12
|
# All requests are POST and always through HTTPS.
|
13
13
|
#
|
14
|
-
# @see
|
15
|
-
# @see
|
14
|
+
# @see SimpleAWS::CallTypes::ActionParam Calling rules
|
15
|
+
# @see SimpleAWS::Response Response handling
|
16
16
|
##
|
17
17
|
class SES < API
|
18
18
|
endpoint "email"
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
require '
|
1
|
+
require 'simple_aws/api'
|
2
|
+
require 'simple_aws/call_types/action_param'
|
3
|
+
require 'simple_aws/signing/version2'
|
4
4
|
|
5
|
-
module
|
5
|
+
module SimpleAWS
|
6
6
|
|
7
7
|
##
|
8
8
|
# Amazon's Simple Notification Service
|
@@ -12,8 +12,8 @@ module AWS
|
|
12
12
|
# All requests are POST and always through HTTPS. Use the third parameter to
|
13
13
|
# #initialize if you need to talk to a region other than us-east-1.
|
14
14
|
#
|
15
|
-
# @see
|
16
|
-
# @see
|
15
|
+
# @see SimpleAWS::CallTypes::ActionParam Calling rules
|
16
|
+
# @see SimpleAWS::Response Response handling
|
17
17
|
##
|
18
18
|
class SNS < API
|
19
19
|
endpoint "sns"
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
require '
|
1
|
+
require 'simple_aws/api'
|
2
|
+
require 'simple_aws/call_types/action_param'
|
3
|
+
require 'simple_aws/signing/version2'
|
4
4
|
|
5
|
-
module
|
5
|
+
module SimpleAWS
|
6
6
|
|
7
7
|
##
|
8
8
|
# Amazon's Simple Queue Service
|
@@ -20,8 +20,8 @@ module AWS
|
|
20
20
|
# In accordance with the AWS documentation, SimpleAWS does not try to reconstruct
|
21
21
|
# queue urls, use ListQueues or GetQueueUrl to get the correct queue url when needed.
|
22
22
|
#
|
23
|
-
# @see
|
24
|
-
# @see
|
23
|
+
# @see SimpleAWS::CallTypes::ActionParam Calling rules
|
24
|
+
# @see SimpleAWS::Response Response handling
|
25
25
|
##
|
26
26
|
class SQS < API
|
27
27
|
endpoint "sqs"
|
@@ -45,8 +45,8 @@ module AWS
|
|
45
45
|
|
46
46
|
uri = URI.parse(request_uri)
|
47
47
|
|
48
|
-
request =
|
49
|
-
request.params["Action"] =
|
48
|
+
request = SimpleAWS::Request.new :post, "#{uri.scheme}://#{uri.host}", uri.path
|
49
|
+
request.params["Action"] = SimpleAWS::Util.camelcase(name.to_s)
|
50
50
|
|
51
51
|
if params.is_a?(Hash)
|
52
52
|
insert_params_from request, params
|
data/samples/cloud_front.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
$: << File.expand_path("../../lib", __FILE__)
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'simple_aws/cloud_front'
|
4
4
|
|
5
5
|
##
|
6
6
|
# Expects your Amazon keys to be in the environment, something like
|
@@ -9,7 +9,7 @@ require 'aws/cloud_front'
|
|
9
9
|
# export AWS_SECRET="SECRET"
|
10
10
|
##
|
11
11
|
|
12
|
-
cloud_front =
|
12
|
+
cloud_front = SimpleAWS::CloudFront.new ENV["AWS_KEY"], ENV["AWS_SECRET"]
|
13
13
|
|
14
14
|
puts "First ten distribution items:", ""
|
15
15
|
|
data/samples/ec2.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
$: << File.expand_path("../../lib", __FILE__)
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'simple_aws/ec2'
|
4
4
|
|
5
5
|
##
|
6
6
|
# Expects your Amazon keys to be in the environment, something like
|
@@ -9,7 +9,7 @@ require 'aws/ec2'
|
|
9
9
|
# export AWS_SECRET="SECRET"
|
10
10
|
##
|
11
11
|
|
12
|
-
ec2 =
|
12
|
+
ec2 = SimpleAWS::EC2.new ENV["AWS_KEY"], ENV["AWS_SECRET"]
|
13
13
|
|
14
14
|
puts "", "Standard Only Addresses", ""
|
15
15
|
|
data/samples/elb.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
$: << File.expand_path("../../lib", __FILE__)
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'simple_aws/elb'
|
4
4
|
|
5
5
|
##
|
6
6
|
# Expects your Amazon keys to be in the environment, something like
|
@@ -9,7 +9,7 @@ require 'aws/elb'
|
|
9
9
|
# export AWS_SECRET="SECRET"
|
10
10
|
##
|
11
11
|
|
12
|
-
$elb =
|
12
|
+
$elb = SimpleAWS::ELB.new ENV["AWS_KEY"], ENV["AWS_SECRET"]
|
13
13
|
|
14
14
|
puts "", "Your Load Balancers", ""
|
15
15
|
|
data/samples/iam.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
$: << File.expand_path("../../lib", __FILE__)
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'simple_aws/iam'
|
4
4
|
|
5
5
|
##
|
6
6
|
# Expects your Amazon keys to be in the environment, something like
|
@@ -9,7 +9,7 @@ require 'aws/iam'
|
|
9
9
|
# export AWS_SECRET="SECRET"
|
10
10
|
##
|
11
11
|
|
12
|
-
$iam =
|
12
|
+
$iam = SimpleAWS::IAM.new ENV["AWS_KEY"], ENV["AWS_SECRET"]
|
13
13
|
|
14
14
|
puts "", "You are", ""
|
15
15
|
|
data/samples/s3.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
$: << File.expand_path("../../lib", __FILE__)
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'simple_aws/s3'
|
4
4
|
|
5
5
|
##
|
6
6
|
# Expects your Amazon keys to be in the environment, something like
|
@@ -21,7 +21,7 @@ def bad_usage
|
|
21
21
|
exit 1
|
22
22
|
end
|
23
23
|
|
24
|
-
s3 =
|
24
|
+
s3 = SimpleAWS::S3.new ENV["AWS_KEY"], ENV["AWS_SECRET"]
|
25
25
|
|
26
26
|
bucket_name = ARGV[0]
|
27
27
|
file_name = ARGV[1]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
$: << File.expand_path("../../lib", __FILE__)
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'simple_aws/s3'
|
4
4
|
|
5
5
|
##
|
6
6
|
# Expects your Amazon keys to be in the environment, something like
|
@@ -22,7 +22,7 @@ def bad_usage
|
|
22
22
|
exit 1
|
23
23
|
end
|
24
24
|
|
25
|
-
s3 =
|
25
|
+
s3 = SimpleAWS::S3.new ENV["AWS_KEY"], ENV["AWS_SECRET"]
|
26
26
|
|
27
27
|
s3_resource = ARGV[0]
|
28
28
|
save_to = ARGV[1]
|
data/samples/sqs.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
$: << File.expand_path("../../lib", __FILE__)
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'simple_aws/sqs'
|
4
4
|
|
5
5
|
##
|
6
6
|
# Expects your Amazon keys to be in the environment, something like
|
@@ -9,7 +9,7 @@ require 'aws/sqs'
|
|
9
9
|
# export AWS_SECRET="SECRET"
|
10
10
|
##
|
11
11
|
|
12
|
-
sqs =
|
12
|
+
sqs = SimpleAWS::SQS.new ENV["AWS_KEY"], ENV["AWS_SECRET"]
|
13
13
|
|
14
14
|
queue_name = "SimpleAWSTest"
|
15
15
|
|
data/samples/turk.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
$: << File.expand_path("../../lib", __FILE__)
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'simple_aws/mechanical_turk'
|
4
4
|
|
5
5
|
##
|
6
6
|
# Expects your Amazon keys to be in the environment, something like
|
@@ -9,6 +9,6 @@ require 'aws/mechanical_turk'
|
|
9
9
|
# export AWS_SECRET="SECRET"
|
10
10
|
##
|
11
11
|
|
12
|
-
turk =
|
12
|
+
turk = SimpleAWS::MechanicalTurk.new ENV["AWS_KEY"], ENV["AWS_SECRET"], true
|
13
13
|
|
14
14
|
p turk.SearchHITs
|
data/simple_aws.gemspec
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'test_helper'
|
2
|
-
require '
|
2
|
+
require 'simple_aws/auto_scaling'
|
3
3
|
|
4
|
-
describe
|
4
|
+
describe SimpleAWS::AutoScaling do
|
5
5
|
|
6
6
|
before do
|
7
|
-
@api =
|
7
|
+
@api = SimpleAWS::AutoScaling.new "key", "secret"
|
8
8
|
end
|
9
9
|
|
10
10
|
it "points to the endpoint" do
|
@@ -18,7 +18,7 @@ describe AWS::AutoScaling do
|
|
18
18
|
describe "API calls" do
|
19
19
|
|
20
20
|
it "builds and signs calls with ActionParam rules" do
|
21
|
-
|
21
|
+
SimpleAWS::Connection.any_instance.expects(:call).with do |request|
|
22
22
|
params = request.params
|
23
23
|
params.wont_be_nil
|
24
24
|
|
@@ -28,7 +28,7 @@ describe AWS::AutoScaling do
|
|
28
28
|
true
|
29
29
|
end
|
30
30
|
|
31
|
-
obj =
|
31
|
+
obj = SimpleAWS::AutoScaling.new "key", "secret"
|
32
32
|
obj.execute_policy
|
33
33
|
end
|
34
34
|
|
@@ -1,15 +1,15 @@
|
|
1
1
|
require 'test_helper'
|
2
|
-
require '
|
3
|
-
require '
|
2
|
+
require 'simple_aws/api'
|
3
|
+
require 'simple_aws/call_types/action_param'
|
4
4
|
|
5
|
-
describe
|
5
|
+
describe SimpleAWS::CallTypes::ActionParam do
|
6
6
|
|
7
|
-
class ActionParamTesting <
|
7
|
+
class ActionParamTesting < SimpleAWS::API
|
8
8
|
endpoint "aptest"
|
9
9
|
version "2011-01-01"
|
10
10
|
use_https true
|
11
11
|
|
12
|
-
include
|
12
|
+
include SimpleAWS::CallTypes::ActionParam
|
13
13
|
|
14
14
|
#noop
|
15
15
|
def finish_and_sign_request(request)
|
@@ -18,7 +18,7 @@ describe AWS::CallTypes::ActionParam do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it "takes an unknown method call and turns it into a request" do
|
21
|
-
|
21
|
+
SimpleAWS::Connection.any_instance.expects(:call).with do |request|
|
22
22
|
params = request.params
|
23
23
|
params["Action"].must_equal "DescribeInstances"
|
24
24
|
|
@@ -30,7 +30,7 @@ describe AWS::CallTypes::ActionParam do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
it "takes a hash parameter and gives it to the request" do
|
33
|
-
|
33
|
+
SimpleAWS::Connection.any_instance.expects(:call).with do |request|
|
34
34
|
|
35
35
|
params = request.params
|
36
36
|
params["ParamA"].must_equal 1
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'test_helper'
|
2
|
-
require '
|
2
|
+
require 'simple_aws/cloud_formation'
|
3
3
|
|
4
|
-
describe
|
4
|
+
describe SimpleAWS::CloudFormation do
|
5
5
|
|
6
6
|
before do
|
7
|
-
@api =
|
7
|
+
@api = SimpleAWS::CloudFormation.new "key", "secret"
|
8
8
|
end
|
9
9
|
|
10
10
|
it "points to endpoint, default to us-east-1" do
|
@@ -18,7 +18,7 @@ describe AWS::CloudFormation do
|
|
18
18
|
describe "API calls" do
|
19
19
|
|
20
20
|
it "builds and signs calls with ActionParam rules" do
|
21
|
-
|
21
|
+
SimpleAWS::Connection.any_instance.expects(:call).with do |request|
|
22
22
|
params = request.params
|
23
23
|
params.wont_be_nil
|
24
24
|
|
@@ -28,7 +28,7 @@ describe AWS::CloudFormation do
|
|
28
28
|
true
|
29
29
|
end
|
30
30
|
|
31
|
-
obj =
|
31
|
+
obj = SimpleAWS::CloudFormation.new "key", "secret"
|
32
32
|
obj.describe_stacks
|
33
33
|
end
|
34
34
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'test_helper'
|
2
|
-
require '
|
2
|
+
require 'simple_aws/cloud_front'
|
3
3
|
|
4
|
-
describe
|
4
|
+
describe SimpleAWS::CloudFront do
|
5
5
|
|
6
6
|
before do
|
7
|
-
@api =
|
7
|
+
@api = SimpleAWS::CloudFront.new "key", "secret"
|
8
8
|
end
|
9
9
|
|
10
10
|
it "points to the endpoint" do
|
@@ -13,7 +13,7 @@ describe AWS::CloudFront do
|
|
13
13
|
|
14
14
|
it "does not support region selection" do
|
15
15
|
lambda {
|
16
|
-
|
16
|
+
SimpleAWS::CloudFront.new "key", "secret", "us-east-1"
|
17
17
|
}.must_raise ArgumentError
|
18
18
|
end
|
19
19
|
|
@@ -25,7 +25,7 @@ describe AWS::CloudFront do
|
|
25
25
|
|
26
26
|
[:get, :post, :put, :delete].each do |method|
|
27
27
|
it "supports the #{method} HTTP method" do
|
28
|
-
|
28
|
+
SimpleAWS::Connection.any_instance.expects(:call).with do |request|
|
29
29
|
request.method.must_equal method
|
30
30
|
true
|
31
31
|
end
|
@@ -35,7 +35,7 @@ describe AWS::CloudFront do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
it "pre-pends the version to the path for every request" do
|
38
|
-
|
38
|
+
SimpleAWS::Connection.any_instance.expects(:call).with do |request|
|
39
39
|
request.path.must_equal "/2010-11-01/"
|
40
40
|
true
|
41
41
|
end
|
@@ -44,7 +44,7 @@ describe AWS::CloudFront do
|
|
44
44
|
end
|
45
45
|
|
46
46
|
it "takes parameters" do
|
47
|
-
|
47
|
+
SimpleAWS::Connection.any_instance.expects(:call).with do |request|
|
48
48
|
request.params["Parameter1"].must_equal "Value2"
|
49
49
|
true
|
50
50
|
end
|
@@ -53,7 +53,7 @@ describe AWS::CloudFront do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
it "takes a raw body" do
|
56
|
-
|
56
|
+
SimpleAWS::Connection.any_instance.expects(:call).with do |request|
|
57
57
|
request.body.must_equal "This is a body of text"
|
58
58
|
true
|
59
59
|
end
|
@@ -62,7 +62,7 @@ describe AWS::CloudFront do
|
|
62
62
|
end
|
63
63
|
|
64
64
|
it "uses :xml to take a hash and build XML from it" do
|
65
|
-
|
65
|
+
SimpleAWS::Connection.any_instance.expects(:call).with do |request|
|
66
66
|
request.headers["Content-Type"].must_equal "text/xml"
|
67
67
|
request.body.must_match(/amazonaws\.com\/doc\//)
|
68
68
|
request.body.must_match(/<InnerNode>/)
|
@@ -81,7 +81,7 @@ describe AWS::CloudFront do
|
|
81
81
|
end
|
82
82
|
|
83
83
|
it "takes extra headers" do
|
84
|
-
|
84
|
+
SimpleAWS::Connection.any_instance.expects(:call).with do |request|
|
85
85
|
request.headers["Header14"].must_equal "Out to Lunch"
|
86
86
|
true
|
87
87
|
end
|
@@ -90,7 +90,7 @@ describe AWS::CloudFront do
|
|
90
90
|
end
|
91
91
|
|
92
92
|
it "signs the given request according to Version 3 rules" do
|
93
|
-
|
93
|
+
SimpleAWS::Connection.any_instance.expects(:call).with do |request|
|
94
94
|
request.headers["Authorization"].wont_be_nil
|
95
95
|
header = request.headers["Authorization"]
|
96
96
|
parts = header.split(":")
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'test_helper'
|
2
|
-
require '
|
2
|
+
require 'simple_aws/cloud_watch'
|
3
3
|
|
4
|
-
describe
|
4
|
+
describe SimpleAWS::CloudWatch do
|
5
5
|
|
6
6
|
before do
|
7
|
-
@api =
|
7
|
+
@api = SimpleAWS::CloudWatch.new "key", "secret"
|
8
8
|
end
|
9
9
|
|
10
10
|
it "points to endpoint, default to us-east-1" do
|
@@ -18,7 +18,7 @@ describe AWS::CloudWatch do
|
|
18
18
|
describe "API calls" do
|
19
19
|
|
20
20
|
it "builds and signs calls with ActionParam rules" do
|
21
|
-
|
21
|
+
SimpleAWS::Connection.any_instance.expects(:call).with do |request|
|
22
22
|
params = request.params
|
23
23
|
params.wont_be_nil
|
24
24
|
|
@@ -28,7 +28,7 @@ describe AWS::CloudWatch do
|
|
28
28
|
true
|
29
29
|
end
|
30
30
|
|
31
|
-
obj =
|
31
|
+
obj = SimpleAWS::CloudWatch.new "key", "secret"
|
32
32
|
obj.list_metrics
|
33
33
|
end
|
34
34
|
|
@@ -1,21 +1,21 @@
|
|
1
1
|
require 'test_helper'
|
2
|
-
require '
|
3
|
-
require '
|
4
|
-
require '
|
2
|
+
require 'simple_aws/core/request'
|
3
|
+
require 'simple_aws/core/response'
|
4
|
+
require 'simple_aws/core/connection'
|
5
5
|
|
6
|
-
describe
|
6
|
+
describe SimpleAWS::Connection do
|
7
7
|
|
8
8
|
describe "#call" do
|
9
9
|
|
10
10
|
before do
|
11
|
-
@connection =
|
11
|
+
@connection = SimpleAWS::Connection.new
|
12
12
|
@http_response = stub_everything(:success? => true, :parsed_response => {"value" => {}})
|
13
13
|
end
|
14
14
|
|
15
15
|
it "takes a basic request and runs it" do
|
16
|
-
request =
|
16
|
+
request = SimpleAWS::Request.new(:get, "host.com", "/")
|
17
17
|
|
18
|
-
|
18
|
+
SimpleAWS::HTTP.expects(:get).with {|uri, options|
|
19
19
|
uri.must_equal "host.com/"
|
20
20
|
}.returns(@http_response)
|
21
21
|
|
@@ -23,20 +23,20 @@ describe AWS::Connection do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it "returns the response wrapped in our Response object" do
|
26
|
-
request =
|
26
|
+
request = SimpleAWS::Request.new(:get, "host.com", "/")
|
27
27
|
|
28
|
-
|
28
|
+
SimpleAWS::HTTP.expects(:get).returns(@http_response)
|
29
29
|
|
30
30
|
response = @connection.call request
|
31
|
-
response.must_be_kind_of
|
31
|
+
response.must_be_kind_of SimpleAWS::Response
|
32
32
|
response.body.must_equal "value" => {}
|
33
33
|
end
|
34
34
|
|
35
35
|
it "pulls parameters into the request" do
|
36
|
-
request =
|
36
|
+
request = SimpleAWS::Request.new(:get, "host.com", "/")
|
37
37
|
request.params["Param1"] = "Something"
|
38
38
|
|
39
|
-
|
39
|
+
SimpleAWS::HTTP.expects(:get).with {|uri, options|
|
40
40
|
options[:query].wont_be_nil
|
41
41
|
options[:query]["Param1"].must_equal "Something"
|
42
42
|
}.returns(@http_response)
|
@@ -45,10 +45,10 @@ describe AWS::Connection do
|
|
45
45
|
end
|
46
46
|
|
47
47
|
it "adds any headers from the Request object" do
|
48
|
-
request =
|
48
|
+
request = SimpleAWS::Request.new(:get, "host.com", "/")
|
49
49
|
request.headers["Header"] = "Awesome"
|
50
50
|
|
51
|
-
|
51
|
+
SimpleAWS::HTTP.expects(:get).with {|uri, options|
|
52
52
|
options[:query].wont_be_nil
|
53
53
|
options[:headers].must_equal "Header" => "Awesome"
|
54
54
|
}.returns(@http_response)
|
@@ -57,10 +57,10 @@ describe AWS::Connection do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
it "passes through any body on the Request" do
|
60
|
-
request =
|
60
|
+
request = SimpleAWS::Request.new(:get, "host.com", "/")
|
61
61
|
request.body = "This is some body text"
|
62
62
|
|
63
|
-
|
63
|
+
SimpleAWS::HTTP.expects(:get).with {|uri, options|
|
64
64
|
options[:query].wont_be_nil
|
65
65
|
options[:body].must_equal "This is some body text"
|
66
66
|
}.returns(@http_response)
|