fog 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +6 -0
- data/LICENSE +20 -0
- data/README.rdoc +7 -0
- data/Rakefile +98 -0
- data/VERSION +1 -0
- data/benchs/fog_vs.rb +135 -0
- data/benchs/headers_split_vs_match.rb +18 -0
- data/benchs/params.rb +43 -0
- data/benchs/parse_vs_push.rb +60 -0
- data/benchs/stripping.rb +26 -0
- data/lib/fog.rb +21 -0
- data/lib/fog/aws.rb +145 -0
- data/lib/fog/aws/ec2.rb +173 -0
- data/lib/fog/aws/models/ec2/address.rb +31 -0
- data/lib/fog/aws/models/ec2/addresses.rb +36 -0
- data/lib/fog/aws/models/ec2/key_pair.rb +35 -0
- data/lib/fog/aws/models/ec2/key_pairs.rb +36 -0
- data/lib/fog/aws/models/ec2/volume.rb +47 -0
- data/lib/fog/aws/models/ec2/volumes.rb +36 -0
- data/lib/fog/aws/models/s3/bucket.rb +77 -0
- data/lib/fog/aws/models/s3/buckets.rb +83 -0
- data/lib/fog/aws/models/s3/object.rb +76 -0
- data/lib/fog/aws/models/s3/objects.rb +97 -0
- data/lib/fog/aws/models/s3/owner.rb +18 -0
- data/lib/fog/aws/parsers/ec2/allocate_address.rb +19 -0
- data/lib/fog/aws/parsers/ec2/attach_volume.rb +22 -0
- data/lib/fog/aws/parsers/ec2/basic.rb +25 -0
- data/lib/fog/aws/parsers/ec2/create_key_pair.rb +20 -0
- data/lib/fog/aws/parsers/ec2/create_snapshot.rb +22 -0
- data/lib/fog/aws/parsers/ec2/create_volume.rb +24 -0
- data/lib/fog/aws/parsers/ec2/describe_addresses.rb +30 -0
- data/lib/fog/aws/parsers/ec2/describe_availability_zones.rb +30 -0
- data/lib/fog/aws/parsers/ec2/describe_images.rb +49 -0
- data/lib/fog/aws/parsers/ec2/describe_instances.rb +73 -0
- data/lib/fog/aws/parsers/ec2/describe_key_pairs.rb +30 -0
- data/lib/fog/aws/parsers/ec2/describe_regions.rb +30 -0
- data/lib/fog/aws/parsers/ec2/describe_security_groups.rb +75 -0
- data/lib/fog/aws/parsers/ec2/describe_snapshots.rb +30 -0
- data/lib/fog/aws/parsers/ec2/describe_volumes.rb +57 -0
- data/lib/fog/aws/parsers/ec2/detach_volume.rb +22 -0
- data/lib/fog/aws/parsers/ec2/get_console_output.rb +28 -0
- data/lib/fog/aws/parsers/ec2/run_instances.rb +65 -0
- data/lib/fog/aws/parsers/ec2/terminate_instances.rb +55 -0
- data/lib/fog/aws/parsers/s3/copy_object.rb +22 -0
- data/lib/fog/aws/parsers/s3/get_bucket.rb +46 -0
- data/lib/fog/aws/parsers/s3/get_bucket_location.rb +20 -0
- data/lib/fog/aws/parsers/s3/get_request_payment.rb +20 -0
- data/lib/fog/aws/parsers/s3/get_service.rb +32 -0
- data/lib/fog/aws/parsers/simpledb/basic.rb +31 -0
- data/lib/fog/aws/parsers/simpledb/domain_metadata.rb +30 -0
- data/lib/fog/aws/parsers/simpledb/get_attributes.rb +34 -0
- data/lib/fog/aws/parsers/simpledb/list_domains.rb +28 -0
- data/lib/fog/aws/parsers/simpledb/select.rb +39 -0
- data/lib/fog/aws/requests/ec2/allocate_address.rb +50 -0
- data/lib/fog/aws/requests/ec2/associate_address.rb +59 -0
- data/lib/fog/aws/requests/ec2/attach_volume.rb +71 -0
- data/lib/fog/aws/requests/ec2/authorize_security_group_ingress.rb +32 -0
- data/lib/fog/aws/requests/ec2/create_key_pair.rb +60 -0
- data/lib/fog/aws/requests/ec2/create_security_group.rb +61 -0
- data/lib/fog/aws/requests/ec2/create_snapshot.rb +65 -0
- data/lib/fog/aws/requests/ec2/create_volume.rb +66 -0
- data/lib/fog/aws/requests/ec2/delete_key_pair.rb +49 -0
- data/lib/fog/aws/requests/ec2/delete_security_group.rb +52 -0
- data/lib/fog/aws/requests/ec2/delete_snapshot.rb +53 -0
- data/lib/fog/aws/requests/ec2/delete_volume.rb +55 -0
- data/lib/fog/aws/requests/ec2/describe_addresses.rb +61 -0
- data/lib/fog/aws/requests/ec2/describe_availability_zones.rb +64 -0
- data/lib/fog/aws/requests/ec2/describe_images.rb +41 -0
- data/lib/fog/aws/requests/ec2/describe_instances.rb +114 -0
- data/lib/fog/aws/requests/ec2/describe_key_pairs.rb +63 -0
- data/lib/fog/aws/requests/ec2/describe_regions.rb +61 -0
- data/lib/fog/aws/requests/ec2/describe_security_groups.rb +71 -0
- data/lib/fog/aws/requests/ec2/describe_snapshots.rb +78 -0
- data/lib/fog/aws/requests/ec2/describe_volumes.rb +85 -0
- data/lib/fog/aws/requests/ec2/detach_volume.rb +62 -0
- data/lib/fog/aws/requests/ec2/disassociate_address.rb +55 -0
- data/lib/fog/aws/requests/ec2/get_console_output.rb +26 -0
- data/lib/fog/aws/requests/ec2/reboot_instances.rb +24 -0
- data/lib/fog/aws/requests/ec2/release_address.rb +50 -0
- data/lib/fog/aws/requests/ec2/revoke_security_group_ingress.rb +32 -0
- data/lib/fog/aws/requests/ec2/run_instances.rb +134 -0
- data/lib/fog/aws/requests/ec2/terminate_instances.rb +80 -0
- data/lib/fog/aws/requests/s3/copy_object.rb +79 -0
- data/lib/fog/aws/requests/s3/delete_bucket.rb +53 -0
- data/lib/fog/aws/requests/s3/delete_object.rb +52 -0
- data/lib/fog/aws/requests/s3/get_bucket.rb +100 -0
- data/lib/fog/aws/requests/s3/get_bucket_location.rb +53 -0
- data/lib/fog/aws/requests/s3/get_object.rb +82 -0
- data/lib/fog/aws/requests/s3/get_request_payment.rb +53 -0
- data/lib/fog/aws/requests/s3/get_service.rb +58 -0
- data/lib/fog/aws/requests/s3/head_object.rb +61 -0
- data/lib/fog/aws/requests/s3/put_bucket.rb +69 -0
- data/lib/fog/aws/requests/s3/put_object.rb +76 -0
- data/lib/fog/aws/requests/s3/put_request_payment.rb +56 -0
- data/lib/fog/aws/requests/simpledb/batch_put_attributes.rb +31 -0
- data/lib/fog/aws/requests/simpledb/create_domain.rb +25 -0
- data/lib/fog/aws/requests/simpledb/delete_attributes.rb +34 -0
- data/lib/fog/aws/requests/simpledb/delete_domain.rb +25 -0
- data/lib/fog/aws/requests/simpledb/domain_metadata.rb +30 -0
- data/lib/fog/aws/requests/simpledb/get_attributes.rb +35 -0
- data/lib/fog/aws/requests/simpledb/list_domains.rb +30 -0
- data/lib/fog/aws/requests/simpledb/put_attributes.rb +29 -0
- data/lib/fog/aws/requests/simpledb/select.rb +29 -0
- data/lib/fog/aws/s3.rb +157 -0
- data/lib/fog/aws/simpledb.rb +157 -0
- data/lib/fog/collection.rb +77 -0
- data/lib/fog/connection.rb +130 -0
- data/lib/fog/errors.rb +145 -0
- data/lib/fog/model.rb +72 -0
- data/lib/fog/parser.rb +30 -0
- data/lib/fog/response.rb +12 -0
- data/spec/aws/models/s3/bucket_spec.rb +130 -0
- data/spec/aws/models/s3/buckets_spec.rb +79 -0
- data/spec/aws/models/s3/object_spec.rb +121 -0
- data/spec/aws/models/s3/objects_spec.rb +112 -0
- data/spec/aws/models/s3/owner_spec.rb +18 -0
- data/spec/aws/requests/ec2/allocate_address_spec.rb +18 -0
- data/spec/aws/requests/ec2/associate_address_spec.rb +42 -0
- data/spec/aws/requests/ec2/attach_volume_spec.rb +53 -0
- data/spec/aws/requests/ec2/authorize_security_group_ingress_spec.rb +26 -0
- data/spec/aws/requests/ec2/create_key_pair_spec.rb +36 -0
- data/spec/aws/requests/ec2/create_security_group_spec.rb +34 -0
- data/spec/aws/requests/ec2/create_snapshot_spec.rb +37 -0
- data/spec/aws/requests/ec2/create_volume_spec.rb +23 -0
- data/spec/aws/requests/ec2/delete_key_pair_spec.rb +21 -0
- data/spec/aws/requests/ec2/delete_security_group_spec.rb +26 -0
- data/spec/aws/requests/ec2/delete_snapshot_spec.rb +35 -0
- data/spec/aws/requests/ec2/delete_volume_spec.rb +26 -0
- data/spec/aws/requests/ec2/describe_addresses_spec.rb +38 -0
- data/spec/aws/requests/ec2/describe_availability_zones_spec.rb +23 -0
- data/spec/aws/requests/ec2/describe_images_spec.rb +39 -0
- data/spec/aws/requests/ec2/describe_instances_spec.rb +86 -0
- data/spec/aws/requests/ec2/describe_key_pairs_spec.rb +42 -0
- data/spec/aws/requests/ec2/describe_regions_spec.rb +21 -0
- data/spec/aws/requests/ec2/describe_security_groups_spec.rb +51 -0
- data/spec/aws/requests/ec2/describe_snapshots_spec.rb +54 -0
- data/spec/aws/requests/ec2/describe_volumes_spec.rb +50 -0
- data/spec/aws/requests/ec2/detach_volume_spec.rb +43 -0
- data/spec/aws/requests/ec2/disassociate_address_spec.rb +35 -0
- data/spec/aws/requests/ec2/get_console_output_spec.rb +23 -0
- data/spec/aws/requests/ec2/reboot_instances_spec.rb +21 -0
- data/spec/aws/requests/ec2/release_address_spec.rb +26 -0
- data/spec/aws/requests/ec2/revoke_security_group_ingress_spec.rb +32 -0
- data/spec/aws/requests/ec2/run_instances_spec.rb +41 -0
- data/spec/aws/requests/ec2/terminate_instances_spec.rb +35 -0
- data/spec/aws/requests/s3/copy_object_spec.rb +62 -0
- data/spec/aws/requests/s3/delete_bucket_spec.rb +36 -0
- data/spec/aws/requests/s3/delete_object_spec.rb +37 -0
- data/spec/aws/requests/s3/get_bucket_location_spec.rb +30 -0
- data/spec/aws/requests/s3/get_bucket_spec.rb +110 -0
- data/spec/aws/requests/s3/get_object_spec.rb +45 -0
- data/spec/aws/requests/s3/get_request_payment_spec.rb +30 -0
- data/spec/aws/requests/s3/get_service_spec.rb +33 -0
- data/spec/aws/requests/s3/head_object_spec.rb +28 -0
- data/spec/aws/requests/s3/put_bucket_spec.rb +19 -0
- data/spec/aws/requests/s3/put_object_spec.rb +38 -0
- data/spec/aws/requests/s3/put_request_payment_spec.rb +29 -0
- data/spec/aws/requests/simpledb/batch_put_attributes_spec.rb +22 -0
- data/spec/aws/requests/simpledb/create_domain_spec.rb +21 -0
- data/spec/aws/requests/simpledb/delete_attributes_spec.rb +22 -0
- data/spec/aws/requests/simpledb/delete_domain_spec.rb +21 -0
- data/spec/aws/requests/simpledb/domain_metadata_spec.rb +43 -0
- data/spec/aws/requests/simpledb/get_attributes_spec.rb +31 -0
- data/spec/aws/requests/simpledb/list_domains_spec.rb +30 -0
- data/spec/aws/requests/simpledb/put_attributes_spec.rb +22 -0
- data/spec/aws/requests/simpledb/select_spec.rb +9 -0
- data/spec/lorem.txt +1 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +66 -0
- metadata +309 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.describe_key_pairs' do
|
4
|
+
describe 'success' do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
ec2.create_key_pair('fog_key_name')
|
8
|
+
end
|
9
|
+
|
10
|
+
after(:each) do
|
11
|
+
ec2.delete_key_pair('fog_key_name')
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should return proper attributes with no params" do
|
15
|
+
actual = ec2.describe_key_pairs
|
16
|
+
actual.body['keySet'].should be_an(Array)
|
17
|
+
actual.body['requestId'].should be_a(String)
|
18
|
+
key_pair = actual.body['keySet'].select {|key| key['keyName'] == 'fog_key_name' }.first
|
19
|
+
key_pair['keyFingerprint'].should be_a(String)
|
20
|
+
key_pair['keyName'].should be_a(String)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should return proper attributes with params" do
|
24
|
+
actual = ec2.describe_key_pairs('fog_key_name')
|
25
|
+
actual.body['keySet'].should be_an(Array)
|
26
|
+
actual.body['requestId'].should be_a(String)
|
27
|
+
key_pair = actual.body['keySet'].select {|key| key['keyName'] == 'fog_key_name' }.first
|
28
|
+
key_pair['keyFingerprint'].should be_a(String)
|
29
|
+
key_pair['keyName'].should be_a(String)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
describe 'failure' do
|
34
|
+
|
35
|
+
it "should raise a BadRequest error if the key does not exist" do
|
36
|
+
lambda {
|
37
|
+
ec2.describe_key_pairs('fog_not_a_key_name')
|
38
|
+
}.should raise_error(Fog::Errors::BadRequest)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.describe_availability_zones' do
|
4
|
+
describe 'success' do
|
5
|
+
|
6
|
+
it "should return proper attributes with no params" do
|
7
|
+
actual = ec2.describe_regions
|
8
|
+
zone = actual.body['regionInfo'].first
|
9
|
+
zone['regionEndpoint'].should be_a(String)
|
10
|
+
zone['regionName'].should be_a(String)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should return proper attribute with params" do
|
14
|
+
actual = ec2.describe_regions(['us-east-1'])
|
15
|
+
zone = actual.body['regionInfo'].first
|
16
|
+
zone['regionEndpoint'].should be_a(String)
|
17
|
+
zone['regionName'].should be_a(String)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.describe_security_groups' do
|
4
|
+
describe 'success' do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
ec2.create_security_group('fog_security_group', 'a security group for testing fog')
|
8
|
+
end
|
9
|
+
|
10
|
+
after(:each) do
|
11
|
+
ec2.delete_security_group('fog_security_group')
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should return proper attributes with no params" do
|
15
|
+
actual = ec2.describe_security_groups
|
16
|
+
actual.body['requestId'].should be_a(String)
|
17
|
+
actual.body['securityGroupInfo'].should be_an(Array)
|
18
|
+
security_group = actual.body['securityGroupInfo'].select do |security_group|
|
19
|
+
security_group['groupName'] == 'default'
|
20
|
+
end.first
|
21
|
+
security_group['groupDescription'].should be_a(String)
|
22
|
+
security_group['groupName'].should be_a(String)
|
23
|
+
security_group['ownerId'].should be_a(String)
|
24
|
+
security_group['ipPermissions'].should be_an(Array)
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should return proper attributes with params" do
|
29
|
+
actual = ec2.describe_security_groups('fog_security_group')
|
30
|
+
actual.body['requestId'].should be_a(String)
|
31
|
+
actual.body['securityGroupInfo'].should be_an(Array)
|
32
|
+
security_group = actual.body['securityGroupInfo'].select do |security_group|
|
33
|
+
security_group['groupName'] == 'fog_security_group'
|
34
|
+
end.first
|
35
|
+
security_group['groupDescription'].should be_a(String)
|
36
|
+
security_group['groupName'].should be_a(String)
|
37
|
+
security_group['ownerId'].should be_a(String)
|
38
|
+
security_group['ipPermissions'].should be_an(Array)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
describe 'failure' do
|
43
|
+
|
44
|
+
it "should raise a BadRequest error if the security group does not exist" do
|
45
|
+
lambda {
|
46
|
+
ec2.describe_security_groups('not_a_security_group')
|
47
|
+
}.should raise_error(Fog::Errors::BadRequest)
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.describe_snapshots' do
|
4
|
+
describe 'success' do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@volume_id = ec2.create_volume('us-east-1a', 1).body['volumeId']
|
8
|
+
@snapshot_id = ec2.create_snapshot(@volume_id).body['snapshotId']
|
9
|
+
end
|
10
|
+
|
11
|
+
after(:each) do
|
12
|
+
ec2.delete_volume(@volume_id)
|
13
|
+
eventually do
|
14
|
+
ec2.delete_snapshot(@snapshot_id)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should return proper attributes with no params" do
|
19
|
+
eventually do
|
20
|
+
actual = ec2.describe_snapshots
|
21
|
+
actual.body['snapshotSet'].should be_an(Array)
|
22
|
+
snapshot = actual.body['snapshotSet'].select {|snapshot| snapshot['snapshotId'] == @snapshot_id}.first
|
23
|
+
snapshot['progress'].should be_a(String)
|
24
|
+
snapshot['snapshotId'].should be_a(String)
|
25
|
+
snapshot['startTime'].should be_a(Time)
|
26
|
+
snapshot['status'].should be_a(String)
|
27
|
+
snapshot['volumeId'].should be_a(String)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should return proper attributes with params" do
|
32
|
+
eventually do
|
33
|
+
actual = ec2.describe_snapshots([@snapshot_id])
|
34
|
+
actual.body['snapshotSet'].should be_an(Array)
|
35
|
+
snapshot = actual.body['snapshotSet'].select {|snapshot| snapshot['snapshotId'] == @snapshot_id}.first
|
36
|
+
snapshot['progress'].should be_a(String)
|
37
|
+
snapshot['snapshotId'].should be_a(String)
|
38
|
+
snapshot['startTime'].should be_a(Time)
|
39
|
+
snapshot['status'].should be_a(String)
|
40
|
+
snapshot['volumeId'].should be_a(String)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
describe 'failure' do
|
46
|
+
|
47
|
+
it "should raise a BadRequest error if the snapshot does not exist" do
|
48
|
+
lambda {
|
49
|
+
ec2.describe_snapshots('snap-00000000')
|
50
|
+
}.should raise_error(Fog::Errors::BadRequest)
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.describe_volumes' do
|
4
|
+
describe 'success' do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@volume_id = ec2.create_volume('us-east-1a', 1).body['volumeId']
|
8
|
+
end
|
9
|
+
|
10
|
+
after(:each) do
|
11
|
+
ec2.delete_volume(@volume_id)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should return proper attributes with no params" do
|
15
|
+
actual = ec2.describe_volumes
|
16
|
+
actual.body['requestId'].should be_a(String)
|
17
|
+
volume = actual.body['volumeSet'].select {|volume| volume['volumeId'] == @volume_id}.first
|
18
|
+
volume['availabilityZone'].should be_a(String)
|
19
|
+
volume['createTime'].should be_a(Time)
|
20
|
+
volume['size'].should == 1
|
21
|
+
volume['snapshotId'].should == ''
|
22
|
+
volume['status'].should be_a(String)
|
23
|
+
volume['volumeId'].should == @volume_id
|
24
|
+
volume['attachmentSet'].should == []
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return proper attributes for specific volume" do
|
28
|
+
actual = ec2.describe_volumes(@volume_id)
|
29
|
+
actual.body['requestId'].should be_a(String)
|
30
|
+
volume = actual.body['volumeSet'].select {|volume| volume['volumeId'] == @volume_id}.first
|
31
|
+
volume['availabilityZone'].should be_a(String)
|
32
|
+
volume['createTime'].should be_a(Time)
|
33
|
+
volume['size'].should == 1
|
34
|
+
volume['snapshotId'].should == ''
|
35
|
+
volume['status'].should be_a(String)
|
36
|
+
volume['volumeId'].should == @volume_id
|
37
|
+
volume['attachmentSet'].should == []
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
describe 'failure' do
|
42
|
+
|
43
|
+
it "should raise a BadRequest error if volume does not exist" do
|
44
|
+
lambda {
|
45
|
+
ec2.describe_volumes('vol-00000000')
|
46
|
+
}.should raise_error(Fog::Errors::BadRequest)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.detach_volume' do
|
4
|
+
describe 'success' do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@instance_id = ec2.run_instances('ami-5ee70037', 1, 1, {'Placement.AvailabilityZone' => 'us-east-1a'}).body['instancesSet'].first['instanceId']
|
8
|
+
@volume_id = ec2.create_volume('us-east-1a', 1).body['volumeId']
|
9
|
+
eventually(128) do
|
10
|
+
ec2.attach_volume(@instance_id, @volume_id, '/dev/sdh')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
after(:each) do
|
15
|
+
eventually do
|
16
|
+
ec2.delete_volume(@volume_id)
|
17
|
+
ec2.terminate_instances([@instance_id])
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should return proper attributes" do
|
22
|
+
eventually do
|
23
|
+
actual = ec2.detach_volume(@volume_id)
|
24
|
+
actual.body['attachTime'].should be_a(Time)
|
25
|
+
actual.body['device'].should be_a(String)
|
26
|
+
actual.body['instanceId'].should be_a(String)
|
27
|
+
actual.body['requestId'].should be_a(String)
|
28
|
+
actual.body['status'].should be_a(String)
|
29
|
+
actual.body['volumeId'].should be_a(String)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
describe 'failure' do
|
35
|
+
|
36
|
+
it "should raise a BadRequest error if the volume does not exist" do
|
37
|
+
lambda {
|
38
|
+
ec2.detach_volume('vol-00000000')
|
39
|
+
}.should raise_error(Fog::Errors::BadRequest)
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.disassociate_address' do
|
4
|
+
describe 'success' do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@instance_id = ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
|
8
|
+
@public_ip = ec2.allocate_address.body['publicIp']
|
9
|
+
ec2.associate_address(@instance_id, @public_ip)
|
10
|
+
end
|
11
|
+
|
12
|
+
after(:each) do
|
13
|
+
ec2.release_address(@public_ip)
|
14
|
+
ec2.terminate_instances([@instance_id])
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should return proper attributes" do
|
18
|
+
actual = ec2.disassociate_address(@public_ip)
|
19
|
+
actual.body['requestId'].should be_a(String)
|
20
|
+
[false, true].should include(actual.body['return'])
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'failure' do
|
26
|
+
|
27
|
+
it "should raise a BadRequest error if the address does not exist" do
|
28
|
+
lambda {
|
29
|
+
ec2.disassociate_address('127.0.0.1')
|
30
|
+
}.should raise_error(Fog::Errors::BadRequest)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.get_console_output' do
|
4
|
+
describe 'success' do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@instance_id = ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
|
8
|
+
end
|
9
|
+
|
10
|
+
after(:each) do
|
11
|
+
ec2.terminate_instances([@instance_id])
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should return proper attributes" do
|
15
|
+
actual = ec2.get_console_output(@instance_id)
|
16
|
+
actual.body['instanceId'].should be_a(String)
|
17
|
+
actual.body['output'].should be_a(String)
|
18
|
+
actual.body['requestId'].should be_a(String)
|
19
|
+
actual.body['timestamp'].should be_a(Time)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.reboot_instances' do
|
4
|
+
describe 'success' do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@instance_id = ec2.run_instances('ami-5ee70037', 1, 1).body['instancesSet'].first['instanceId']
|
8
|
+
end
|
9
|
+
|
10
|
+
after(:each) do
|
11
|
+
ec2.terminate_instances([@instance_id])
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should return proper attributes" do
|
15
|
+
actual = ec2.reboot_instances([@instance_id])
|
16
|
+
actual.body['requestId'].should be_a(String)
|
17
|
+
[false, true].should include(actual.body['return'])
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.release_address' do
|
4
|
+
describe 'success' do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@public_ip = ec2.allocate_address.body['publicIp']
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should return proper attributes" do
|
11
|
+
actual = ec2.release_address(@public_ip)
|
12
|
+
actual.body['requestId'].should be_a(String)
|
13
|
+
actual.body['return'].should == true
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
describe 'failure' do
|
18
|
+
|
19
|
+
it "should raise a BadRequest error if address does not exist" do
|
20
|
+
lambda {
|
21
|
+
ec2.release_address('127.0.0.1')
|
22
|
+
}.should raise_error(Fog::Errors::BadRequest)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.revoke_security_group_ingress' do
|
4
|
+
describe 'success' do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
ec2.create_security_group('fog_security_group', 'a security group for testing fog')
|
8
|
+
ec2.authorize_security_group_ingress({
|
9
|
+
'FromPort' => 80,
|
10
|
+
'GroupName' => 'fog_security_group',
|
11
|
+
'IpProtocol' => 'tcp',
|
12
|
+
'ToPort' => 80
|
13
|
+
})
|
14
|
+
end
|
15
|
+
|
16
|
+
after(:each) do
|
17
|
+
ec2.delete_security_group('fog_security_group')
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should return proper attributes" do
|
21
|
+
actual = ec2.revoke_security_group_ingress({
|
22
|
+
'FromPort' => 80,
|
23
|
+
'GroupName' => 'fog_security_group',
|
24
|
+
'IpProtocol' => 'tcp',
|
25
|
+
'ToPort' => 80
|
26
|
+
})
|
27
|
+
actual.body['requestId'].should be_a(String)
|
28
|
+
[false, true].should include(actual.body['return'])
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe 'EC2.run_instances' do
|
4
|
+
describe 'success' do
|
5
|
+
|
6
|
+
after(:each) do
|
7
|
+
ec2.terminate_instances([@instance_id])
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should return proper attributes" do
|
11
|
+
actual = ec2.run_instances('ami-5ee70037', 1, 1)
|
12
|
+
@instance_id = actual.body['instancesSet'].first['instanceId']
|
13
|
+
actual.body['groupSet'].should be_an(Array)
|
14
|
+
actual.body['groupSet'].first.should be_a(String)
|
15
|
+
actual.body['instancesSet'].should be_an(Array)
|
16
|
+
instance = actual.body['instancesSet'].first
|
17
|
+
instance['amiLaunchIndex'].should be_a(Integer)
|
18
|
+
instance['dnsName'].should be_a(String)
|
19
|
+
instance['imageId'].should be_a(String)
|
20
|
+
instance['instanceId'].should be_a(String)
|
21
|
+
instance['instanceState'].should be_an(Hash)
|
22
|
+
instance['instanceState']['code'].should be_an(Integer)
|
23
|
+
instance['instanceState']['name'].should be_an(String)
|
24
|
+
instance['instanceType'].should be_a(String)
|
25
|
+
instance['kernelId'].should be_a(String)
|
26
|
+
instance['keyName'].should be_a(String) if instance['keyName']
|
27
|
+
instance['launchTime'].should be_a(Time)
|
28
|
+
instance['monitoring'].should be_a(Hash)
|
29
|
+
[false, true].should include(instance['monitoring']['state'])
|
30
|
+
instance['placement'].should be_a(Hash)
|
31
|
+
instance['placement']['availabilityZone'].should be_a(String)
|
32
|
+
instance['privateDnsName'].should be_a(String)
|
33
|
+
instance['ramdiskId'].should be_a(String)
|
34
|
+
instance['reason'].should be_a(String)
|
35
|
+
actual.body['ownerId'].should be_a(String)
|
36
|
+
actual.body['requestId'].should be_a(String)
|
37
|
+
actual.body['reservationId'].should be_a(String)
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|