fog-brightbox 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +1 -0
- data/CHANGELOG.md +18 -0
- data/fog-brightbox.gemspec +1 -0
- data/lib/fog/brightbox/compute/shared.rb +1 -1
- data/lib/fog/brightbox/oauth2.rb +16 -13
- data/lib/fog/brightbox/version.rb +1 -1
- data/spec/fog/brightbox/oauth2/client_credentials_strategy_spec.rb +30 -0
- data/spec/fog/brightbox/oauth2/credential_set_spec.rb +86 -0
- data/spec/fog/brightbox/oauth2/grant_type_strategy_spec.rb +24 -0
- data/spec/fog/brightbox/oauth2/refresh_token_strategy_spec.rb +33 -0
- data/spec/fog/brightbox/oauth2/user_credentials_strategy_spec.rb +40 -0
- data/spec/fog/compute/brightbox/database_server_spec.rb +3 -3
- data/spec/fog/compute/brightbox/server_spec.rb +3 -3
- data/tests/brightbox/compute/helper.rb +1 -0
- data/tests/brightbox/compute/schema.rb +794 -0
- data/tests/brightbox/compute_tests.rb +98 -0
- data/tests/brightbox/helper.rb +1 -0
- data/tests/brightbox/models/compute/account_tests.rb +15 -0
- data/tests/brightbox/models/compute/cloud_ip_tests.rb +32 -0
- data/tests/brightbox/models/compute/database_server_tests.rb +78 -0
- data/tests/brightbox/models/compute/database_snapshot_tests.rb +26 -0
- data/tests/brightbox/models/compute/database_type_tests.rb +27 -0
- data/tests/brightbox/models/compute/server_tests.rb +19 -0
- data/tests/brightbox/requests/compute/account_tests.rb +59 -0
- data/tests/brightbox/requests/compute/api_client_tests.rb +59 -0
- data/tests/brightbox/requests/compute/application_test.rb +58 -0
- data/tests/brightbox/requests/compute/cloud_ip_tests.rb +79 -0
- data/tests/brightbox/requests/compute/collaboration_tests.rb +36 -0
- data/tests/brightbox/requests/compute/database_server_tests.rb +53 -0
- data/tests/brightbox/requests/compute/database_snapsnot_tests.rb +46 -0
- data/tests/brightbox/requests/compute/database_type_tests.rb +16 -0
- data/tests/brightbox/requests/compute/firewall_policy_tests.rb +39 -0
- data/tests/brightbox/requests/compute/firewall_rule_tests.rb +42 -0
- data/tests/brightbox/requests/compute/helper.rb +42 -0
- data/tests/brightbox/requests/compute/image_tests.rb +54 -0
- data/tests/brightbox/requests/compute/interface_tests.rb +30 -0
- data/tests/brightbox/requests/compute/load_balancer_tests.rb +116 -0
- data/tests/brightbox/requests/compute/server_group_tests.rb +91 -0
- data/tests/brightbox/requests/compute/server_tests.rb +93 -0
- data/tests/brightbox/requests/compute/server_type_tests.rb +28 -0
- data/tests/brightbox/requests/compute/user_collaboration_tests.rb +65 -0
- data/tests/brightbox/requests/compute/user_tests.rb +32 -0
- data/tests/brightbox/requests/compute/zone_tests.rb +28 -0
- data/tests/helper.rb +8 -0
- data/tests/helpers/collection_helper.rb +91 -0
- data/tests/helpers/compute/flavors_helper.rb +28 -0
- data/tests/helpers/compute/server_helper.rb +23 -0
- data/tests/helpers/compute/servers_helper.rb +8 -0
- data/tests/helpers/formats_helper.rb +98 -0
- data/tests/helpers/formats_helper_tests.rb +106 -0
- data/tests/helpers/mock_helper.rb +98 -0
- data/tests/helpers/model_helper.rb +29 -0
- data/tests/helpers/responds_to_helper.rb +11 -0
- data/tests/helpers/schema_validator_tests.rb +101 -0
- data/tests/helpers/succeeds_helper.rb +9 -0
- metadata +68 -2
@@ -0,0 +1,79 @@
|
|
1
|
+
Shindo.tests("Fog::Compute[:brightbox] | cloud ip requests", ["brightbox"]) do
|
2
|
+
tests("success") do
|
3
|
+
unless Fog.mocking?
|
4
|
+
@server = Brightbox::Compute::TestSupport.get_test_server
|
5
|
+
end
|
6
|
+
|
7
|
+
tests("#create_cloud_ip") do
|
8
|
+
pending if Fog.mocking?
|
9
|
+
result = Fog::Compute[:brightbox].create_cloud_ip
|
10
|
+
@cloud_ip_id = result["id"]
|
11
|
+
data_matches_schema(Brightbox::Compute::Formats::Full::CLOUD_IP, :allow_extra_keys => true) { result }
|
12
|
+
end
|
13
|
+
|
14
|
+
tests("#list_cloud_ips") do
|
15
|
+
pending if Fog.mocking?
|
16
|
+
result = Fog::Compute[:brightbox].list_cloud_ips
|
17
|
+
data_matches_schema(Brightbox::Compute::Formats::Collection::CLOUD_IPS, :allow_extra_keys => true) { result }
|
18
|
+
end
|
19
|
+
|
20
|
+
tests("#get_cloud_ip('#{@cloud_ip_id}')") do
|
21
|
+
pending if Fog.mocking?
|
22
|
+
result = Fog::Compute[:brightbox].get_cloud_ip(@cloud_ip_id)
|
23
|
+
data_matches_schema(Brightbox::Compute::Formats::Full::CLOUD_IP, :allow_extra_keys => true) { result }
|
24
|
+
end
|
25
|
+
|
26
|
+
unless Fog.mocking?
|
27
|
+
map_options = { :destination => @server.interfaces.first["id"] }
|
28
|
+
end
|
29
|
+
|
30
|
+
tests("#map_cloud_ip('#{@cloud_ip_id}', #{map_options.inspect})") do
|
31
|
+
pending if Fog.mocking?
|
32
|
+
result = Fog::Compute[:brightbox].map_cloud_ip(@cloud_ip_id, map_options)
|
33
|
+
data_matches_schema(Brightbox::Compute::Formats::Full::CLOUD_IP, :allow_extra_keys => true) { result }
|
34
|
+
end
|
35
|
+
|
36
|
+
unless Fog.mocking?
|
37
|
+
Fog::Compute[:brightbox].cloud_ips.get(@cloud_ip_id).wait_for { mapped? }
|
38
|
+
end
|
39
|
+
|
40
|
+
tests("#unmap_cloud_ip('#{@cloud_ip_id}')") do
|
41
|
+
pending if Fog.mocking?
|
42
|
+
result = Fog::Compute[:brightbox].unmap_cloud_ip(@cloud_ip_id)
|
43
|
+
data_matches_schema(Brightbox::Compute::Formats::Full::CLOUD_IP, :allow_extra_keys => true) { result }
|
44
|
+
end
|
45
|
+
|
46
|
+
unless Fog.mocking?
|
47
|
+
update_options = { :reverse_dns => "public.#{@server.id}.gb1.brightbox.com" }
|
48
|
+
end
|
49
|
+
|
50
|
+
tests("#update_cloud_ip('#{@cloud_ip_id}', #{update_options.inspect})") do
|
51
|
+
pending if Fog.mocking?
|
52
|
+
result = Fog::Compute[:brightbox].update_cloud_ip(@cloud_ip_id, update_options)
|
53
|
+
data_matches_schema(Brightbox::Compute::Formats::Full::CLOUD_IP, :allow_extra_keys => true) { result }
|
54
|
+
result = Fog::Compute[:brightbox].update_cloud_ip(@cloud_ip_id, :reverse_dns => "")
|
55
|
+
end
|
56
|
+
|
57
|
+
tests("#destroy_cloud_ip('#{@cloud_ip_id}')") do
|
58
|
+
pending if Fog.mocking?
|
59
|
+
result = Fog::Compute[:brightbox].destroy_cloud_ip(@cloud_ip_id)
|
60
|
+
data_matches_schema(Brightbox::Compute::Formats::Full::CLOUD_IP, :allow_extra_keys => true) { result }
|
61
|
+
end
|
62
|
+
|
63
|
+
unless Fog.mocking?
|
64
|
+
@server.destroy
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
tests("failure") do
|
69
|
+
tests("#get_cloud_ip('cip-00000')").raises(Excon::Errors::NotFound) do
|
70
|
+
pending if Fog.mocking?
|
71
|
+
Fog::Compute[:brightbox].get_cloud_ip("cip-00000")
|
72
|
+
end
|
73
|
+
|
74
|
+
tests("#get_cloud_ip").raises(ArgumentError) do
|
75
|
+
pending if Fog.mocking?
|
76
|
+
Fog::Compute[:brightbox].get_cloud_ip
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
Shindo.tests("Fog::Compute[:brightbox] | collaboration requests", ["brightbox"]) do
|
2
|
+
tests("success") do
|
3
|
+
tests("#create_collaboration") do
|
4
|
+
pending if Fog.mocking?
|
5
|
+
collaboration = Fog::Compute[:brightbox].create_collaboration(:email => "paul@example.com", :role => "admin")
|
6
|
+
@collaboration_id = collaboration["id"]
|
7
|
+
formats(Brightbox::Compute::Formats::Full::COLLABORATION, false) { collaboration }
|
8
|
+
end
|
9
|
+
|
10
|
+
tests("#list_collaborations") do
|
11
|
+
pending if Fog.mocking?
|
12
|
+
result = Fog::Compute[:brightbox].list_collaborations
|
13
|
+
|
14
|
+
formats(Brightbox::Compute::Formats::Collection::COLLABORATIONS, false) { result }
|
15
|
+
end
|
16
|
+
|
17
|
+
tests("#get_collaboration") do
|
18
|
+
pending if Fog.mocking?
|
19
|
+
result = Fog::Compute[:brightbox].get_collaboration(@collaboration_id)
|
20
|
+
formats(Brightbox::Compute::Formats::Full::COLLABORATION, false) { result }
|
21
|
+
end
|
22
|
+
|
23
|
+
tests("#destroy_collaboration") do
|
24
|
+
pending if Fog.mocking?
|
25
|
+
result = Fog::Compute[:brightbox].destroy_collaboration(@collaboration_id)
|
26
|
+
formats(Brightbox::Compute::Formats::Full::COLLABORATION, false) { result }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
tests("failure") do
|
31
|
+
tests("get_collaboration('col-abcde')").raises(Excon::Errors::NotFound) do
|
32
|
+
pending if Fog.mocking?
|
33
|
+
Fog::Compute[:brightbox].get_collaboration("col-abcde")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
Shindo.tests("Fog::Compute[:brightbox] | database server requests", ["brightbox"]) do
|
2
|
+
pending if Fog.mocking?
|
3
|
+
|
4
|
+
tests("success") do
|
5
|
+
create_options = {}
|
6
|
+
tests("#create_database_server(#{create_options.inspect})") do
|
7
|
+
result = Fog::Compute[:brightbox].create_database_server(create_options)
|
8
|
+
@database_server_id = result["id"]
|
9
|
+
data_matches_schema(Brightbox::Compute::Formats::Full::DATABASE_SERVER, :allow_extra_keys => true) { result }
|
10
|
+
end
|
11
|
+
|
12
|
+
tests("#list_database_servers") do
|
13
|
+
result = Fog::Compute[:brightbox].list_database_servers
|
14
|
+
data_matches_schema(Brightbox::Compute::Formats::Collection::DATABASE_SERVERS, :allow_extra_keys => true) { result }
|
15
|
+
end
|
16
|
+
|
17
|
+
tests("#get_database_server('#{@database_server_id}')") do
|
18
|
+
result = Fog::Compute[:brightbox].get_database_server(@database_server_id)
|
19
|
+
data_matches_schema(Brightbox::Compute::Formats::Full::DATABASE_SERVER, :allow_extra_keys => true) { result }
|
20
|
+
end
|
21
|
+
|
22
|
+
update_options = {
|
23
|
+
:name => "New name"
|
24
|
+
}
|
25
|
+
tests("#update_database_server('#{@database_server_id}', update_options)") do
|
26
|
+
result = Fog::Compute[:brightbox].update_database_server(@database_server_id, update_options)
|
27
|
+
data_matches_schema(Brightbox::Compute::Formats::Full::DATABASE_SERVER, :allow_extra_keys => true) { result }
|
28
|
+
end
|
29
|
+
|
30
|
+
Fog::Compute[:brightbox].database_servers.get(@database_server_id).wait_for { ready? }
|
31
|
+
|
32
|
+
tests("#reset_password_database_server('#{@database_server_id}')") do
|
33
|
+
result = Fog::Compute[:brightbox].reset_password_database_server(@database_server_id)
|
34
|
+
data_matches_schema(Brightbox::Compute::Formats::Full::DATABASE_SERVER, :allow_extra_keys => true) { result }
|
35
|
+
test("new password is visible") { !result["admin_password"].nil? }
|
36
|
+
end
|
37
|
+
|
38
|
+
tests("#destroy_database_server('#{@database_server_id}')") do
|
39
|
+
result = Fog::Compute[:brightbox].destroy_database_server(@database_server_id)
|
40
|
+
data_matches_schema(Brightbox::Compute::Formats::Full::DATABASE_SERVER, :allow_extra_keys => true) { result }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
tests("failure") do
|
45
|
+
tests("create_database_server").raises(ArgumentError) do
|
46
|
+
Fog::Compute[:brightbox].create_database_server
|
47
|
+
end
|
48
|
+
|
49
|
+
tests("get_database_server").raises(Excon::Errors::NotFound) do
|
50
|
+
Fog::Compute[:brightbox].get_database_server("dbs-00000")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
Shindo.tests("Fog::Compute[:brightbox] | database snapshot requests", ["brightbox"]) do
|
2
|
+
pending if Fog.mocking?
|
3
|
+
|
4
|
+
service = Fog::Compute[:brightbox]
|
5
|
+
|
6
|
+
tests("success") do
|
7
|
+
# Create a Database Server, then snapshot it
|
8
|
+
database_server = service.database_servers.create
|
9
|
+
database_server.wait_for { ready? }
|
10
|
+
service.snapshot_database_server(database_server.id)
|
11
|
+
|
12
|
+
tests("#list_database_snapshots") do
|
13
|
+
result = service.list_database_snapshots
|
14
|
+
data_matches_schema(Brightbox::Compute::Formats::Collection::DATABASE_SNAPSHOTS, :allow_extra_keys => true) { result }
|
15
|
+
@database_snapshot_id = result.last["id"]
|
16
|
+
end
|
17
|
+
|
18
|
+
# Can't delete the server until snapshot is finished
|
19
|
+
service.database_snapshots.get(@database_snapshot_id).wait_for { ready? }
|
20
|
+
database_server.destroy
|
21
|
+
|
22
|
+
tests("#get_database_snapshot('#{@database_snapshot_id}')") do
|
23
|
+
result = service.get_database_snapshot(@database_snapshot_id)
|
24
|
+
data_matches_schema(Brightbox::Compute::Formats::Full::DATABASE_SNAPSHOT, :allow_extra_keys => true) { result }
|
25
|
+
end
|
26
|
+
|
27
|
+
update_options = {
|
28
|
+
:name => "New name"
|
29
|
+
}
|
30
|
+
tests("#update_database_snapshot('#{@database_snapshot_id}', update_options)") do
|
31
|
+
result = service.update_database_snapshot(@database_snapshot_id, update_options)
|
32
|
+
data_matches_schema(Brightbox::Compute::Formats::Full::DATABASE_SNAPSHOT, :allow_extra_keys => true) { result }
|
33
|
+
end
|
34
|
+
|
35
|
+
tests("#destroy_database_snapshot('#{@database_snapshot_id}')") do
|
36
|
+
result = service.destroy_database_snapshot(@database_snapshot_id)
|
37
|
+
data_matches_schema(Brightbox::Compute::Formats::Full::DATABASE_SNAPSHOT, :allow_extra_keys => true) { result }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
tests("failure") do
|
42
|
+
tests("get_database_snapshot").raises(Excon::Errors::NotFound) do
|
43
|
+
service.get_database_snapshot("dbs-00000")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Shindo.tests("Fog::Compute[:brightbox] | database type requests", ["brightbox"]) do
|
2
|
+
tests("success") do
|
3
|
+
tests("#list_database_types") do
|
4
|
+
pending if Fog.mocking?
|
5
|
+
result = Fog::Compute[:brightbox].list_database_types
|
6
|
+
data_matches_schema(Brightbox::Compute::Formats::Collection::DATABASE_SERVER_TYPES, :allow_extra_keys => true) { result }
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
tests("failure") do
|
11
|
+
tests("#get_database_type").raises(Excon::Errors::NotFound) do
|
12
|
+
pending if Fog.mocking?
|
13
|
+
Fog::Compute[:brightbox].get_database_type("dbt-00000")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
Shindo.tests("Fog::Compute[:brightbox] | firewall policy requests", ["brightbox"]) do
|
2
|
+
tests("success") do
|
3
|
+
pending if Fog.mocking?
|
4
|
+
|
5
|
+
create_options = {
|
6
|
+
:name => "Fog test policy A"
|
7
|
+
}
|
8
|
+
|
9
|
+
tests("#create_firewall_policy(#{create_options.inspect})") do
|
10
|
+
result = Fog::Compute[:brightbox].create_firewall_policy(create_options)
|
11
|
+
@firewall_policy_id = result["id"]
|
12
|
+
data_matches_schema(Brightbox::Compute::Formats::Full::FIREWALL_POLICY, :allow_extra_keys => true) { result }
|
13
|
+
end
|
14
|
+
|
15
|
+
tests("#list_firewall_policies()") do
|
16
|
+
data_matches_schema(Brightbox::Compute::Formats::Collection::FIREWALL_POLICIES, :allow_extra_keys => true) do
|
17
|
+
Fog::Compute[:brightbox].list_firewall_policies
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
tests("#get_firewall_policy('#{@firewall_policy_id}')") do
|
22
|
+
data_matches_schema(Brightbox::Compute::Formats::Full::FIREWALL_POLICY, :allow_extra_keys => true) do
|
23
|
+
Fog::Compute[:brightbox].get_firewall_policy(@firewall_policy_id)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
update_options = { :name => "Fog test policy B" }
|
28
|
+
tests("#update_firewall_policy('#{@firewall_policy_id}', #{update_options.inspect})") do
|
29
|
+
result = Fog::Compute[:brightbox].update_firewall_policy(@firewall_policy_id, update_options)
|
30
|
+
data_matches_schema(Brightbox::Compute::Formats::Full::FIREWALL_POLICY, :allow_extra_keys => true) { result }
|
31
|
+
returns("Fog test policy B") { result["name"] }
|
32
|
+
end
|
33
|
+
|
34
|
+
tests("#destroy_firewall_policy('#{@firewall_policy_id}')") do
|
35
|
+
result = Fog::Compute[:brightbox].destroy_firewall_policy(@firewall_policy_id)
|
36
|
+
data_matches_schema(Brightbox::Compute::Formats::Full::FIREWALL_POLICY, :allow_extra_keys => true) { result }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
Shindo.tests("Fog::Compute[:brightbox] | firewall rule requests", ["brightbox"]) do
|
2
|
+
tests("success") do
|
3
|
+
pending if Fog.mocking?
|
4
|
+
|
5
|
+
unless Fog.mocking?
|
6
|
+
policy = Fog::Compute[:brightbox].firewall_policies.create
|
7
|
+
end
|
8
|
+
|
9
|
+
create_options = {
|
10
|
+
:firewall_policy => policy.id,
|
11
|
+
:destination => "127.0.0.1"
|
12
|
+
}
|
13
|
+
|
14
|
+
tests("#create_firewall_rule(#{create_options.inspect})") do
|
15
|
+
result = Fog::Compute[:brightbox].create_firewall_rule(create_options)
|
16
|
+
@firewall_rule_id = result["id"]
|
17
|
+
data_matches_schema(Brightbox::Compute::Formats::Full::FIREWALL_RULE, :allow_extra_keys => true) { result }
|
18
|
+
end
|
19
|
+
|
20
|
+
tests("#get_firewall_rule('#{@firewall_rule_id}')") do
|
21
|
+
data_matches_schema(Brightbox::Compute::Formats::Full::FIREWALL_RULE, :allow_extra_keys => true) do
|
22
|
+
Fog::Compute[:brightbox].get_firewall_rule(@firewall_rule_id)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
update_options = { :source => nil, :destination => "127.0.0.1" }
|
27
|
+
tests("#update_firewall_rule('#{@firewall_rule_id}', #{update_options.inspect})") do
|
28
|
+
data_matches_schema(Brightbox::Compute::Formats::Full::FIREWALL_RULE, :allow_extra_keys => true) do
|
29
|
+
Fog::Compute[:brightbox].update_firewall_rule(@firewall_rule_id, update_options)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
tests("#destroy_firewall_rule('#{@firewall_rule_id}')") do
|
34
|
+
result = Fog::Compute[:brightbox].destroy_firewall_rule(@firewall_rule_id)
|
35
|
+
data_matches_schema(Brightbox::Compute::Formats::Full::FIREWALL_RULE, :allow_extra_keys => true) { result }
|
36
|
+
end
|
37
|
+
|
38
|
+
unless Fog.mocking?
|
39
|
+
policy.destroy
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
class Brightbox
|
2
|
+
module Compute
|
3
|
+
module TestSupport
|
4
|
+
# Find a suitable image for testing with
|
5
|
+
# For speed of server building we're using an empty image
|
6
|
+
#
|
7
|
+
# Unless the tester has credentials this will fail so we rescue
|
8
|
+
# any errors and return nil.
|
9
|
+
#
|
10
|
+
# This is used in the shared file +tests/compute/helper.rb+ so unfortunately
|
11
|
+
# makes all tests reliant on hardcoded values and each other
|
12
|
+
#
|
13
|
+
# @return [String,NilClass] the most suitable test image's identifier or nil
|
14
|
+
def self.image_id
|
15
|
+
return @image_id unless @image_id.nil?
|
16
|
+
image = select_testing_image_from_api
|
17
|
+
@image_id = image["id"]
|
18
|
+
rescue
|
19
|
+
@image_id = nil
|
20
|
+
end
|
21
|
+
|
22
|
+
# Prepare a test server, wait for it to be usable but raise if it fails
|
23
|
+
def self.get_test_server
|
24
|
+
test_server_options = { :image_id => image_id }
|
25
|
+
server = Fog::Compute[:brightbox].servers.create(test_server_options)
|
26
|
+
server.wait_for do
|
27
|
+
raise "Test server failed to build" if state == "failed"
|
28
|
+
ready?
|
29
|
+
end
|
30
|
+
server
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def self.select_testing_image_from_api
|
36
|
+
images = Fog::Compute[:brightbox].list_images
|
37
|
+
raise "No available images!" if images.empty?
|
38
|
+
images.select { |img| img["official"] && img["virtual_size"] != 0 }.sort_by { |img| img["disk_size"] }.first || images.first
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
Shindo.tests("Fog::Compute[:brightbox] | image requests", ["brightbox"]) do
|
2
|
+
tests("success") do
|
3
|
+
## Difficult to test without having uploaded an Image to your account to register
|
4
|
+
# creation_options = {
|
5
|
+
# "arch" => "i686",
|
6
|
+
# "source" => "fnord"
|
7
|
+
# }
|
8
|
+
# tests("#create_image(#{creation_options.inspect})")
|
9
|
+
# result = Fog::Compute[:brightbox].create_image(creation_options)
|
10
|
+
# @image_id = result["id"]
|
11
|
+
# formats(Brightbox::Compute::Formats::Full::IMAGE) { result }
|
12
|
+
# end
|
13
|
+
|
14
|
+
# Fog::Compute[:brightbox].images.get(@image_id).wait_for { ready? }
|
15
|
+
|
16
|
+
tests("#list_images") do
|
17
|
+
pending if Fog.mocking?
|
18
|
+
result = Fog::Compute[:brightbox].list_images
|
19
|
+
@image_id = result.first["id"]
|
20
|
+
data_matches_schema(Brightbox::Compute::Formats::Collection::IMAGES, :allow_extra_keys => true) { result }
|
21
|
+
end
|
22
|
+
|
23
|
+
tests("#get_image('#{@image_id}')") do
|
24
|
+
pending if Fog.mocking?
|
25
|
+
result = Fog::Compute[:brightbox].get_image(@image_id)
|
26
|
+
data_matches_schema(Brightbox::Compute::Formats::Full::IMAGE, :allow_extra_keys => true) { result }
|
27
|
+
end
|
28
|
+
|
29
|
+
## Until Image creation can be automated, we shouldn't be updating Images randomly
|
30
|
+
# update_options = {}
|
31
|
+
# tests("#update_image('#{@image_id}', #{update_options.inspect})") do
|
32
|
+
# result = Fog::Compute[:brightbox].update_image(@image_id, :name => "New name from Fog test")
|
33
|
+
# formats(Brightbox::Compute::Formats::Full::IMAGE) { result }
|
34
|
+
# end
|
35
|
+
|
36
|
+
## Same as other tests - can't be deleting them unless part of the test run
|
37
|
+
# tests("#destroy_server('#{@image_id}')") do
|
38
|
+
# result = Fog::Compute[:brightbox].destroy_image(@image_id)
|
39
|
+
# formats(Brightbox::Compute::Formats::Full::IMAGE) { result }
|
40
|
+
# end
|
41
|
+
end
|
42
|
+
|
43
|
+
tests("failure") do
|
44
|
+
tests("#get_image('img-00000')").raises(Excon::Errors::NotFound) do
|
45
|
+
pending if Fog.mocking?
|
46
|
+
Fog::Compute[:brightbox].get_image("img-00000")
|
47
|
+
end
|
48
|
+
|
49
|
+
tests("#get_image").raises(ArgumentError) do
|
50
|
+
pending if Fog.mocking?
|
51
|
+
Fog::Compute[:brightbox].get_image
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Shindo.tests("Fog::Compute[:brightbox] | interface requests", ["brightbox"]) do
|
2
|
+
@test_service = Fog::Compute[:brightbox]
|
3
|
+
|
4
|
+
tests("success") do
|
5
|
+
unless Fog.mocking?
|
6
|
+
@test_server = Brightbox::Compute::TestSupport.get_test_server
|
7
|
+
@interface_id = @test_server.interfaces.first["id"]
|
8
|
+
|
9
|
+
tests("#get_interface('#{@interface_id}')") do
|
10
|
+
pending if Fog.mocking?
|
11
|
+
result = @test_service.get_interface(@interface_id)
|
12
|
+
data_matches_schema(Brightbox::Compute::Formats::Full::INTERFACE, :allow_extra_keys => true) { result }
|
13
|
+
end
|
14
|
+
|
15
|
+
@test_server.destroy
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
tests("failure") do
|
20
|
+
tests("#get_interface('int-00000')").raises(Excon::Errors::NotFound) do
|
21
|
+
pending if Fog.mocking?
|
22
|
+
@test_service.get_interface("int-00000")
|
23
|
+
end
|
24
|
+
|
25
|
+
tests("#get_interface()").raises(ArgumentError) do
|
26
|
+
pending if Fog.mocking?
|
27
|
+
@test_service.get_interface
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|