fog-brightbox 1.10.0 → 1.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +15 -10
- data/CHANGELOG.md +17 -0
- data/Rakefile +1 -1
- data/fog-brightbox.gemspec +5 -3
- data/lib/fog/brightbox/compute/shared.rb +11 -10
- data/lib/fog/brightbox/compute.rb +20 -21
- data/lib/fog/brightbox/config.rb +6 -9
- data/lib/fog/brightbox/models/compute/api_client.rb +4 -4
- data/lib/fog/brightbox/models/compute/application.rb +2 -2
- data/lib/fog/brightbox/models/compute/cloud_ip.rb +11 -11
- data/lib/fog/brightbox/models/compute/collaboration.rb +3 -3
- data/lib/fog/brightbox/models/compute/collaborations.rb +1 -1
- data/lib/fog/brightbox/models/compute/config_map.rb +2 -3
- data/lib/fog/brightbox/models/compute/database_server.rb +17 -5
- data/lib/fog/brightbox/models/compute/database_snapshot.rb +2 -2
- data/lib/fog/brightbox/models/compute/firewall_policy.rb +6 -6
- data/lib/fog/brightbox/models/compute/firewall_rule.rb +9 -9
- data/lib/fog/brightbox/models/compute/image.rb +9 -9
- data/lib/fog/brightbox/models/compute/load_balancer.rb +12 -12
- data/lib/fog/brightbox/models/compute/server.rb +21 -23
- data/lib/fog/brightbox/models/compute/server_group.rb +6 -6
- data/lib/fog/brightbox/models/compute/user.rb +3 -3
- data/lib/fog/brightbox/models/compute/volume.rb +16 -16
- data/lib/fog/brightbox/models/storage/directories.rb +2 -2
- data/lib/fog/brightbox/models/storage/directory.rb +7 -7
- data/lib/fog/brightbox/models/storage/file.rb +13 -13
- data/lib/fog/brightbox/models/storage/files.rb +9 -13
- data/lib/fog/brightbox/oauth2.rb +11 -11
- data/lib/fog/brightbox/requests/compute/list_accounts.rb +1 -1
- data/lib/fog/brightbox/requests/compute/reset_database_server.rb +21 -0
- data/lib/fog/brightbox/requests/compute/resize_database_server.rb +25 -0
- data/lib/fog/brightbox/requests/compute/snapshot_database_server.rb +1 -1
- data/lib/fog/brightbox/requests/compute/snapshot_server.rb +1 -1
- data/lib/fog/brightbox/requests/storage/copy_object.rb +5 -5
- data/lib/fog/brightbox/requests/storage/delete_container.rb +3 -3
- data/lib/fog/brightbox/requests/storage/delete_multiple_objects.rb +7 -7
- data/lib/fog/brightbox/requests/storage/delete_object.rb +3 -3
- data/lib/fog/brightbox/requests/storage/delete_static_large_object.rb +6 -6
- data/lib/fog/brightbox/requests/storage/get_container.rb +4 -4
- data/lib/fog/brightbox/requests/storage/get_containers.rb +4 -4
- data/lib/fog/brightbox/requests/storage/get_object.rb +4 -6
- data/lib/fog/brightbox/requests/storage/get_object_http_url.rb +1 -1
- data/lib/fog/brightbox/requests/storage/get_object_https_url.rb +1 -1
- data/lib/fog/brightbox/requests/storage/head_container.rb +4 -4
- data/lib/fog/brightbox/requests/storage/head_containers.rb +4 -4
- data/lib/fog/brightbox/requests/storage/head_object.rb +3 -3
- data/lib/fog/brightbox/requests/storage/post_set_meta_temp_url_key.rb +3 -3
- data/lib/fog/brightbox/requests/storage/put_container.rb +4 -4
- data/lib/fog/brightbox/requests/storage/put_dynamic_obj_manifest.rb +4 -4
- data/lib/fog/brightbox/requests/storage/put_object.rb +7 -7
- data/lib/fog/brightbox/requests/storage/put_static_obj_manifest.rb +6 -6
- data/lib/fog/brightbox/storage/authentication_request.rb +4 -4
- data/lib/fog/brightbox/storage/connection.rb +2 -2
- data/lib/fog/brightbox/storage.rb +13 -14
- data/lib/fog/brightbox/version.rb +1 -1
- data/spec/fog/brightbox/compute/config_spec.rb +4 -4
- data/spec/fog/brightbox/compute/get_access_token_spec.rb +28 -28
- data/spec/fog/brightbox/compute/wrapped_request_spec.rb +23 -23
- data/spec/fog/brightbox/config_spec.rb +23 -23
- data/spec/fog/brightbox/oauth2/client_credentials_strategy_spec.rb +2 -2
- data/spec/fog/brightbox/oauth2/credential_set_spec.rb +5 -5
- data/spec/fog/brightbox/oauth2/grant_type_strategy_spec.rb +2 -2
- data/spec/fog/brightbox/oauth2/refresh_token_strategy_spec.rb +3 -3
- data/spec/fog/brightbox/oauth2/user_credentials_strategy_spec.rb +4 -4
- data/spec/fog/brightbox/storage/authentication_request_spec.rb +34 -34
- data/spec/fog/brightbox/storage/config_spec.rb +4 -4
- data/spec/fog/brightbox/storage/connection_errors_spec.rb +6 -6
- data/spec/fog/brightbox/storage/connection_spec.rb +37 -37
- data/spec/fog/brightbox/storage/directory_spec.rb +6 -6
- data/spec/fog/brightbox/storage/files_spec.rb +5 -5
- data/spec/fog/brightbox/storage_spec.rb +5 -5
- data/spec/fog/compute/brightbox/database_server_spec.rb +19 -19
- data/spec/fog/compute/brightbox/image_selector_spec.rb +18 -18
- data/spec/fog/compute/brightbox/load_balancer_spec.rb +5 -5
- data/spec/fog/compute/brightbox/server_spec.rb +44 -44
- data/spec/fog/compute/brightbox/volume_spec.rb +68 -69
- data/spec/fog/compute/brightbox_spec.rb +10 -10
- data/spec/fog/storage/brightbox_spec.rb +83 -83
- data/spec/model_setup.rb +9 -9
- data/spec/stock_storage_responses.rb +9 -9
- data/spec/supports_resource_locking.rb +6 -6
- data/tests/brightbox/compute/schema.rb +74 -74
- data/tests/brightbox/compute_tests.rb +14 -14
- data/tests/brightbox/models/compute/server_tests.rb +0 -1
- data/tests/brightbox/requests/compute/account_tests.rb +9 -9
- data/tests/brightbox/requests/compute/api_client_tests.rb +9 -9
- data/tests/brightbox/requests/compute/application_test.rb +8 -8
- data/tests/brightbox/requests/compute/cloud_ip_tests.rb +11 -13
- data/tests/brightbox/requests/compute/collaboration_tests.rb +1 -1
- data/tests/brightbox/requests/compute/database_server_tests.rb +7 -7
- data/tests/brightbox/requests/compute/database_snapsnot_tests.rb +5 -5
- data/tests/brightbox/requests/compute/database_type_tests.rb +1 -1
- data/tests/brightbox/requests/compute/firewall_policy_tests.rb +7 -7
- data/tests/brightbox/requests/compute/firewall_rule_tests.rb +8 -10
- data/tests/brightbox/requests/compute/helper.rb +1 -1
- data/tests/brightbox/requests/compute/image_tests.rb +2 -2
- data/tests/brightbox/requests/compute/interface_tests.rb +1 -1
- data/tests/brightbox/requests/compute/load_balancer_tests.rb +23 -23
- data/tests/brightbox/requests/compute/server_group_tests.rb +16 -18
- data/tests/brightbox/requests/compute/server_tests.rb +12 -12
- data/tests/brightbox/requests/compute/server_type_tests.rb +2 -2
- data/tests/brightbox/requests/compute/user_tests.rb +4 -4
- data/tests/brightbox/requests/compute/volume_tests.rb +5 -5
- data/tests/brightbox/requests/compute/zone_tests.rb +2 -2
- data/tests/helper.rb +1 -1
- data/tests/helpers/collection_helper.rb +16 -23
- data/tests/helpers/compute/server_helper.rb +4 -6
- data/tests/helpers/formats_helper.rb +5 -5
- data/tests/helpers/formats_helper_tests.rb +16 -16
- data/tests/helpers/mock_helper.rb +84 -86
- data/tests/helpers/model_helper.rb +1 -3
- data/tests/helpers/schema_validator_tests.rb +14 -14
- metadata +17 -2
- data/.rubocop_todo.yml +0 -81
@@ -8,11 +8,11 @@ describe Fog::Brightbox::OAuth2::RefreshTokenStrategy do
|
|
8
8
|
@strategy = Fog::Brightbox::OAuth2::GrantTypeStrategy.new(@credentials)
|
9
9
|
end
|
10
10
|
|
11
|
-
it "tests #respond_to?(:authorization_body_data) returns true"
|
11
|
+
it "tests #respond_to?(:authorization_body_data) returns true" do
|
12
12
|
assert @strategy.respond_to?(:authorization_body_data)
|
13
13
|
end
|
14
14
|
|
15
|
-
it "tests #respond_to?(:headers) returns true"
|
15
|
+
it "tests #respond_to?(:headers) returns true" do
|
16
16
|
assert @strategy.respond_to?(:headers)
|
17
17
|
end
|
18
18
|
|
@@ -5,16 +5,16 @@ describe Fog::Brightbox::OAuth2::RefreshTokenStrategy do
|
|
5
5
|
@client_id = "app-12345"
|
6
6
|
@client_secret = "__mashed_keys_123__"
|
7
7
|
@refresh_token = "ab4b39dddf909"
|
8
|
-
options = { :
|
8
|
+
options = { refresh_token: @refresh_token }
|
9
9
|
@credentials = Fog::Brightbox::OAuth2::CredentialSet.new(@client_id, @client_secret, options)
|
10
10
|
@strategy = Fog::Brightbox::OAuth2::RefreshTokenStrategy.new(@credentials)
|
11
11
|
end
|
12
12
|
|
13
|
-
it "tests #respond_to?(:authorization_body_data) returns true"
|
13
|
+
it "tests #respond_to?(:authorization_body_data) returns true" do
|
14
14
|
assert @strategy.respond_to?(:authorization_body_data)
|
15
15
|
end
|
16
16
|
|
17
|
-
it "tests #respond_to?(:headers) returns true"
|
17
|
+
it "tests #respond_to?(:headers) returns true" do
|
18
18
|
assert @strategy.respond_to?(:headers)
|
19
19
|
end
|
20
20
|
|
@@ -8,19 +8,19 @@ describe Fog::Brightbox::OAuth2::UserCredentialsStrategy do
|
|
8
8
|
@password = "__mushed_keys_321__"
|
9
9
|
|
10
10
|
options = {
|
11
|
-
:
|
12
|
-
:
|
11
|
+
username: @username,
|
12
|
+
password: @password
|
13
13
|
}
|
14
14
|
|
15
15
|
@credentials = Fog::Brightbox::OAuth2::CredentialSet.new(@client_id, @client_secret, options)
|
16
16
|
@strategy = Fog::Brightbox::OAuth2::UserCredentialsStrategy.new(@credentials)
|
17
17
|
end
|
18
18
|
|
19
|
-
it "tests #respond_to?(:authorization_body_data) returns true"
|
19
|
+
it "tests #respond_to?(:authorization_body_data) returns true" do
|
20
20
|
assert @strategy.respond_to?(:authorization_body_data)
|
21
21
|
end
|
22
22
|
|
23
|
-
it "tests #respond_to?(:headers) returns true"
|
23
|
+
it "tests #respond_to?(:headers) returns true" do
|
24
24
|
assert @strategy.respond_to?(:headers)
|
25
25
|
end
|
26
26
|
|
@@ -5,12 +5,12 @@ describe Fog::Brightbox::Storage::AuthenticationRequest do
|
|
5
5
|
|
6
6
|
describe "when initialised with blank config" do
|
7
7
|
before do
|
8
|
-
stub_request(:get, "https://orbit.brightbox.com/v1")
|
9
|
-
with(:
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
stub_request(:get, "https://orbit.brightbox.com/v1")
|
9
|
+
.with(headers: {
|
10
|
+
"Host" => "orbit.brightbox.com:443",
|
11
|
+
"X-Auth-User" => "",
|
12
|
+
"X-Auth-Key" => ""
|
13
|
+
}).to_return(bad_url_response)
|
14
14
|
end
|
15
15
|
|
16
16
|
it "raises error" do
|
@@ -23,18 +23,18 @@ describe Fog::Brightbox::Storage::AuthenticationRequest do
|
|
23
23
|
|
24
24
|
describe "when initialised with API client details" do
|
25
25
|
before do
|
26
|
-
stub_request(:get, "https://orbit.brightbox.com/v1")
|
27
|
-
with(:
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
stub_request(:get, "https://orbit.brightbox.com/v1")
|
27
|
+
.with(headers: {
|
28
|
+
"Host" => "orbit.brightbox.com:443",
|
29
|
+
"X-Auth-User" => "cli-12345",
|
30
|
+
"X-Auth-Key" => "12345"
|
31
|
+
}).to_return(authorized_response)
|
32
32
|
end
|
33
33
|
|
34
34
|
it "authenticates correctly" do
|
35
35
|
settings = {
|
36
|
-
:
|
37
|
-
:
|
36
|
+
brightbox_client_id: "cli-12345",
|
37
|
+
brightbox_secret: "12345"
|
38
38
|
}
|
39
39
|
@config = Fog::Brightbox::Config.new(settings)
|
40
40
|
@request = Fog::Brightbox::Storage::AuthenticationRequest.new(@config)
|
@@ -44,20 +44,20 @@ describe Fog::Brightbox::Storage::AuthenticationRequest do
|
|
44
44
|
|
45
45
|
describe "when initialised with user details" do
|
46
46
|
before do
|
47
|
-
stub_request(:get, "https://orbit.brightbox.com/v1")
|
48
|
-
with(:
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
47
|
+
stub_request(:get, "https://orbit.brightbox.com/v1")
|
48
|
+
.with(headers: {
|
49
|
+
"Host" => "orbit.brightbox.com:443",
|
50
|
+
"X-Auth-User" => "user@example.test",
|
51
|
+
"X-Auth-Key" => "abcde"
|
52
|
+
}).to_return(authorized_response)
|
53
53
|
end
|
54
54
|
|
55
55
|
it "authenticates correctly" do
|
56
56
|
settings = {
|
57
|
-
:
|
58
|
-
:
|
59
|
-
:
|
60
|
-
:
|
57
|
+
brightbox_client_id: "app-12345",
|
58
|
+
brightbox_secret: "12345",
|
59
|
+
brightbox_username: "user@example.test",
|
60
|
+
brightbox_password: "abcde"
|
61
61
|
}
|
62
62
|
@config = Fog::Brightbox::Config.new(settings)
|
63
63
|
@request = Fog::Brightbox::Storage::AuthenticationRequest.new(@config)
|
@@ -67,20 +67,20 @@ describe Fog::Brightbox::Storage::AuthenticationRequest do
|
|
67
67
|
|
68
68
|
describe "when initialised with bad user details" do
|
69
69
|
before do
|
70
|
-
stub_request(:get, "https://orbit.brightbox.com/v1")
|
71
|
-
with(:
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
70
|
+
stub_request(:get, "https://orbit.brightbox.com/v1")
|
71
|
+
.with(headers: {
|
72
|
+
"Host" => "orbit.brightbox.com:443",
|
73
|
+
"X-Auth-User" => "user@example.test",
|
74
|
+
"X-Auth-Key" => "abcde"
|
75
|
+
}).to_return(unauthorized_response)
|
76
76
|
end
|
77
77
|
|
78
78
|
it "raises error" do
|
79
79
|
settings = {
|
80
|
-
:
|
81
|
-
:
|
82
|
-
:
|
83
|
-
:
|
80
|
+
brightbox_client_id: "app-12345",
|
81
|
+
brightbox_secret: "12345",
|
82
|
+
brightbox_username: "user@example.test",
|
83
|
+
brightbox_password: "abcde"
|
84
84
|
}
|
85
85
|
@config = Fog::Brightbox::Config.new(settings)
|
86
86
|
@request = Fog::Brightbox::Storage::AuthenticationRequest.new(@config)
|
@@ -5,8 +5,8 @@ describe Fog::Brightbox::Storage::Config do
|
|
5
5
|
describe "when required arguments are included" do
|
6
6
|
it "nothing is raised" do
|
7
7
|
settings = {
|
8
|
-
:
|
9
|
-
:
|
8
|
+
brightbox_client_id: "cli-12345",
|
9
|
+
brightbox_secret: "1234567890"
|
10
10
|
}
|
11
11
|
config = Fog::Brightbox::Config.new(settings)
|
12
12
|
Fog::Brightbox::Storage::Config.new(config)
|
@@ -17,7 +17,7 @@ describe Fog::Brightbox::Storage::Config do
|
|
17
17
|
describe "when client_id is not in configuration" do
|
18
18
|
it "raises ArgumentError" do
|
19
19
|
settings = {
|
20
|
-
:
|
20
|
+
brightbox_secret: "1234567890"
|
21
21
|
}
|
22
22
|
config = Fog::Brightbox::Config.new(settings)
|
23
23
|
assert_raises ArgumentError do
|
@@ -29,7 +29,7 @@ describe Fog::Brightbox::Storage::Config do
|
|
29
29
|
describe "when client_secret is not in configuration" do
|
30
30
|
it "raises ArgumentError" do
|
31
31
|
settings = {
|
32
|
-
:
|
32
|
+
brightbox_client_id: "cli-12345"
|
33
33
|
}
|
34
34
|
config = Fog::Brightbox::Config.new(settings)
|
35
35
|
assert_raises ArgumentError do
|
@@ -6,13 +6,13 @@ describe Fog::Brightbox::Storage::Connection do
|
|
6
6
|
let(:config) { Fog::Brightbox::Config.new(settings) }
|
7
7
|
let(:connection) { Fog::Brightbox::Storage::Connection.new(config) }
|
8
8
|
let(:params) do
|
9
|
-
{ :
|
9
|
+
{ path: "fnord", expects: [200] }
|
10
10
|
end
|
11
11
|
let(:settings) do
|
12
12
|
{
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
13
|
+
brightbox_client_id: "app-12345",
|
14
|
+
brightbox_secret: "1234567890",
|
15
|
+
brightbox_storage_management_url: "https://files.gb2.brightbox.com/v1/acc-12345"
|
16
16
|
}
|
17
17
|
end
|
18
18
|
let(:valid_auth_token) { "01234567890abcdefghijklmnopqrstuvwxyz" }
|
@@ -45,8 +45,8 @@ describe Fog::Brightbox::Storage::Connection do
|
|
45
45
|
}.each do |status, error|
|
46
46
|
describe "when request responds with #{status}" do
|
47
47
|
it "raises #{error}" do
|
48
|
-
stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345/fnord")
|
49
|
-
to_return(:
|
48
|
+
stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345/fnord")
|
49
|
+
.to_return(status: status)
|
50
50
|
assert_raises(error) { connection.request(params) }
|
51
51
|
end
|
52
52
|
end
|
@@ -6,13 +6,13 @@ describe Fog::Brightbox::Storage::Connection do
|
|
6
6
|
let(:config) { Fog::Brightbox::Config.new(settings) }
|
7
7
|
let(:connection) { Fog::Brightbox::Storage::Connection.new(config) }
|
8
8
|
let(:params) do
|
9
|
-
{ :
|
9
|
+
{ path: "fnord", expects: [200] }
|
10
10
|
end
|
11
11
|
let(:settings) do
|
12
12
|
{
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
13
|
+
brightbox_client_id: "app-12345",
|
14
|
+
brightbox_secret: "1234567890",
|
15
|
+
brightbox_storage_management_url: "https://files.gb2.brightbox.com/v1/acc-12345"
|
16
16
|
}
|
17
17
|
end
|
18
18
|
let(:valid_auth_token) { "01234567890abcdefghijklmnopqrstuvwxyz" }
|
@@ -20,8 +20,8 @@ describe Fog::Brightbox::Storage::Connection do
|
|
20
20
|
describe "when management URL is not available" do
|
21
21
|
let(:settings) do
|
22
22
|
{
|
23
|
-
:
|
24
|
-
:
|
23
|
+
brightbox_client_id: "app-12345",
|
24
|
+
brightbox_secret: "1234567890"
|
25
25
|
}
|
26
26
|
end
|
27
27
|
|
@@ -42,14 +42,14 @@ describe Fog::Brightbox::Storage::Connection do
|
|
42
42
|
let(:params) { {} }
|
43
43
|
|
44
44
|
before do
|
45
|
-
stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345")
|
46
|
-
with(:
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
45
|
+
stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345")
|
46
|
+
.with(headers: {
|
47
|
+
"Accept" => "application/json",
|
48
|
+
"Content-Type" => "application/json",
|
49
|
+
"X-Auth-Token" => valid_auth_token
|
50
|
+
}).to_return(status: 200, body: "{}", headers: {
|
51
|
+
"Content-Type" => "application/json"
|
52
|
+
})
|
53
53
|
end
|
54
54
|
|
55
55
|
it "completes successfully" do
|
@@ -62,14 +62,14 @@ describe Fog::Brightbox::Storage::Connection do
|
|
62
62
|
|
63
63
|
describe "when request should succeed" do
|
64
64
|
before do
|
65
|
-
stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345/fnord")
|
66
|
-
with(:
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
65
|
+
stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345/fnord")
|
66
|
+
.with(headers: {
|
67
|
+
"Accept" => "application/json",
|
68
|
+
"Content-Type" => "application/json",
|
69
|
+
"X-Auth-Token" => valid_auth_token
|
70
|
+
}).to_return(status: 200, body: "{}", headers: {
|
71
|
+
"Content-Type" => "application/json"
|
72
|
+
})
|
73
73
|
end
|
74
74
|
|
75
75
|
it "completes successfully" do
|
@@ -82,12 +82,12 @@ describe Fog::Brightbox::Storage::Connection do
|
|
82
82
|
|
83
83
|
describe "when custom headers are passed" do
|
84
84
|
let(:params) do
|
85
|
-
{ :
|
85
|
+
{ headers: { "X-Test" => "present" }, path: "fnord" }
|
86
86
|
end
|
87
87
|
|
88
88
|
it "completes successfully" do
|
89
|
-
stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345/fnord")
|
90
|
-
with(:
|
89
|
+
stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345/fnord")
|
90
|
+
.with(headers: { "X-Test" => "present" }).to_return(status: 200)
|
91
91
|
|
92
92
|
connection.request(params)
|
93
93
|
pass
|
@@ -96,24 +96,24 @@ describe Fog::Brightbox::Storage::Connection do
|
|
96
96
|
|
97
97
|
describe "when container is not found" do
|
98
98
|
it "raises Fog::Brightbox::Storage::NotFound" do
|
99
|
-
stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345/fnord")
|
100
|
-
to_return(:
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
99
|
+
stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345/fnord")
|
100
|
+
.to_return(status: 404,
|
101
|
+
body: "<html><h1>Not Found</h1><p>The resource could not be found.</p></html>",
|
102
|
+
headers: {
|
103
|
+
"Content-Type" => "text/html"
|
104
|
+
})
|
105
105
|
assert_raises(Fog::Brightbox::Storage::NotFound) { connection.request(params) }
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
109
|
describe "when request is not authenticated" do
|
110
110
|
it "raises Fog::Brightbox::Storage::AuthenticationRequired" do
|
111
|
-
stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345/fnord")
|
112
|
-
to_return(:
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
111
|
+
stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345/fnord")
|
112
|
+
.to_return(status: 401,
|
113
|
+
body: "Authentication required",
|
114
|
+
headers: {
|
115
|
+
"Content-Type" => "text/plain"
|
116
|
+
})
|
117
117
|
assert_raises(Fog::Brightbox::Storage::AuthenticationRequired) { connection.request(params) }
|
118
118
|
end
|
119
119
|
end
|
@@ -11,19 +11,19 @@ describe Fog::Brightbox::Storage::Directory do
|
|
11
11
|
describe ".create" do
|
12
12
|
let(:settings) do
|
13
13
|
{
|
14
|
-
:
|
15
|
-
:
|
14
|
+
brightbox_client_id: "cli-12345",
|
15
|
+
brightbox_secret: "fdkls"
|
16
16
|
}
|
17
17
|
end
|
18
18
|
let(:read_permissions) { ".r:*" }
|
19
19
|
let(:write_permissions) { "*:*" }
|
20
20
|
|
21
21
|
before do
|
22
|
-
stub_request(:get, "https://orbit.brightbox.com/v1")
|
23
|
-
to_return(authorized_response)
|
22
|
+
stub_request(:get, "https://orbit.brightbox.com/v1")
|
23
|
+
.to_return(authorized_response)
|
24
24
|
|
25
|
-
stub_request(:put, "https://orbit.brightbox.com/v1/acc-12345/container-name")
|
26
|
-
to_return(status: 201)
|
25
|
+
stub_request(:put, "https://orbit.brightbox.com/v1/acc-12345/container-name")
|
26
|
+
.to_return(status: 201)
|
27
27
|
end
|
28
28
|
|
29
29
|
it do
|
@@ -7,9 +7,9 @@ describe Fog::Brightbox::Storage::Files do
|
|
7
7
|
describe "#get_url" do
|
8
8
|
before do
|
9
9
|
@options = {
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
10
|
+
brightbox_client_id: "cli-12345",
|
11
|
+
brightbox_secret: "1234567890",
|
12
|
+
brightbox_storage_management_url: "https://management.url/v1/acc-12345"
|
13
13
|
}
|
14
14
|
@service = Fog::Brightbox::Storage.new(@options)
|
15
15
|
end
|
@@ -61,8 +61,8 @@ describe Fog::Brightbox::Storage::Files do
|
|
61
61
|
describe "when no management URL" do
|
62
62
|
before do
|
63
63
|
@options = {
|
64
|
-
:
|
65
|
-
:
|
64
|
+
brightbox_client_id: "cli-12345",
|
65
|
+
brightbox_secret: "1234567890"
|
66
66
|
}
|
67
67
|
@service = Fog::Brightbox::Storage.new(@options)
|
68
68
|
end
|
@@ -5,9 +5,9 @@ describe Fog::Brightbox::Storage do
|
|
5
5
|
describe "when passed in configuration" do
|
6
6
|
before do
|
7
7
|
@options = {
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
8
|
+
brightbox_client_id: "cli-12345",
|
9
|
+
brightbox_secret: "1234567890",
|
10
|
+
brightbox_storage_management_url: "https://management.url/v1/acc-12345"
|
11
11
|
}
|
12
12
|
@service = Fog::Brightbox::Storage.new(@options)
|
13
13
|
end
|
@@ -21,8 +21,8 @@ describe Fog::Brightbox::Storage do
|
|
21
21
|
describe "when unavailable" do
|
22
22
|
before do
|
23
23
|
@options = {
|
24
|
-
:
|
25
|
-
:
|
24
|
+
brightbox_client_id: "cli-12345",
|
25
|
+
brightbox_secret: "1234567890"
|
26
26
|
}
|
27
27
|
@service = Fog::Brightbox::Storage.new(@options)
|
28
28
|
end
|
@@ -21,12 +21,12 @@ describe Fog::Brightbox::Compute::DatabaseServer do
|
|
21
21
|
|
22
22
|
describe "when snapshotting with no options" do
|
23
23
|
it "returns the database server" do
|
24
|
-
stub_request(:post, "http://localhost/1.0/database_servers/dbs-12345/snapshot")
|
25
|
-
with(:
|
26
|
-
|
27
|
-
to_return(:
|
24
|
+
stub_request(:post, "http://localhost/1.0/database_servers/dbs-12345/snapshot")
|
25
|
+
.with(query: hash_including(:account_id),
|
26
|
+
headers: { "Authorization" => "Bearer FAKECACHEDTOKEN" })
|
27
|
+
.to_return(status: 202, body: '{"id": "dbs-12345"}', headers: {})
|
28
28
|
|
29
|
-
@database_server = Fog::Brightbox::Compute::DatabaseServer.new(:
|
29
|
+
@database_server = Fog::Brightbox::Compute::DatabaseServer.new(service: service, id: "dbs-12345")
|
30
30
|
assert @database_server.snapshot
|
31
31
|
end
|
32
32
|
end
|
@@ -35,28 +35,28 @@ describe Fog::Brightbox::Compute::DatabaseServer do
|
|
35
35
|
it "returns the new image" do
|
36
36
|
link = "<https://api.gb1.brightbox.com/1.0/database_snapshots/dbi-12345>; rel=snapshot"
|
37
37
|
|
38
|
-
stub_request(:post, "http://localhost/1.0/database_servers/dbs-12345/snapshot")
|
39
|
-
with(:
|
40
|
-
to_return(:
|
38
|
+
stub_request(:post, "http://localhost/1.0/database_servers/dbs-12345/snapshot")
|
39
|
+
.with(headers: { "Authorization" => "Bearer FAKECACHEDTOKEN" })
|
40
|
+
.to_return(status: 202, body: "{}", headers: { "Link" => link })
|
41
41
|
|
42
|
-
stub_request(:get, "http://localhost/1.0/database_snapshots/dbi-12345")
|
43
|
-
with(:
|
44
|
-
|
45
|
-
to_return(:
|
46
|
-
@database_server = Fog::Brightbox::Compute::DatabaseServer.new(:
|
42
|
+
stub_request(:get, "http://localhost/1.0/database_snapshots/dbi-12345")
|
43
|
+
.with(query: hash_including(:account_id),
|
44
|
+
headers: { "Authorization" => "Bearer FAKECACHEDTOKEN" })
|
45
|
+
.to_return(status: 200, body: '{"id": "dbs-12345"}')
|
46
|
+
@database_server = Fog::Brightbox::Compute::DatabaseServer.new(service: service, id: "dbs-12345")
|
47
47
|
assert_kind_of Fog::Brightbox::Compute::DatabaseSnapshot, @database_server.snapshot(true)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
describe "when building from a snapshot" do
|
52
52
|
it "returns the new SQL instance" do
|
53
|
-
stub_request(:post, "http://localhost/1.0/database_servers")
|
54
|
-
with(:
|
55
|
-
|
56
|
-
|
57
|
-
to_return(:
|
53
|
+
stub_request(:post, "http://localhost/1.0/database_servers")
|
54
|
+
.with(query: hash_including(:account_id),
|
55
|
+
headers: { "Authorization" => "Bearer FAKECACHEDTOKEN" },
|
56
|
+
body: hash_including(snapshot: "dbi-lv426"))
|
57
|
+
.to_return(status: 202, body: '{"id": "dbs-12345"}')
|
58
58
|
|
59
|
-
@database_server = Fog::Brightbox::Compute::DatabaseServer.new(:
|
59
|
+
@database_server = Fog::Brightbox::Compute::DatabaseServer.new(service: service, snapshot_id: "dbi-lv426")
|
60
60
|
@database_server.save
|
61
61
|
assert_kind_of Fog::Brightbox::Compute::DatabaseServer, @database_server
|
62
62
|
assert_equal "dbs-12345", @database_server.id
|