right_aws 2.1.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +38 -14
- data/Manifest.txt +1 -0
- data/Rakefile +34 -8
- data/lib/awsbase/right_awsbase.rb +176 -12
- data/lib/awsbase/version.rb +2 -2
- data/lib/ec2/right_ec2.rb +120 -37
- data/lib/ec2/right_ec2_ebs.rb +57 -41
- data/lib/ec2/right_ec2_images.rb +73 -44
- data/lib/ec2/right_ec2_instances.rb +158 -155
- data/lib/ec2/right_ec2_reserved_instances.rb +36 -26
- data/lib/ec2/right_ec2_security_groups.rb +261 -166
- data/lib/ec2/right_ec2_spot_instances.rb +72 -75
- data/lib/ec2/right_ec2_vpc.rb +15 -8
- data/lib/ec2/right_ec2_vpc2.rb +381 -0
- data/lib/elb/right_elb_interface.rb +3 -1
- data/lib/emr/right_emr_interface.rb +727 -0
- data/lib/rds/right_rds_interface.rb +102 -27
- data/lib/right_aws.rb +4 -1
- data/lib/route_53/right_route_53_interface.rb +24 -14
- data/lib/s3/right_s3.rb +16 -15
- data/lib/s3/right_s3_interface.rb +42 -10
- data/lib/sdb/right_sdb_interface.rb +14 -5
- data/lib/sns/right_sns_interface.rb +286 -0
- data/test/README.mdown +39 -0
- data/test/awsbase/test_right_awsbase.rb +0 -1
- data/test/ec2/test_right_ec2.rb +0 -1
- data/test/elb/test_helper.rb +2 -0
- data/test/elb/test_right_elb.rb +43 -0
- data/test/route_53/fixtures/a_record.xml +18 -0
- data/test/route_53/fixtures/alias_record.xml +18 -0
- data/test/route_53/test_helper.rb +2 -0
- data/test/route_53/test_right_route_53.rb +141 -0
- data/test/s3/test_right_s3.rb +97 -39
- data/test/sns/test_helper.rb +2 -0
- data/test/sns/test_right_sns.rb +153 -0
- data/test/ts_right_aws.rb +1 -0
- metadata +28 -9
data/test/ec2/test_right_ec2.rb
CHANGED
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestElb < Test::Unit::TestCase
|
4
|
+
|
5
|
+
STDOUT.sync = true
|
6
|
+
BALANCER_NAME = 'right-aws-test-lb'
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@elb = Rightscale::ElbInterface.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key, :logger => Logger.new('/dev/null'))
|
10
|
+
|
11
|
+
unless @elb.describe_load_balancers.detect { |lb| lb[:load_balancer_name] == BALANCER_NAME }
|
12
|
+
@elb.create_load_balancer(BALANCER_NAME, %w[us-east-1b], [])
|
13
|
+
end
|
14
|
+
@lb = @elb.describe_load_balancers.detect { |lb| lb[:load_balancer_name] == BALANCER_NAME }
|
15
|
+
end
|
16
|
+
|
17
|
+
# At the end of the day when you want to shut down the test balancer:
|
18
|
+
# * Uncomment this method.
|
19
|
+
# * Comment out all test except one.
|
20
|
+
# * Run this test file.
|
21
|
+
#
|
22
|
+
# def teardown
|
23
|
+
# @elb.delete_load_balancer BALANCER_NAME
|
24
|
+
# end
|
25
|
+
|
26
|
+
def test_00_describe_load_balancers
|
27
|
+
items = @elb.describe_load_balancers
|
28
|
+
assert items.is_a?(Array)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_description
|
32
|
+
assert_match /^#{BALANCER_NAME}-\d+\.us-east-1\.elb\.amazonaws\.com$/, @lb[:dns_name]
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_description_has_canonical_hosted_zone_name
|
36
|
+
assert_match /^#{BALANCER_NAME}-\d+\.us-east-1\.elb\.amazonaws\.com$/, @lb[:canonical_hosted_zone_name]
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_description_has_canonical_hosted_zone_name_id
|
40
|
+
assert_match /^[A-Z0-9]+$/, @lb[:canonical_hosted_zone_name_id]
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<ChangeResourceRecordSetsRequest xmlns="https://route53.amazonaws.com/doc/2011-05-05/">
|
3
|
+
<ChangeBatch>
|
4
|
+
<Changes>
|
5
|
+
<Change>
|
6
|
+
<Action>CREATE</Action>
|
7
|
+
<ResourceRecordSet>
|
8
|
+
<Name>host.right-aws.example.com.</Name>
|
9
|
+
<Type>A</Type>
|
10
|
+
<TTL>600</TTL>
|
11
|
+
<ResourceRecords>
|
12
|
+
<ResourceRecord><Value>10.0.0.1</Value></ResourceRecord>
|
13
|
+
</ResourceRecords>
|
14
|
+
</ResourceRecordSet>
|
15
|
+
</Change>
|
16
|
+
</Changes>
|
17
|
+
</ChangeBatch>
|
18
|
+
</ChangeResourceRecordSetsRequest>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<ChangeResourceRecordSetsRequest xmlns="https://route53.amazonaws.com/doc/2011-05-05/">
|
3
|
+
<ChangeBatch>
|
4
|
+
<Changes>
|
5
|
+
<Change>
|
6
|
+
<Action>CREATE</Action>
|
7
|
+
<ResourceRecordSet>
|
8
|
+
<Name>right-aws.example.com.</Name>
|
9
|
+
<Type>A</Type>
|
10
|
+
<AliasTarget>
|
11
|
+
<HostedZoneId>Z1234567890123</HostedZoneId>
|
12
|
+
<DNSName>example-load-balancer-1111111111.us-east-1.elb.amazonaws.com.</DNSName>
|
13
|
+
</AliasTarget>
|
14
|
+
</ResourceRecordSet>
|
15
|
+
</Change>
|
16
|
+
</Changes>
|
17
|
+
</ChangeBatch>
|
18
|
+
</ChangeResourceRecordSetsRequest>
|
@@ -0,0 +1,141 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestRoute53 < Test::Unit::TestCase
|
4
|
+
|
5
|
+
STDOUT.sync = true
|
6
|
+
BALANCER_NAME = 'right-aws-test-lb'
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@r53 = Rightscale::Route53Interface.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key, :logger => Logger.new('/dev/null'))
|
10
|
+
@zone_config = {:name => "right-aws.example.com.", :config => {:comment => 'a comment'}}
|
11
|
+
|
12
|
+
@elb = Rightscale::ElbInterface.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key, :logger => Logger.new('/dev/null'))
|
13
|
+
end
|
14
|
+
|
15
|
+
def teardown
|
16
|
+
@r53.list_hosted_zones.each do |zone|
|
17
|
+
next unless zone[:name] == @zone_config[:name]
|
18
|
+
zone_id = zone[:aws_id]
|
19
|
+
puts zone_id
|
20
|
+
records = @r53.list_resource_record_sets(zone_id)
|
21
|
+
# The NS and SOA records are provided by AWS and must not be deleted
|
22
|
+
records.reject! { |rr| %w[NS SOA].include? rr[:type] }
|
23
|
+
if records.any?
|
24
|
+
response = @r53.delete_resource_record_sets(zone_id, records)
|
25
|
+
puts response.inspect
|
26
|
+
end
|
27
|
+
puts @r53.delete_hosted_zone(zone_id).inspect
|
28
|
+
end
|
29
|
+
# Uncomment to shut down at the end of the day.
|
30
|
+
# @elb.delete_load_balancer BALANCER_NAME
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_00_list_hosted_zones
|
34
|
+
items = @r53.list_hosted_zones
|
35
|
+
assert items.is_a?(Array)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_create_and_delete_zone
|
39
|
+
response = @r53.create_hosted_zone(@zone_config)
|
40
|
+
assert_equal response[:name], @zone_config[:name]
|
41
|
+
assert response[:aws_id].is_a?(String)
|
42
|
+
assert response[:name_servers].is_a?(Array)
|
43
|
+
|
44
|
+
response2 = @r53.delete_hosted_zone(response[:aws_id])
|
45
|
+
assert_equal response2[:status], 'PENDING'
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_add_and_remove_A_record
|
49
|
+
zone = @r53.create_hosted_zone(@zone_config)
|
50
|
+
zone_id = zone[:aws_id]
|
51
|
+
# add
|
52
|
+
a_record = { :name => 'host.right-aws.example.com.', :type => 'A', :ttl => 600, :resource_records => ['10.0.0.1'] }
|
53
|
+
response = @r53.create_resource_record_sets(zone_id, [a_record.dup]) # .dup since it will get :action => :create
|
54
|
+
assert_equal response[:status], 'PENDING'
|
55
|
+
|
56
|
+
# It should be there now
|
57
|
+
records = @r53.list_resource_record_sets(zone_id)
|
58
|
+
assert records.is_a?(Array)
|
59
|
+
assert records.detect { |rr| rr == a_record }, "Could not find '#{a_record.inspect}' in '#{records.inspect}'"
|
60
|
+
|
61
|
+
# remove
|
62
|
+
response = @r53.delete_resource_record_sets(zone_id, [a_record.dup])
|
63
|
+
assert_equal response[:status], 'PENDING'
|
64
|
+
|
65
|
+
# It should not be there anymore
|
66
|
+
records = @r53.list_resource_record_sets(zone_id)
|
67
|
+
assert records.is_a?(Array)
|
68
|
+
assert ! records.detect { |rr| rr == a_record }, "Record '#{a_record.inspect}' is still in '#{records.inspect}'"
|
69
|
+
|
70
|
+
@r53.delete_hosted_zone(zone_id)
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_add_and_remove_Alias_record
|
74
|
+
lb = find_or_create_load_balancer
|
75
|
+
|
76
|
+
zone = @r53.create_hosted_zone(@zone_config)
|
77
|
+
zone_id = zone[:aws_id]
|
78
|
+
|
79
|
+
# add
|
80
|
+
alias_target = { :hosted_zone_id => lb[:canonical_hosted_zone_name_id], :dns_name => lb[:dns_name] }
|
81
|
+
alias_record = { :name => 'right-aws.example.com', :type => 'A', :alias_target => alias_target }
|
82
|
+
response = @r53.create_resource_record_sets(zone_id, [alias_record.dup]) # .dup since it will get :action => :create
|
83
|
+
assert_equal response[:status], 'PENDING'
|
84
|
+
|
85
|
+
# It should be there now
|
86
|
+
records = @r53.list_resource_record_sets(zone_id)
|
87
|
+
assert records.is_a?(Array)
|
88
|
+
record = records.detect { |rr| rr[:alias_target] }
|
89
|
+
assert record, "Could not find '#{alias_record.inspect}' in '#{records.inspect}'"
|
90
|
+
# AWS adds final dots to names
|
91
|
+
assert_equal "#{alias_record[:name]}.", record[:name]
|
92
|
+
assert_equal "#{alias_target[:dns_name]}.", record[:alias_target][:dns_name]
|
93
|
+
|
94
|
+
# remove
|
95
|
+
response = @r53.delete_resource_record_sets(zone_id, [alias_record.dup])
|
96
|
+
assert_equal response[:status], 'PENDING'
|
97
|
+
|
98
|
+
# It should not be there anymore
|
99
|
+
records = @r53.list_resource_record_sets(zone_id)
|
100
|
+
assert records.is_a?(Array)
|
101
|
+
record = records.detect { |rr| rr[:alias_target] }
|
102
|
+
assert ! record, "Record '#{alias_record.inspect}' is still in '#{records.inspect}'"
|
103
|
+
|
104
|
+
@r53.delete_hosted_zone(zone_id)
|
105
|
+
end
|
106
|
+
|
107
|
+
def find_or_create_load_balancer
|
108
|
+
unless @elb.describe_load_balancers.detect { |lb| lb[:load_balancer_name] == BALANCER_NAME }
|
109
|
+
@elb.create_load_balancer(BALANCER_NAME, %w[us-east-1b], [])
|
110
|
+
puts "WARNING: Started load balancer. Remember to shut it down (see teardown)."
|
111
|
+
puts "NOTE: Tests might not pass during first few seconds after load balancer is created."
|
112
|
+
end
|
113
|
+
@elb.describe_load_balancers.detect { |lb| lb[:load_balancer_name] == BALANCER_NAME }
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_rr_sets_to_xml
|
117
|
+
a_record = { :name => 'host.right-aws.example.com.', :type => 'A', :ttl => 600, :resource_records => ['10.0.0.1'], :action => :create }
|
118
|
+
expected = load_fixture('a_record.xml')
|
119
|
+
assert_equal expected, @r53.resource_record_sets_to_xml([a_record], '')
|
120
|
+
|
121
|
+
# Note final full stop
|
122
|
+
alias_target = { :hosted_zone_id => 'Z1234567890123', :dns_name => 'example-load-balancer-1111111111.us-east-1.elb.amazonaws.com.' }
|
123
|
+
alias_record = { :name => 'right-aws.example.com.', :type => 'A', :alias_target => alias_target, :action => :create }
|
124
|
+
expected = load_fixture('alias_record.xml')
|
125
|
+
assert_same_lines expected, @r53.resource_record_sets_to_xml([alias_record], '')
|
126
|
+
end
|
127
|
+
|
128
|
+
def load_fixture (name)
|
129
|
+
File.read(File.join(File.dirname(__FILE__), 'fixtures', name))
|
130
|
+
end
|
131
|
+
|
132
|
+
def assert_same_lines (expected, actual)
|
133
|
+
expected = expected.split "\n"
|
134
|
+
actual = actual.split "\n"
|
135
|
+
previous = []
|
136
|
+
while e = expected.shift and a = actual.shift
|
137
|
+
assert_equal e, a, "After:\n#{previous.join("\n")}"
|
138
|
+
previous << e
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
data/test/s3/test_right_s3.rb
CHANGED
@@ -3,24 +3,26 @@ require File.dirname(__FILE__) + '/test_helper.rb'
|
|
3
3
|
class TestS3 < Test::Unit::TestCase
|
4
4
|
|
5
5
|
RIGHT_OBJECT_TEXT = 'Right test message'
|
6
|
-
|
6
|
+
INTERFACE = Rightscale::S3Interface.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key)
|
7
|
+
CONNECTION = Rightscale::S3.new(TestCredentials.aws_access_key_id, TestCredentials.aws_secret_access_key)
|
8
|
+
|
7
9
|
def setup
|
8
|
-
@s3 =
|
9
|
-
@bucket = '
|
10
|
-
@bucket2 = '
|
10
|
+
@s3 = INTERFACE
|
11
|
+
@bucket = 'right_s3_awesome_test_bucket_000B1_officedrop'
|
12
|
+
@bucket2 = 'right_s3_awesome_test_bucket_000B2_officedrop'
|
11
13
|
@key1 = 'test/woohoo1/'
|
12
14
|
@key2 = 'test1/key/woohoo2'
|
13
15
|
@key3 = 'test2/A%B@C_D&E?F+G=H"I'
|
14
16
|
@key1_copy = 'test/woohoo1_2'
|
15
17
|
@key1_new_name = 'test/woohoo1_3'
|
16
18
|
@key2_new_name = 'test1/key/woohoo2_new'
|
17
|
-
@s =
|
19
|
+
@s = CONNECTION
|
18
20
|
end
|
19
21
|
|
20
22
|
#---------------------------
|
21
23
|
# Rightscale::S3Interface
|
22
24
|
#---------------------------
|
23
|
-
|
25
|
+
|
24
26
|
def test_01_create_bucket
|
25
27
|
assert @s3.create_bucket(@bucket), 'Create_bucket fail'
|
26
28
|
end
|
@@ -32,13 +34,13 @@ class TestS3 < Test::Unit::TestCase
|
|
32
34
|
def test_03_list_empty_bucket
|
33
35
|
assert_equal 0, @s3.list_bucket(@bucket).size, "#{@bucket} isn't empty, arrgh!"
|
34
36
|
end
|
35
|
-
|
37
|
+
|
36
38
|
def test_04_put
|
37
39
|
assert @s3.put(@bucket, @key1, RIGHT_OBJECT_TEXT, 'x-amz-meta-family'=>'Woohoo1!'), 'Put bucket fail'
|
38
40
|
assert @s3.put(@bucket, @key2, RIGHT_OBJECT_TEXT, 'x-amz-meta-family'=>'Woohoo2!'), 'Put bucket fail'
|
39
41
|
assert @s3.put(@bucket, @key3, RIGHT_OBJECT_TEXT, 'x-amz-meta-family'=>'Woohoo3!'), 'Put bucket fail'
|
40
42
|
end
|
41
|
-
|
43
|
+
|
42
44
|
def test_05_get_and_get_object
|
43
45
|
assert_raise(Rightscale::AwsError) { @s3.get(@bucket, 'undefined/key') }
|
44
46
|
data1 = @s3.get(@bucket, @key1)
|
@@ -47,7 +49,7 @@ class TestS3 < Test::Unit::TestCase
|
|
47
49
|
assert_equal 'Woohoo1!', data1[:headers]['x-amz-meta-family'], "x-amz-meta-family header must be equal to 'Woohoo1!'"
|
48
50
|
assert_equal RIGHT_OBJECT_TEXT, @s3.get_object(@bucket, @key3), "Get_object text must return '#{RIGHT_OBJECT_TEXT}'"
|
49
51
|
end
|
50
|
-
|
52
|
+
|
51
53
|
def test_06_head
|
52
54
|
assert_equal 'Woohoo1!', @s3.head(@bucket,@key1)['x-amz-meta-family'], "x-amz-meta-family header must be equal to 'Woohoo1!'"
|
53
55
|
end
|
@@ -55,7 +57,7 @@ class TestS3 < Test::Unit::TestCase
|
|
55
57
|
|
56
58
|
def test_07_streaming_get
|
57
59
|
resp = String.new
|
58
|
-
assert_raise(Rightscale::AwsError) do
|
60
|
+
assert_raise(Rightscale::AwsError) do
|
59
61
|
@s3.get(@bucket, 'undefined/key') do |chunk|
|
60
62
|
resp += chunk
|
61
63
|
end
|
@@ -69,7 +71,7 @@ class TestS3 < Test::Unit::TestCase
|
|
69
71
|
assert_equal @s3.get_object(@bucket, @key1), resp, "Streaming iface must return same as non-streaming"
|
70
72
|
assert_equal 'Woohoo1!', data1[:headers]['x-amz-meta-family'], "x-amz-meta-family header must be equal to 'Woohoo1!'"
|
71
73
|
end
|
72
|
-
|
74
|
+
|
73
75
|
def test_08_keys
|
74
76
|
keys = @s3.list_bucket(@bucket).map{|b| b[:key]}
|
75
77
|
assert_equal keys.size, 3, "There should be 3 keys"
|
@@ -77,7 +79,7 @@ class TestS3 < Test::Unit::TestCase
|
|
77
79
|
assert(keys.include?(@key2))
|
78
80
|
assert(keys.include?(@key3))
|
79
81
|
end
|
80
|
-
|
82
|
+
|
81
83
|
def test_09_copy_key
|
82
84
|
#--- test COPY
|
83
85
|
# copy a key
|
@@ -130,7 +132,7 @@ class TestS3 < Test::Unit::TestCase
|
|
130
132
|
def test_13_delete_folder
|
131
133
|
assert_equal 1, @s3.delete_folder(@bucket, 'test').size, "Only one key(#{@key1}) must be deleted!"
|
132
134
|
end
|
133
|
-
|
135
|
+
|
134
136
|
def test_14_delete_bucket
|
135
137
|
assert_raise(Rightscale::AwsError) { @s3.delete_bucket(@bucket) }
|
136
138
|
assert @s3.clear_bucket(@bucket), 'Clear_bucket fail'
|
@@ -138,9 +140,9 @@ class TestS3 < Test::Unit::TestCase
|
|
138
140
|
assert @s3.delete_bucket(@bucket)
|
139
141
|
assert !@s3.list_all_my_buckets.map{|bucket| bucket[:name]}.include?(@bucket), "#{@bucket} must not exist"
|
140
142
|
end
|
141
|
-
|
142
|
-
|
143
|
-
|
143
|
+
|
144
|
+
|
145
|
+
|
144
146
|
|
145
147
|
#---------------------------
|
146
148
|
# Rightscale::S3 classes
|
@@ -198,7 +200,7 @@ class TestS3 < Test::Unit::TestCase
|
|
198
200
|
assert key2.delete
|
199
201
|
assert !key2.exists?
|
200
202
|
end
|
201
|
-
|
203
|
+
|
202
204
|
def test_23_rename_key
|
203
205
|
bucket = Rightscale::S3::Bucket.create(@s, @bucket, false)
|
204
206
|
# -- 1 -- (key based rename)
|
@@ -218,7 +220,7 @@ class TestS3 < Test::Unit::TestCase
|
|
218
220
|
assert bucket.key('test/copy/3').exists?, "'test/copy/3' should exist"
|
219
221
|
assert !bucket.key('test/copy/2').exists?, "'test/copy/2' should not exist"
|
220
222
|
end
|
221
|
-
|
223
|
+
|
222
224
|
def test_24_copy_key
|
223
225
|
bucket = Rightscale::S3::Bucket.create(@s, @bucket, false)
|
224
226
|
# -- 1 -- (key based copy)
|
@@ -239,7 +241,7 @@ class TestS3 < Test::Unit::TestCase
|
|
239
241
|
assert_equal RIGHT_OBJECT_TEXT, bucket.key('test/copy/11').get
|
240
242
|
assert_equal RIGHT_OBJECT_TEXT, bucket.key('test/copy/12').get
|
241
243
|
end
|
242
|
-
|
244
|
+
|
243
245
|
def test_25_move_key
|
244
246
|
bucket = Rightscale::S3::Bucket.create(@s, @bucket, false)
|
245
247
|
# -- 1 -- (key based copy)
|
@@ -258,7 +260,7 @@ class TestS3 < Test::Unit::TestCase
|
|
258
260
|
assert bucket.key('test/copy/22').exists?, "'test/copy/22' should exist"
|
259
261
|
assert_equal RIGHT_OBJECT_TEXT, bucket.key('test/copy/22').get
|
260
262
|
end
|
261
|
-
|
263
|
+
|
262
264
|
def test_26_save_meta
|
263
265
|
bucket = Rightscale::S3::Bucket.create(@s, @bucket, false)
|
264
266
|
# create a key
|
@@ -271,7 +273,7 @@ class TestS3 < Test::Unit::TestCase
|
|
271
273
|
# reload meta
|
272
274
|
assert_equal meta, key.reload_meta
|
273
275
|
end
|
274
|
-
|
276
|
+
|
275
277
|
def test_27_clear_delete
|
276
278
|
bucket = Rightscale::S3::Bucket.create(@s, @bucket, false)
|
277
279
|
# add another key
|
@@ -280,16 +282,16 @@ class TestS3 < Test::Unit::TestCase
|
|
280
282
|
assert_equal 1, bucket.delete_folder(@key1).size
|
281
283
|
# delete
|
282
284
|
assert_raise(Rightscale::AwsError) { bucket.delete }
|
283
|
-
bucket.delete(true)
|
285
|
+
bucket.delete(:force => true)
|
284
286
|
end
|
285
287
|
|
286
288
|
# Grantees
|
287
|
-
|
289
|
+
|
288
290
|
def test_30_create_bucket
|
289
291
|
bucket = @s.bucket(@bucket, true, 'public-read')
|
290
292
|
assert bucket
|
291
293
|
end
|
292
|
-
|
294
|
+
|
293
295
|
def test_31_list_grantees
|
294
296
|
bucket = Rightscale::S3::Bucket.create(@s, @bucket, false)
|
295
297
|
# get grantees list
|
@@ -297,10 +299,10 @@ class TestS3 < Test::Unit::TestCase
|
|
297
299
|
# check that the grantees count equal to 2 (root, AllUsers)
|
298
300
|
assert_equal 2, grantees.size
|
299
301
|
end
|
300
|
-
|
302
|
+
|
301
303
|
def test_32_grant_revoke_drop
|
302
304
|
bucket = Rightscale::S3::Bucket.create(@s, @bucket, false)
|
303
|
-
# Take 'AllUsers' grantee
|
305
|
+
# Take 'AllUsers' grantee
|
304
306
|
grantee = Rightscale::S3::Grantee.new(bucket,'http://acs.amazonaws.com/groups/global/AllUsers')
|
305
307
|
# Check exists?
|
306
308
|
assert grantee.exists?
|
@@ -331,9 +333,9 @@ class TestS3 < Test::Unit::TestCase
|
|
331
333
|
assert !grantee.exists?
|
332
334
|
assert_equal 1, bucket.grantees.size
|
333
335
|
# Delete bucket
|
334
|
-
bucket.delete(true)
|
336
|
+
bucket.delete(:force => true)
|
335
337
|
end
|
336
|
-
|
338
|
+
|
337
339
|
def test_33_key_grantees
|
338
340
|
# Create bucket
|
339
341
|
bucket = @s.bucket(@bucket, true)
|
@@ -350,7 +352,7 @@ class TestS3 < Test::Unit::TestCase
|
|
350
352
|
# Drop grantee
|
351
353
|
assert grantee.drop
|
352
354
|
# Drop bucket
|
353
|
-
bucket.delete(true)
|
355
|
+
bucket.delete(:force => true)
|
354
356
|
end
|
355
357
|
|
356
358
|
def test_34_bucket_create_put_with_perms
|
@@ -393,29 +395,85 @@ class TestS3 < Test::Unit::TestCase
|
|
393
395
|
RightAws::S3Interface.amazon_problems= nil
|
394
396
|
assert_nil(RightAws::S3Interface.amazon_problems)
|
395
397
|
end
|
396
|
-
|
398
|
+
|
397
399
|
def test_37_access_logging
|
398
400
|
bucket = Rightscale::S3::Bucket.create(@s, @bucket, false)
|
399
401
|
targetbucket = Rightscale::S3::Bucket.create(@s, @bucket2, true)
|
400
|
-
# Take 'AllUsers' grantee
|
402
|
+
# Take 'AllUsers' grantee
|
401
403
|
grantee = Rightscale::S3::Grantee.new(targetbucket,'http://acs.amazonaws.com/groups/s3/LogDelivery')
|
402
|
-
|
404
|
+
|
403
405
|
assert grantee.grant(['READ_ACP', 'WRITE'])
|
404
|
-
|
406
|
+
|
405
407
|
assert bucket.enable_logging(:targetbucket => targetbucket, :targetprefix => "loggylogs/")
|
406
408
|
sleep 10
|
407
|
-
|
409
|
+
|
408
410
|
assert_equal({:enabled => true, :targetbucket => @bucket2, :targetprefix => "loggylogs/"}, bucket.logging_info)
|
409
|
-
|
411
|
+
|
410
412
|
assert bucket.disable_logging
|
411
|
-
|
413
|
+
|
412
414
|
# check 'Drop' method
|
413
|
-
assert grantee.drop
|
415
|
+
assert grantee.drop
|
414
416
|
end
|
415
417
|
|
416
418
|
def test_40_delete_buckets
|
417
|
-
Rightscale::S3::Bucket.create(@s, @bucket, false).delete(true)
|
418
|
-
Rightscale::S3::Bucket.create(@s, @bucket2, false).delete(true)
|
419
|
+
Rightscale::S3::Bucket.create(@s, @bucket, false).delete(:force => true)
|
420
|
+
Rightscale::S3::Bucket.create(@s, @bucket2, false).delete(:force => true)
|
421
|
+
end
|
422
|
+
|
423
|
+
def test_41_add_cache_control_response_parameter
|
424
|
+
@cache_control = 'max-age=3600'
|
425
|
+
perform_request( 'response-cache-control' => @cache_control ) do |response|
|
426
|
+
assert_equal response['Cache-Control'], @cache_control
|
427
|
+
end
|
428
|
+
end
|
429
|
+
|
430
|
+
def test_42_add_cache_control_and_content_type_and_content_disposition
|
431
|
+
@cache_control = 'max-age=3600'
|
432
|
+
@content_type = 'text/plain'
|
433
|
+
@content_disposition = 'attachment; filename=sample.txt'
|
434
|
+
perform_request(
|
435
|
+
'response-cache-control' => @cache_control,
|
436
|
+
'response-content-type' => @content_type,
|
437
|
+
'response-content-disposition' => @content_disposition
|
438
|
+
) do |response|
|
439
|
+
assert_equal response['Cache-Control'], @cache_control
|
440
|
+
assert_equal response['Content-Type'], @content_type
|
441
|
+
assert_equal response['Content-Disposition'], @content_disposition
|
442
|
+
end
|
443
|
+
end
|
444
|
+
|
445
|
+
def test_43_add_expires_and_content_type_and_content_disposition
|
446
|
+
@expires = 'Sun, 26 Jun 2011 02:58:26 GMT'
|
447
|
+
@content_type = 'text/plain'
|
448
|
+
@content_disposition = 'attachment; filename=sample.txt'
|
449
|
+
perform_request(
|
450
|
+
'response-expires' => @expires,
|
451
|
+
'response-content-type' => @content_type,
|
452
|
+
'response-content-disposition' => @content_disposition
|
453
|
+
) do |response|
|
454
|
+
assert_equal response['Expires'], @expires
|
455
|
+
assert_equal response['Content-Type'], @content_type
|
456
|
+
assert_equal response['Content-Disposition'], @content_disposition
|
457
|
+
end
|
458
|
+
end
|
459
|
+
|
460
|
+
private
|
461
|
+
|
462
|
+
def request( uri )
|
463
|
+
url = URI.parse( uri )
|
464
|
+
|
465
|
+
http = Net::HTTP.new(url.host, 443)
|
466
|
+
http.use_ssl = true
|
467
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
468
|
+
http.request(Net::HTTP::Get.new( url.request_uri ))
|
469
|
+
end
|
470
|
+
|
471
|
+
def perform_request( headers, &block )
|
472
|
+
@s3.create_bucket( @bucket )
|
473
|
+
@s3.put( @bucket, @key2, RIGHT_OBJECT_TEXT )
|
474
|
+
response = request( @s3.get_link( @bucket, @key2, nil, {}, headers ) )
|
475
|
+
block.call( response )
|
476
|
+
@s3.force_delete_bucket(@bucket)
|
419
477
|
end
|
420
478
|
|
421
479
|
end
|