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
@@ -14,10 +14,10 @@ module Fog
|
|
14
14
|
# * 'X-Container-Bytes-Used'<~String> - Bytes used
|
15
15
|
def head_container(container)
|
16
16
|
request(
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
20
|
-
:
|
17
|
+
expects: 204,
|
18
|
+
method: "HEAD",
|
19
|
+
path: Fog::Brightbox::Storage.escape(container),
|
20
|
+
query: { "format" => "json" }
|
21
21
|
)
|
22
22
|
end
|
23
23
|
end
|
@@ -11,10 +11,10 @@ module Fog
|
|
11
11
|
# * 'X-Account-Bytes-Used'<~String> - Bytes used
|
12
12
|
def head_containers
|
13
13
|
request(
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
14
|
+
expects: 204,
|
15
|
+
method: "HEAD",
|
16
|
+
path: "",
|
17
|
+
query: { "format" => "json" }
|
18
18
|
)
|
19
19
|
end
|
20
20
|
end
|
@@ -10,9 +10,9 @@ module Fog
|
|
10
10
|
#
|
11
11
|
def head_object(container, object)
|
12
12
|
request({
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
13
|
+
expects: 200,
|
14
|
+
method: "HEAD",
|
15
|
+
path: "#{Fog::Brightbox::Storage.escape(container)}/#{Fog::Brightbox::Storage.escape(object)}"
|
16
16
|
}, false)
|
17
17
|
end
|
18
18
|
end
|
@@ -22,9 +22,9 @@ module Fog
|
|
22
22
|
# http://docs.rackspace.com/files/api/v1/cf-devguide/content/Set_Account_Metadata-d1a4460.html
|
23
23
|
def post_set_meta_temp_url_key(key)
|
24
24
|
request(
|
25
|
-
:
|
26
|
-
:
|
27
|
-
:
|
25
|
+
expects: [201, 202, 204],
|
26
|
+
method: "POST",
|
27
|
+
headers: { "X-Account-Meta-Temp-Url-Key" => key }
|
28
28
|
)
|
29
29
|
end
|
30
30
|
end
|
@@ -13,10 +13,10 @@ module Fog
|
|
13
13
|
headers["X-Container-Write"] ||= options.delete(:write_permissions)
|
14
14
|
|
15
15
|
request(
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
16
|
+
expects: [201, 202],
|
17
|
+
method: "PUT",
|
18
|
+
path: Fog::Brightbox::Storage.escape(name),
|
19
|
+
headers: headers
|
20
20
|
)
|
21
21
|
end
|
22
22
|
end
|
@@ -29,10 +29,10 @@ module Fog
|
|
29
29
|
path = "#{Fog::Brightbox::Storage.escape(container)}/#{Fog::Brightbox::Storage.escape(object)}"
|
30
30
|
headers = { "X-Object-Manifest" => path }.merge(options)
|
31
31
|
request(
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
32
|
+
expects: 201,
|
33
|
+
headers: headers,
|
34
|
+
method: "PUT",
|
35
|
+
path: path
|
36
36
|
)
|
37
37
|
end
|
38
38
|
end
|
@@ -17,20 +17,20 @@ module Fog
|
|
17
17
|
#
|
18
18
|
def put_object(container, object, data, options = {}, &block)
|
19
19
|
if block_given?
|
20
|
-
params = { :
|
20
|
+
params = { request_block: block }
|
21
21
|
headers = options
|
22
22
|
else
|
23
23
|
data = Fog::Storage.parse_data(data)
|
24
24
|
headers = data[:headers].merge!(options)
|
25
|
-
params = { :
|
25
|
+
params = { body: data[:body] }
|
26
26
|
end
|
27
27
|
|
28
28
|
params.merge!(
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
33
|
-
:
|
29
|
+
expects: 201,
|
30
|
+
idempotent: !params[:request_block],
|
31
|
+
headers: headers,
|
32
|
+
method: "PUT",
|
33
|
+
path: "#{Fog::Brightbox::Storage.escape(container)}/#{Fog::Brightbox::Storage.escape(object)}"
|
34
34
|
)
|
35
35
|
|
36
36
|
request(params)
|
@@ -41,12 +41,12 @@ module Fog
|
|
41
41
|
# @see http://docs.brightbox.org/api/brightbox-object-storage/1.0/content/static-large-objects.html
|
42
42
|
def put_static_obj_manifest(container, object, segments, options = {})
|
43
43
|
request(
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:
|
48
|
-
:
|
49
|
-
:
|
44
|
+
expects: 201,
|
45
|
+
method: "PUT",
|
46
|
+
headers: options,
|
47
|
+
body: Fog::JSON.encode(segments),
|
48
|
+
path: "#{Fog::Brightbox::Storage.escape(container)}/#{Fog::Brightbox::Storage.escape(object)}",
|
49
|
+
query: { "multipart-manifest" => "put" }
|
50
50
|
)
|
51
51
|
end
|
52
52
|
end
|
@@ -25,10 +25,10 @@ module Fog
|
|
25
25
|
authentication_url = URI.parse(@config.storage_url.to_s)
|
26
26
|
connection = Fog::Core::Connection.new(authentication_url.to_s)
|
27
27
|
request_settings = {
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
28
|
+
expects: [200, 204],
|
29
|
+
headers: auth_headers,
|
30
|
+
method: "GET",
|
31
|
+
path: "v1"
|
32
32
|
}
|
33
33
|
connection.request(request_settings)
|
34
34
|
end
|
@@ -16,8 +16,8 @@ module Fog
|
|
16
16
|
begin
|
17
17
|
raise ArgumentError if params.nil?
|
18
18
|
request_params = params.merge(
|
19
|
-
:
|
20
|
-
:
|
19
|
+
headers: request_headers(params),
|
20
|
+
path: path_in_params(params)
|
21
21
|
)
|
22
22
|
response = @connection.request(request_params)
|
23
23
|
rescue Excon::Errors::Unauthorized => error
|
@@ -44,17 +44,16 @@ module Fog
|
|
44
44
|
request :put_static_obj_manifest
|
45
45
|
|
46
46
|
class Mock
|
47
|
-
def initialize(_options = {})
|
48
|
-
end
|
47
|
+
def initialize(_options = {}); end
|
49
48
|
end
|
50
49
|
|
51
50
|
class Real
|
52
51
|
def initialize(config)
|
53
|
-
if config.respond_to?(:config_service?) && config.config_service?
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
52
|
+
@config = if config.respond_to?(:config_service?) && config.config_service?
|
53
|
+
config
|
54
|
+
else
|
55
|
+
Fog::Brightbox::Config.new(config)
|
56
|
+
end
|
58
57
|
@config = Fog::Brightbox::Storage::Config.new(@config)
|
59
58
|
|
60
59
|
@temp_url_key = @config.storage_temp_key
|
@@ -152,9 +151,9 @@ module Fog
|
|
152
151
|
raise ArgumentError, "Storage must be instantiated with the :brightbox_temp_url_key option" if @config.storage_temp_key.nil?
|
153
152
|
|
154
153
|
# POST not allowed
|
155
|
-
allowed_methods = %w
|
154
|
+
allowed_methods = %w[GET PUT HEAD]
|
156
155
|
unless allowed_methods.include?(method)
|
157
|
-
raise ArgumentError
|
156
|
+
raise ArgumentError, "Invalid method '#{method}' specified. Valid methods are: #{allowed_methods.join(', ')}"
|
158
157
|
end
|
159
158
|
|
160
159
|
if management_url.nil?
|
@@ -168,7 +167,7 @@ module Fog
|
|
168
167
|
destination_url.scheme = options[:scheme] if options[:scheme]
|
169
168
|
destination_url.port = options[:port] if options[:port]
|
170
169
|
|
171
|
-
object_path_escaped = "#{object_path}/#{Fog::Brightbox::Storage.escape(container)}/#{Fog::Brightbox::Storage.escape(object,
|
170
|
+
object_path_escaped = "#{object_path}/#{Fog::Brightbox::Storage.escape(container)}/#{Fog::Brightbox::Storage.escape(object, '/')}"
|
172
171
|
object_path_unescaped = "#{object_path}/#{Fog::Brightbox::Storage.escape(container)}/#{object}"
|
173
172
|
|
174
173
|
expiry_timestamp = expires_at.to_i
|
@@ -178,18 +177,18 @@ module Fog
|
|
178
177
|
sig = sig_to_hex(hmac.sign(string_to_sign))
|
179
178
|
|
180
179
|
destination_url.path = object_path_escaped
|
181
|
-
destination_url.query = URI.encode_www_form(:
|
180
|
+
destination_url.query = URI.encode_www_form(temp_url_sig: sig, temp_url_expires: expiry_timestamp)
|
182
181
|
destination_url.to_s
|
183
182
|
end
|
184
183
|
|
185
184
|
private
|
186
185
|
|
187
186
|
def sig_to_hex(str)
|
188
|
-
str.unpack("C*").map
|
187
|
+
str.unpack("C*").map do |c|
|
189
188
|
c.to_s(16)
|
190
|
-
|
189
|
+
end.map do |h|
|
191
190
|
h.size == 1 ? "0#{h}" : h
|
192
|
-
|
191
|
+
end.join
|
193
192
|
end
|
194
193
|
|
195
194
|
def update_config_from_auth_response(response)
|
@@ -4,8 +4,8 @@ describe Fog::Brightbox::Compute::Config do
|
|
4
4
|
describe "when required arguments are included" do
|
5
5
|
it "nothing is raised" do
|
6
6
|
settings = {
|
7
|
-
:
|
8
|
-
:
|
7
|
+
brightbox_client_id: "cli-12345",
|
8
|
+
brightbox_secret: "1234567890"
|
9
9
|
}
|
10
10
|
config = Fog::Brightbox::Config.new(settings)
|
11
11
|
Fog::Brightbox::Compute::Config.new(config)
|
@@ -16,7 +16,7 @@ describe Fog::Brightbox::Compute::Config do
|
|
16
16
|
describe "when client_id is not in configuration" do
|
17
17
|
it "raises ArgumentError" do
|
18
18
|
settings = {
|
19
|
-
:
|
19
|
+
brightbox_secret: "1234567890"
|
20
20
|
}
|
21
21
|
config = Fog::Brightbox::Config.new(settings)
|
22
22
|
assert_raises ArgumentError do
|
@@ -28,7 +28,7 @@ describe Fog::Brightbox::Compute::Config do
|
|
28
28
|
describe "when client_secret is not in configuration" do
|
29
29
|
it "raises ArgumentError" do
|
30
30
|
settings = {
|
31
|
-
:
|
31
|
+
brightbox_client_id: "cli-12345"
|
32
32
|
}
|
33
33
|
config = Fog::Brightbox::Config.new(settings)
|
34
34
|
assert_raises ArgumentError do
|
@@ -238,7 +238,7 @@ describe Fog::Brightbox::Compute, "#get_access_token" do
|
|
238
238
|
# @param auth_correct [Boolean] Treat username/password as correct
|
239
239
|
# @param two_factor_user [Boolean] Is user protected by 2FA on server
|
240
240
|
# @param otp_sent [Boolean] Is an OTP sent in the request?
|
241
|
-
def stub_authentication_request(auth_correct
|
241
|
+
def stub_authentication_request(auth_correct: true,
|
242
242
|
two_factor_user: false,
|
243
243
|
otp_sent: nil)
|
244
244
|
|
@@ -247,7 +247,7 @@ describe Fog::Brightbox::Compute, "#get_access_token" do
|
|
247
247
|
request = {
|
248
248
|
headers: {
|
249
249
|
"Authorization" => "Basic YXBwLTEyMzQ1OjEyMzQ1Njc4OTA=",
|
250
|
-
"Content-Type" => "application/json"
|
250
|
+
"Content-Type" => "application/json"
|
251
251
|
},
|
252
252
|
body: {
|
253
253
|
grant_type: "password",
|
@@ -271,32 +271,32 @@ describe Fog::Brightbox::Compute, "#get_access_token" do
|
|
271
271
|
# * User does use 2FA and FAILS to send OTP
|
272
272
|
#
|
273
273
|
response = if two_factor_user && !otp_sent
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
274
|
+
# OTP required header
|
275
|
+
{
|
276
|
+
status: 401,
|
277
|
+
headers: {
|
278
|
+
"X-Brightbox-OTP" => "required"
|
279
|
+
},
|
280
|
+
body: { error: "invalid_client" }.to_json
|
281
|
+
}
|
282
|
+
elsif !auth_correct
|
283
|
+
# No OTP header
|
284
|
+
{
|
285
|
+
status: 401,
|
286
|
+
headers: {},
|
287
|
+
body: { error: "invalid_client" }.to_json
|
288
|
+
}
|
289
|
+
else
|
290
|
+
{
|
291
|
+
status: 200,
|
292
|
+
headers: {},
|
293
|
+
body: {
|
294
|
+
access_token: @new_access_token,
|
295
|
+
refresh_token: @new_refresh_token,
|
296
|
+
expires_in: 7200
|
297
|
+
}.to_json
|
298
|
+
}
|
299
|
+
end
|
300
300
|
|
301
301
|
stub_request(:post, "https://api.gb1.brightbox.com/token")
|
302
302
|
.with(request)
|
@@ -5,20 +5,20 @@ describe Fog::Brightbox::Compute do
|
|
5
5
|
describe "when nested option passed as true" do
|
6
6
|
before do
|
7
7
|
@options = {
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
8
|
+
brightbox_client_id: "cli-12345",
|
9
|
+
brightbox_secret: "1234567890",
|
10
|
+
brightbox_access_token: "TESTVALUE"
|
11
11
|
}
|
12
12
|
@service = Fog::Brightbox::Compute.new(@options)
|
13
13
|
end
|
14
14
|
|
15
15
|
it "makes correct request" do
|
16
|
-
stub_request(:get, "https://api.gb1.brightbox.com/1.0/accounts")
|
17
|
-
with(:
|
18
|
-
|
19
|
-
to_return(:
|
16
|
+
stub_request(:get, "https://api.gb1.brightbox.com/1.0/accounts")
|
17
|
+
.with(headers: { "Authorization" => "Bearer TESTVALUE" },
|
18
|
+
query: { nested: "true" })
|
19
|
+
.to_return(status: 200, body: "", headers: {})
|
20
20
|
|
21
|
-
@service.wrapped_request("get", "/1.0/accounts", [200], :
|
21
|
+
@service.wrapped_request("get", "/1.0/accounts", [200], nested: "true")
|
22
22
|
pass
|
23
23
|
end
|
24
24
|
end
|
@@ -26,20 +26,20 @@ describe Fog::Brightbox::Compute do
|
|
26
26
|
describe "when nested option passed as false" do
|
27
27
|
before do
|
28
28
|
@options = {
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
29
|
+
brightbox_client_id: "cli-12345",
|
30
|
+
brightbox_secret: "1234567890",
|
31
|
+
brightbox_access_token: "TESTVALUE"
|
32
32
|
}
|
33
33
|
@service = Fog::Brightbox::Compute.new(@options)
|
34
34
|
end
|
35
35
|
|
36
36
|
it "makes correct request" do
|
37
|
-
stub_request(:get, "https://api.gb1.brightbox.com/1.0/accounts")
|
38
|
-
with(:
|
39
|
-
|
40
|
-
to_return(:
|
37
|
+
stub_request(:get, "https://api.gb1.brightbox.com/1.0/accounts")
|
38
|
+
.with(headers: { "Authorization" => "Bearer TESTVALUE" },
|
39
|
+
query: { nested: "false" })
|
40
|
+
.to_return(status: 200, body: "", headers: {})
|
41
41
|
|
42
|
-
@service.wrapped_request("get", "/1.0/accounts", [200], :
|
42
|
+
@service.wrapped_request("get", "/1.0/accounts", [200], nested: "false")
|
43
43
|
pass
|
44
44
|
end
|
45
45
|
end
|
@@ -47,18 +47,18 @@ describe Fog::Brightbox::Compute do
|
|
47
47
|
describe "when nested option not passed" do
|
48
48
|
before do
|
49
49
|
@options = {
|
50
|
-
:
|
51
|
-
:
|
52
|
-
:
|
50
|
+
brightbox_client_id: "cli-12345",
|
51
|
+
brightbox_secret: "1234567890",
|
52
|
+
brightbox_access_token: "TESTVALUE"
|
53
53
|
}
|
54
54
|
@service = Fog::Brightbox::Compute.new(@options)
|
55
55
|
end
|
56
56
|
|
57
57
|
it "makes correct request" do
|
58
|
-
stub_request(:get, "https://api.gb1.brightbox.com/1.0/accounts")
|
59
|
-
with(:
|
60
|
-
|
61
|
-
to_return(:
|
58
|
+
stub_request(:get, "https://api.gb1.brightbox.com/1.0/accounts")
|
59
|
+
.with(headers: { "Authorization" => "Bearer TESTVALUE" },
|
60
|
+
query: {})
|
61
|
+
.to_return(status: 200, body: "", headers: {})
|
62
62
|
|
63
63
|
@service.wrapped_request("get", "/1.0/accounts", [200])
|
64
64
|
pass
|
@@ -16,7 +16,7 @@ describe Fog::Brightbox::Config do
|
|
16
16
|
describe "when created with a Hash" do
|
17
17
|
it "does not error" do
|
18
18
|
@options = {
|
19
|
-
:
|
19
|
+
brightbox_client_id: "cli-12345"
|
20
20
|
}
|
21
21
|
@config = Fog::Brightbox::Config.new(@options)
|
22
22
|
assert_instance_of Fog::Brightbox::Config, @config
|
@@ -25,7 +25,7 @@ describe Fog::Brightbox::Config do
|
|
25
25
|
|
26
26
|
describe "when auth url options was passed" do
|
27
27
|
it "returns the setting" do
|
28
|
-
@options = { :
|
28
|
+
@options = { brightbox_auth_url: "https://api.gb1.brightbox.com" }
|
29
29
|
@config = Fog::Brightbox::Config.new(@options)
|
30
30
|
assert_instance_of URI::HTTPS, @config.auth_url
|
31
31
|
end
|
@@ -41,7 +41,7 @@ describe Fog::Brightbox::Config do
|
|
41
41
|
|
42
42
|
describe "when compute url options was passed" do
|
43
43
|
it "returns the setting" do
|
44
|
-
@options = { :
|
44
|
+
@options = { brightbox_api_url: "https://api.gb1.brightbox.com" }
|
45
45
|
@config = Fog::Brightbox::Config.new(@options)
|
46
46
|
assert_instance_of URI::HTTPS, @config.compute_url
|
47
47
|
assert_equal @config.compute_url, @config.api_url
|
@@ -59,7 +59,7 @@ describe Fog::Brightbox::Config do
|
|
59
59
|
|
60
60
|
describe "when client id is passed" do
|
61
61
|
it "returns the settings" do
|
62
|
-
@options = { :
|
62
|
+
@options = { brightbox_client_id: "cli-12345" }
|
63
63
|
@config = Fog::Brightbox::Config.new(@options)
|
64
64
|
assert_equal "cli-12345", @config.client_id
|
65
65
|
end
|
@@ -67,7 +67,7 @@ describe Fog::Brightbox::Config do
|
|
67
67
|
|
68
68
|
describe "when client secret is passed" do
|
69
69
|
it "returns the settings" do
|
70
|
-
@options = { :
|
70
|
+
@options = { brightbox_secret: "secret" }
|
71
71
|
@config = Fog::Brightbox::Config.new(@options)
|
72
72
|
assert_equal "secret", @config.client_secret
|
73
73
|
end
|
@@ -75,7 +75,7 @@ describe Fog::Brightbox::Config do
|
|
75
75
|
|
76
76
|
describe "when username is passed" do
|
77
77
|
it "returns the settings" do
|
78
|
-
@options = { :
|
78
|
+
@options = { brightbox_username: "usr-12345" }
|
79
79
|
@config = Fog::Brightbox::Config.new(@options)
|
80
80
|
assert_equal "usr-12345", @config.username
|
81
81
|
end
|
@@ -83,7 +83,7 @@ describe Fog::Brightbox::Config do
|
|
83
83
|
|
84
84
|
describe "when password is passed" do
|
85
85
|
it "returns the settings" do
|
86
|
-
@options = { :
|
86
|
+
@options = { brightbox_password: "password" }
|
87
87
|
@config = Fog::Brightbox::Config.new(@options)
|
88
88
|
assert_equal "password", @config.password
|
89
89
|
end
|
@@ -91,7 +91,7 @@ describe Fog::Brightbox::Config do
|
|
91
91
|
|
92
92
|
describe "when account is passed" do
|
93
93
|
it "returns the settings" do
|
94
|
-
@options = { :
|
94
|
+
@options = { brightbox_account: "acc-12345" }
|
95
95
|
@config = Fog::Brightbox::Config.new(@options)
|
96
96
|
assert_equal "acc-12345", @config.account
|
97
97
|
end
|
@@ -99,7 +99,7 @@ describe Fog::Brightbox::Config do
|
|
99
99
|
|
100
100
|
describe "when account was passed but changed" do
|
101
101
|
it "returns the new account" do
|
102
|
-
@options = { :
|
102
|
+
@options = { brightbox_account: "acc-12345" }
|
103
103
|
@config = Fog::Brightbox::Config.new(@options)
|
104
104
|
@config.change_account("acc-abcde")
|
105
105
|
assert_equal "acc-abcde", @config.account
|
@@ -108,7 +108,7 @@ describe Fog::Brightbox::Config do
|
|
108
108
|
|
109
109
|
describe "when account was passed, changed and reset" do
|
110
110
|
it "returns the original account" do
|
111
|
-
@options = { :
|
111
|
+
@options = { brightbox_account: "acc-12345" }
|
112
112
|
@config = Fog::Brightbox::Config.new(@options)
|
113
113
|
@config.change_account("acc-abcde")
|
114
114
|
@config.reset_account
|
@@ -119,12 +119,12 @@ describe Fog::Brightbox::Config do
|
|
119
119
|
describe "when connection options are passed" do
|
120
120
|
it "returns the settings" do
|
121
121
|
@connection_settings = {
|
122
|
-
:
|
122
|
+
headers: {
|
123
123
|
"Content-Type" => "application/json"
|
124
124
|
}
|
125
125
|
}
|
126
126
|
@options = {
|
127
|
-
:
|
127
|
+
connection_options: @connection_settings
|
128
128
|
}
|
129
129
|
@config = Fog::Brightbox::Config.new(@options)
|
130
130
|
assert_equal @connection_settings, @config.connection_options
|
@@ -140,7 +140,7 @@ describe Fog::Brightbox::Config do
|
|
140
140
|
|
141
141
|
describe "when persistent connection is requested" do
|
142
142
|
it "returns true for the setting" do
|
143
|
-
@options = { :
|
143
|
+
@options = { persistent: true }
|
144
144
|
@config = Fog::Brightbox::Config.new(@options)
|
145
145
|
assert @config.connection_persistent?
|
146
146
|
end
|
@@ -158,8 +158,8 @@ describe Fog::Brightbox::Config do
|
|
158
158
|
@access_token = "1234567890abcdefghijklmnopqrstuvwxyz"
|
159
159
|
@refresh_token = "1234567890abcdefghijklmnopqrstuvwxyz"
|
160
160
|
@options = {
|
161
|
-
:
|
162
|
-
:
|
161
|
+
brightbox_access_token: @access_token,
|
162
|
+
brightbox_refresh_token: @refresh_token
|
163
163
|
}
|
164
164
|
@config = Fog::Brightbox::Config.new(@options)
|
165
165
|
end
|
@@ -194,7 +194,7 @@ describe Fog::Brightbox::Config do
|
|
194
194
|
|
195
195
|
describe "when token management setting is disabled" do
|
196
196
|
it "returns false" do
|
197
|
-
@options = { :
|
197
|
+
@options = { brightbox_token_management: false }
|
198
198
|
@config = Fog::Brightbox::Config.new(@options)
|
199
199
|
refute @config.managed_tokens?
|
200
200
|
end
|
@@ -202,7 +202,7 @@ describe Fog::Brightbox::Config do
|
|
202
202
|
|
203
203
|
describe "when a default server image is configured" do
|
204
204
|
it "returns the configured setting" do
|
205
|
-
@options = { :
|
205
|
+
@options = { brightbox_default_image: "img-12345" }
|
206
206
|
@config = Fog::Brightbox::Config.new(@options)
|
207
207
|
assert_equal "img-12345", @config.default_image_id
|
208
208
|
end
|
@@ -218,10 +218,10 @@ describe Fog::Brightbox::Config do
|
|
218
218
|
describe "when username and password are given" do
|
219
219
|
it "user_credentials? returns true" do
|
220
220
|
@options = {
|
221
|
-
:
|
222
|
-
:
|
223
|
-
:
|
224
|
-
:
|
221
|
+
brightbox_client_id: "app-12345",
|
222
|
+
brightbox_secret: "12345",
|
223
|
+
brightbox_username: "user@example.test",
|
224
|
+
brightbox_password: "12345"
|
225
225
|
}
|
226
226
|
@config = Fog::Brightbox::Config.new(@options)
|
227
227
|
assert @config.user_credentials?
|
@@ -231,8 +231,8 @@ describe Fog::Brightbox::Config do
|
|
231
231
|
describe "when no username is given" do
|
232
232
|
it "user_credentials? returns false" do
|
233
233
|
@options = {
|
234
|
-
:
|
235
|
-
:
|
234
|
+
brightbox_client_id: "cli-12345",
|
235
|
+
brightbox_secret: "12345"
|
236
236
|
}
|
237
237
|
@config = Fog::Brightbox::Config.new(@options)
|
238
238
|
refute @config.user_credentials?
|
@@ -8,11 +8,11 @@ describe Fog::Brightbox::OAuth2::ClientCredentialsStrategy do
|
|
8
8
|
@strategy = Fog::Brightbox::OAuth2::ClientCredentialsStrategy.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
|
|
@@ -35,7 +35,7 @@ describe Fog::Brightbox::OAuth2::CredentialSet do
|
|
35
35
|
|
36
36
|
describe "when using user credentials" do
|
37
37
|
before do
|
38
|
-
options = { :
|
38
|
+
options = { username: @username, password: @password }
|
39
39
|
@credentials = Fog::Brightbox::OAuth2::CredentialSet.new(@client_id, @client_secret, options)
|
40
40
|
end
|
41
41
|
|
@@ -59,10 +59,10 @@ describe Fog::Brightbox::OAuth2::CredentialSet do
|
|
59
59
|
describe "when using refresh token" do
|
60
60
|
before do
|
61
61
|
options = {
|
62
|
-
:
|
63
|
-
:
|
64
|
-
:
|
65
|
-
:
|
62
|
+
username: @username,
|
63
|
+
access_token: @access_token,
|
64
|
+
refresh_token: @refresh_token,
|
65
|
+
expires_in: @expires_in
|
66
66
|
}
|
67
67
|
@credentials = Fog::Brightbox::OAuth2::CredentialSet.new(@client_id, @client_secret, options)
|
68
68
|
end
|