fog-digitalocean 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.document +3 -0
- data/.gitignore +30 -0
- data/.irbrc +82 -0
- data/.rubocop.yml +20 -0
- data/.rubocop_todo.yml +606 -0
- data/.travis.yml +35 -0
- data/CHANGELOG.md +3 -0
- data/CONTRIBUTING.md +276 -0
- data/CONTRIBUTORS.md +898 -0
- data/Gemfile +5 -0
- data/LICENSE.md +20 -0
- data/README.md +130 -0
- data/RELEASE.md +40 -0
- data/Rakefile +12 -0
- data/benchs/each_provider.sh +6 -0
- data/benchs/each_service.sh +6 -0
- data/benchs/fog_vs.rb +106 -0
- data/benchs/load_times.rb +37 -0
- data/benchs/params.rb +43 -0
- data/benchs/parse_vs_push.rb +67 -0
- data/bin/fog +78 -0
- data/fog-digitalocean.gemspec +61 -0
- data/gemfiles/Gemfile-edge +14 -0
- data/lib/fog/digitalocean.rb +1 -0
- data/lib/fog/digitalocean/CHANGELOG.md +6 -0
- data/lib/fog/digitalocean/compute.rb +109 -0
- data/lib/fog/digitalocean/core.rb +9 -0
- data/lib/fog/digitalocean/examples/getting_started.md +123 -0
- data/lib/fog/digitalocean/models/compute/flavor.rb +17 -0
- data/lib/fog/digitalocean/models/compute/flavors.rb +21 -0
- data/lib/fog/digitalocean/models/compute/image.rb +25 -0
- data/lib/fog/digitalocean/models/compute/images.rb +42 -0
- data/lib/fog/digitalocean/models/compute/region.rb +13 -0
- data/lib/fog/digitalocean/models/compute/regions.rb +21 -0
- data/lib/fog/digitalocean/models/compute/server.rb +170 -0
- data/lib/fog/digitalocean/models/compute/servers.rb +43 -0
- data/lib/fog/digitalocean/models/compute/ssh_key.rb +31 -0
- data/lib/fog/digitalocean/models/compute/ssh_keys.rb +40 -0
- data/lib/fog/digitalocean/models/paging_collection.rb +42 -0
- data/lib/fog/digitalocean/requests/compute/change_kernel.rb +44 -0
- data/lib/fog/digitalocean/requests/compute/convert_to_snapshot.rb +44 -0
- data/lib/fog/digitalocean/requests/compute/create_server.rb +93 -0
- data/lib/fog/digitalocean/requests/compute/create_ssh_key.rb +49 -0
- data/lib/fog/digitalocean/requests/compute/delete_ssh_key.rb +32 -0
- data/lib/fog/digitalocean/requests/compute/destroy_server.rb +35 -0
- data/lib/fog/digitalocean/requests/compute/disable_backups.rb +45 -0
- data/lib/fog/digitalocean/requests/compute/enable_ipv6.rb +44 -0
- data/lib/fog/digitalocean/requests/compute/enable_private_networking.rb +44 -0
- data/lib/fog/digitalocean/requests/compute/get_droplet_action.rb +36 -0
- data/lib/fog/digitalocean/requests/compute/get_image_details.rb +42 -0
- data/lib/fog/digitalocean/requests/compute/get_server_details.rb +84 -0
- data/lib/fog/digitalocean/requests/compute/get_ssh_key.rb +34 -0
- data/lib/fog/digitalocean/requests/compute/list_droplet_actions.rb +38 -0
- data/lib/fog/digitalocean/requests/compute/list_flavors.rb +132 -0
- data/lib/fog/digitalocean/requests/compute/list_images.rb +51 -0
- data/lib/fog/digitalocean/requests/compute/list_regions.rb +95 -0
- data/lib/fog/digitalocean/requests/compute/list_servers.rb +33 -0
- data/lib/fog/digitalocean/requests/compute/list_ssh_keys.rb +41 -0
- data/lib/fog/digitalocean/requests/compute/password_reset.rb +44 -0
- data/lib/fog/digitalocean/requests/compute/power_cycle.rb +44 -0
- data/lib/fog/digitalocean/requests/compute/power_off.rb +44 -0
- data/lib/fog/digitalocean/requests/compute/power_on.rb +44 -0
- data/lib/fog/digitalocean/requests/compute/reboot_server.rb +44 -0
- data/lib/fog/digitalocean/requests/compute/rebuild.rb +44 -0
- data/lib/fog/digitalocean/requests/compute/rename.rb +44 -0
- data/lib/fog/digitalocean/requests/compute/resize.rb +48 -0
- data/lib/fog/digitalocean/requests/compute/restore.rb +44 -0
- data/lib/fog/digitalocean/requests/compute/shutdown.rb +44 -0
- data/lib/fog/digitalocean/requests/compute/snapshot.rb +44 -0
- data/lib/fog/digitalocean/requests/compute/transfer_image.rb +44 -0
- data/lib/fog/digitalocean/requests/compute/update_ssh_key.rb +46 -0
- data/lib/fog/digitalocean/requests/compute/upgrade.rb +44 -0
- data/lib/fog/digitalocean/service.rb +51 -0
- data/lib/fog/digitalocean/version.rb +5 -0
- data/spec/fog/account_spec.rb +14 -0
- data/spec/fog/billing_spec.rb +14 -0
- data/spec/fog/bin/atmos_spec.rb +33 -0
- data/spec/fog/bin/aws_spec.rb +98 -0
- data/spec/fog/bin/baremetalcloud_spec.rb +33 -0
- data/spec/fog/bin/bluebox_spec.rb +55 -0
- data/spec/fog/bin/brightbox_spec.rb +30 -0
- data/spec/fog/bin/clodo_spec.rb +9 -0
- data/spec/fog/bin/cloudsigma_spec.rb +9 -0
- data/spec/fog/bin/cloudstack_spec.rb +9 -0
- data/spec/fog/bin/digitalocean_spec.rb +9 -0
- data/spec/fog/bin/dnsimple_spec.rb +9 -0
- data/spec/fog/bin/dnsmadeeasy_spec.rb +9 -0
- data/spec/fog/bin/dreamhost_spec.rb +9 -0
- data/spec/fog/bin/dynect_spec.rb +9 -0
- data/spec/fog/bin/ecloud_spec.rb +10 -0
- data/spec/fog/bin/fogdocker_spec.rb +10 -0
- data/spec/fog/bin/glesys_spec.rb +10 -0
- data/spec/fog/bin/gogrid_spec.rb +10 -0
- data/spec/fog/bin/google_spec.rb +10 -0
- data/spec/fog/bin/ibm_spec.rb +10 -0
- data/spec/fog/bin/internetarchive_spec.rb +10 -0
- data/spec/fog/bin/joyent_spec.rb +10 -0
- data/spec/fog/bin/linode_spec.rb +10 -0
- data/spec/fog/bin/local_spec.rb +10 -0
- data/spec/fog/bin/ninefold_spec.rb +10 -0
- data/spec/fog/bin/opennebula_spec.rb +10 -0
- data/spec/fog/bin/openstack_spec.rb +10 -0
- data/spec/fog/bin/openvz_spec.rb +10 -0
- data/spec/fog/bin/ovirt_spec.rb +10 -0
- data/spec/fog/bin/powerdns_spec.rb +9 -0
- data/spec/fog/bin/profitbricks_spec.rb +10 -0
- data/spec/fog/bin/rackspace_spec.rb +10 -0
- data/spec/fog/bin/rage4_spec.rb +10 -0
- data/spec/fog/bin/riakcs_spec.rb +10 -0
- data/spec/fog/bin/sakuracloud_spec.rb +10 -0
- data/spec/fog/bin/serverlove_spec.rb +10 -0
- data/spec/fog/bin/softlayer_spec.rb +10 -0
- data/spec/fog/bin/stormondemand_spec.rb +10 -0
- data/spec/fog/bin/vcloud_spec.rb +10 -0
- data/spec/fog/bin/vclouddirector_spec.rb +10 -0
- data/spec/fog/bin/vmfusion_spec.rb +10 -0
- data/spec/fog/bin/voxel_spec.rb +10 -0
- data/spec/fog/bin/vsphere_spec.rb +10 -0
- data/spec/fog/bin/xenserver_spec.rb +10 -0
- data/spec/fog/bin/zerigo_spec.rb +10 -0
- data/spec/fog/bin_spec.rb +161 -0
- data/spec/fog/cdn_spec.rb +14 -0
- data/spec/fog/compute_spec.rb +19 -0
- data/spec/fog/dns_spec.rb +19 -0
- data/spec/fog/identity_spec.rb +14 -0
- data/spec/fog/image_spec.rb +14 -0
- data/spec/fog/metering_spec.rb +14 -0
- data/spec/fog/monitoring_spec.rb +14 -0
- data/spec/fog/network_spec.rb +14 -0
- data/spec/fog/orchestration_spec.rb +14 -0
- data/spec/fog/storage_spec.rb +14 -0
- data/spec/fog/support_spec.rb +14 -0
- data/spec/fog/volume_spec.rb +14 -0
- data/spec/fog/vpn_spec.rb +14 -0
- data/spec/fog/xml/connection_spec.rb +33 -0
- data/spec/helpers/bin.rb +34 -0
- data/spec/spec_helper.rb +18 -0
- data/tests/digitalocean/helper.rb +56 -0
- data/tests/digitalocean/requests/compute/list_flavors_tests.rb +25 -0
- data/tests/digitalocean/requests/compute/list_images_tests.rb +25 -0
- data/tests/digitalocean/requests/compute/list_regions_tests.rb +21 -0
- data/tests/digitalocean/requests/compute/server_tests.rb +77 -0
- data/tests/digitalocean/requests/compute_v2/list_ssh_keys_tests.rb +20 -0
- data/tests/helper.rb +25 -0
- data/tests/helpers/format_helper.rb +100 -0
- data/tests/helpers/mock_helper.rb +14 -0
- data/tests/helpers/succeeds_helper.rb +10 -0
- data/tests/lorem.txt +1 -0
- data/tests/watchr.rb +22 -0
- metadata +428 -0
@@ -0,0 +1,44 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class DigitalOcean
|
4
|
+
class Real
|
5
|
+
def shutdown(id)
|
6
|
+
body = { :type => "shutdown" }
|
7
|
+
|
8
|
+
encoded_body = Fog::JSON.encode(body)
|
9
|
+
|
10
|
+
request(
|
11
|
+
:expects => [201],
|
12
|
+
:headers => {
|
13
|
+
'Content-Type' => "application/json; charset=UTF-8",
|
14
|
+
},
|
15
|
+
:method => 'POST',
|
16
|
+
:path => "v2/droplets/#{id}/actions",
|
17
|
+
:body => encoded_body,
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class Mock
|
23
|
+
def shutdown(id)
|
24
|
+
response = Excon::Response.new
|
25
|
+
response.status = 201
|
26
|
+
response.body = {
|
27
|
+
'action' => {
|
28
|
+
'id' => Fog::Mock.random_numbers(1).to_i,
|
29
|
+
'status' => "in-progress",
|
30
|
+
'type' => "shutdown",
|
31
|
+
'started_at' => "2014-11-14T16:31:00Z",
|
32
|
+
'completed_at' => null,
|
33
|
+
'resource_id' => id,
|
34
|
+
'resource_type' => "droplet",
|
35
|
+
'region' => "nyc3",
|
36
|
+
'region_slug' => "nyc3"
|
37
|
+
}
|
38
|
+
}
|
39
|
+
response
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class DigitalOcean
|
4
|
+
class Real
|
5
|
+
def snapshot(id, name)
|
6
|
+
body = { :type => "snapshot", :name => name }
|
7
|
+
|
8
|
+
encoded_body = Fog::JSON.encode(body)
|
9
|
+
|
10
|
+
request(
|
11
|
+
:expects => [201],
|
12
|
+
:headers => {
|
13
|
+
'Content-Type' => "application/json; charset=UTF-8",
|
14
|
+
},
|
15
|
+
:method => 'POST',
|
16
|
+
:path => "v2/droplets/#{id}/actions",
|
17
|
+
:body => encoded_body,
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class Mock
|
23
|
+
def snapshot(id, name)
|
24
|
+
response = Excon::Response.new
|
25
|
+
response.status = 201
|
26
|
+
response.body = {
|
27
|
+
'action' => {
|
28
|
+
'id' => Fog::Mock.random_numbers(1).to_i,
|
29
|
+
'status' => "in-progress",
|
30
|
+
'type' => "snapshot",
|
31
|
+
'started_at' => "2014-11-14T16:31:00Z",
|
32
|
+
'completed_at' => null,
|
33
|
+
'resource_id' => id,
|
34
|
+
'resource_type' => "droplet",
|
35
|
+
'region' => "nyc3",
|
36
|
+
'region_slug' => "nyc3"
|
37
|
+
}
|
38
|
+
}
|
39
|
+
response
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class DigitalOcean
|
4
|
+
class Real
|
5
|
+
def transfer_image(id, region)
|
6
|
+
body = { :type => 'transfer', :region => region }
|
7
|
+
|
8
|
+
encoded_body = Fog::JSON.encode(body)
|
9
|
+
|
10
|
+
request(
|
11
|
+
:expects => [201],
|
12
|
+
:headers => {
|
13
|
+
'Content-Type' => "application/json; charset=UTF-8",
|
14
|
+
},
|
15
|
+
:method => 'POST',
|
16
|
+
:path => "v2/images/#{id}/actions",
|
17
|
+
:body => encoded_body,
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class Mock
|
23
|
+
def transfer_image(id, name)
|
24
|
+
response = Excon::Response.new
|
25
|
+
response.status = 201
|
26
|
+
response.body = {
|
27
|
+
'action' => {
|
28
|
+
'id' => 36805527,
|
29
|
+
'status' => 'in-progress',
|
30
|
+
'type' => 'transfer',
|
31
|
+
'started_at' => '2014-11-14T16:42:45Z',
|
32
|
+
'completed_at' => null,
|
33
|
+
'resource_id' => 7938269,
|
34
|
+
'resource_type' => 'image',
|
35
|
+
'region' => 'nyc3',
|
36
|
+
'region_slug' => 'nyc3'
|
37
|
+
}
|
38
|
+
}
|
39
|
+
response
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class DigitalOcean
|
4
|
+
# noinspection RubyStringKeysInHashInspection
|
5
|
+
class Real
|
6
|
+
|
7
|
+
def update_ssh_key(key_id, name)
|
8
|
+
update_options = {
|
9
|
+
:name => name,
|
10
|
+
}
|
11
|
+
|
12
|
+
encoded_body = Fog::JSON.encode(update_options)
|
13
|
+
|
14
|
+
request(
|
15
|
+
:expects => [200],
|
16
|
+
:headers => {
|
17
|
+
'Content-Type' => "application/json; charset=UTF-8",
|
18
|
+
},
|
19
|
+
:method => 'PUT',
|
20
|
+
:path => "/v2/account/keys/#{key_id}",
|
21
|
+
:body => encoded_body,
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# noinspection RubyStringKeysInHashInspection
|
27
|
+
class Mock
|
28
|
+
def update_ssh_key(key_id, name)
|
29
|
+
response = Excon::Response.new
|
30
|
+
response.status = 200
|
31
|
+
|
32
|
+
response.body ={
|
33
|
+
'ssh_key' => {
|
34
|
+
'id' => 512190,
|
35
|
+
'fingerprint' => "3b:16:bf:e4:8b:00:8b:b8:59:8c:a9:d3:f0:19:45:fa",
|
36
|
+
'public_key' => "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAQQDDHr/jh2Jy4yALcK4JyWbVkPRaWmhck3IgCoeOO3z1e2dBowLh64QAM+Qb72pxekALga2oi4GvT+TlWNhzPH4V example",
|
37
|
+
'name' => "My SSH Public Key"
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
response
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class DigitalOcean
|
4
|
+
class Real
|
5
|
+
def upgrade(id)
|
6
|
+
body = { :type => "upgrade" }
|
7
|
+
|
8
|
+
encoded_body = Fog::JSON.encode(body)
|
9
|
+
|
10
|
+
request(
|
11
|
+
:expects => [201],
|
12
|
+
:headers => {
|
13
|
+
'Content-Type' => "application/json; charset=UTF-8",
|
14
|
+
},
|
15
|
+
:method => 'POST',
|
16
|
+
:path => "v2/droplets/#{id}/actions",
|
17
|
+
:body => encoded_body,
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class Mock
|
23
|
+
def upgrade(id)
|
24
|
+
response = Excon::Response.new
|
25
|
+
response.status = 201
|
26
|
+
response.body = {
|
27
|
+
'action' => {
|
28
|
+
'id' => Fog::Mock.random_numbers(1).to_i,
|
29
|
+
'status' => "in-progress",
|
30
|
+
'type' => "upgrade",
|
31
|
+
'started_at' => "2014-11-14T16:31:00Z",
|
32
|
+
'completed_at' => null,
|
33
|
+
'resource_id' => id,
|
34
|
+
'resource_type' => "droplet",
|
35
|
+
'region' => "nyc3",
|
36
|
+
'region_slug' => "nyc3"
|
37
|
+
}
|
38
|
+
}
|
39
|
+
response
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Fog
|
2
|
+
module DigitalOcean
|
3
|
+
class Service
|
4
|
+
|
5
|
+
def request(params, parse_json = true)
|
6
|
+
first_attempt = true
|
7
|
+
begin
|
8
|
+
response = @connection.request(request_params(params))
|
9
|
+
rescue Excon::Errors::Unauthorized => error
|
10
|
+
raise error unless first_attempt
|
11
|
+
first_attempt = false
|
12
|
+
authenticate
|
13
|
+
retry
|
14
|
+
end
|
15
|
+
|
16
|
+
process_response(response) if parse_json
|
17
|
+
response
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def process_response(response)
|
23
|
+
if response &&
|
24
|
+
response.body &&
|
25
|
+
response.body.is_a?(String) &&
|
26
|
+
!response.body.strip.empty?
|
27
|
+
begin
|
28
|
+
response.body = Fog::JSON.decode(response.body)
|
29
|
+
rescue Fog::JSON::DecodeError => e
|
30
|
+
Fog::Logger.warning("Error Parsing response json - #{e}")
|
31
|
+
response.body = {}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def headers(options={})
|
37
|
+
{'Content-Type' => 'application/json',
|
38
|
+
'Accept' => 'application/json',
|
39
|
+
}.merge(options[:headers] || {})
|
40
|
+
end
|
41
|
+
|
42
|
+
def request_params(params)
|
43
|
+
params.merge({
|
44
|
+
:headers => headers(params),
|
45
|
+
:path => "#{params[:path]}"
|
46
|
+
})
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Fog::Account do
|
4
|
+
Fog::Account.providers.each do |provider|
|
5
|
+
describe "when #{provider} is passed with no available credentials" do
|
6
|
+
it "returns ArgumentError" do
|
7
|
+
# Stub credentials so you still see errors where the tester really has credentials
|
8
|
+
Fog.stub :credentials, {} do
|
9
|
+
assert_raises(ArgumentError) { Fog::Account[provider] }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Fog::Billing do
|
4
|
+
Fog::Billing.providers.each do |provider|
|
5
|
+
describe "when #{provider} is passed with no available credentials" do
|
6
|
+
it "returns ArgumentError" do
|
7
|
+
# Stub credentials so you still see errors where the tester really has credentials
|
8
|
+
Fog.stub :credentials, {} do
|
9
|
+
assert_raises(ArgumentError) { Fog::Billing[provider] }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "fog/bin"
|
3
|
+
require "helpers/bin"
|
4
|
+
|
5
|
+
describe Atmos do
|
6
|
+
include Fog::BinSpec
|
7
|
+
|
8
|
+
let(:subject) { Atmos }
|
9
|
+
|
10
|
+
describe "#services" do
|
11
|
+
it "includes all services" do
|
12
|
+
assert_includes Atmos.services, :storage
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#class_for" do
|
17
|
+
describe "when requesting storage service" do
|
18
|
+
it "returns correct class" do
|
19
|
+
assert_equal Fog::Storage::Atmos, Atmos.class_for(:storage)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#[]" do
|
25
|
+
describe "when requesting storage service" do
|
26
|
+
it "returns instance" do
|
27
|
+
Fog::Storage::Atmos.stub(:new, "instance") do
|
28
|
+
assert_equal "instance", Atmos[:storage]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "fog/bin"
|
3
|
+
require "helpers/bin"
|
4
|
+
|
5
|
+
describe AWS do
|
6
|
+
include Fog::BinSpec
|
7
|
+
|
8
|
+
let(:subject) { AWS }
|
9
|
+
|
10
|
+
KEY_CLASS_MAPPING = {
|
11
|
+
:auto_scaling => Fog::AWS::AutoScaling,
|
12
|
+
:beanstalk => Fog::AWS::ElasticBeanstalk,
|
13
|
+
:cdn => Fog::CDN::AWS,
|
14
|
+
:cloud_formation => Fog::AWS::CloudFormation,
|
15
|
+
:cloud_watch => Fog::AWS::CloudWatch,
|
16
|
+
:compute => Fog::Compute::AWS,
|
17
|
+
:data_pipeline => Fog::AWS::DataPipeline,
|
18
|
+
:ddb => Fog::AWS::DynamoDB,
|
19
|
+
:dynamodb => Fog::AWS::DynamoDB,
|
20
|
+
:dns => Fog::DNS::AWS,
|
21
|
+
:elasticache => Fog::AWS::Elasticache,
|
22
|
+
:elb => Fog::AWS::ELB,
|
23
|
+
:emr => Fog::AWS::EMR,
|
24
|
+
:glacier => Fog::AWS::Glacier,
|
25
|
+
:iam => Fog::AWS::IAM,
|
26
|
+
:redshift => Fog::AWS::Redshift,
|
27
|
+
:sdb => Fog::AWS::SimpleDB,
|
28
|
+
:simpledb => Fog::AWS::SimpleDB,
|
29
|
+
:ses => Fog::AWS::SES,
|
30
|
+
:sqs => Fog::AWS::SQS,
|
31
|
+
:eu_storage => Fog::Storage::AWS,
|
32
|
+
:storage => Fog::Storage::AWS,
|
33
|
+
:rds => Fog::AWS::RDS,
|
34
|
+
:sns => Fog::AWS::SNS,
|
35
|
+
:sts => Fog::AWS::STS
|
36
|
+
}
|
37
|
+
|
38
|
+
describe "#services" do
|
39
|
+
it "includes all services" do
|
40
|
+
assert_includes AWS.services, :auto_scaling
|
41
|
+
assert_includes AWS.services, :beanstalk
|
42
|
+
assert_includes AWS.services, :cdn
|
43
|
+
assert_includes AWS.services, :cloud_formation
|
44
|
+
assert_includes AWS.services, :cloud_watch
|
45
|
+
assert_includes AWS.services, :compute
|
46
|
+
assert_includes AWS.services, :data_pipeline
|
47
|
+
assert_includes AWS.services, :dynamodb
|
48
|
+
assert_includes AWS.services, :dns
|
49
|
+
assert_includes AWS.services, :elasticache
|
50
|
+
assert_includes AWS.services, :elb
|
51
|
+
assert_includes AWS.services, :emr
|
52
|
+
assert_includes AWS.services, :glacier
|
53
|
+
assert_includes AWS.services, :iam
|
54
|
+
assert_includes AWS.services, :redshift
|
55
|
+
assert_includes AWS.services, :rds
|
56
|
+
assert_includes AWS.services, :simpledb
|
57
|
+
assert_includes AWS.services, :ses
|
58
|
+
assert_includes AWS.services, :sqs
|
59
|
+
assert_includes AWS.services, :storage
|
60
|
+
assert_includes AWS.services, :sns
|
61
|
+
assert_includes AWS.services, :sts
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "#class_for" do
|
66
|
+
describe "when key exists" do
|
67
|
+
it "maps to correct class" do
|
68
|
+
KEY_CLASS_MAPPING.each do |key, klass|
|
69
|
+
assert_equal klass, AWS.class_for(key)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "when key does not exist" do
|
75
|
+
it "raises ArgumentError" do
|
76
|
+
assert_raises(ArgumentError) { AWS.class_for(:bad_key) }
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "#[]" do
|
82
|
+
describe "when service is recognised" do
|
83
|
+
it "returns correct instance" do
|
84
|
+
KEY_CLASS_MAPPING.each do |key, klass|
|
85
|
+
klass.stub(:new, "#{klass} instance") do
|
86
|
+
assert_equal "#{klass} instance", AWS[key]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "when service is not recognised" do
|
93
|
+
it "raises ArgumentError" do
|
94
|
+
assert_raises(ArgumentError) { AWS[:bad_service] }
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|