brightbox-cli 1.2.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +26 -0
- data/Gemfile +0 -2
- data/Gemfile.lock +25 -23
- data/Rakefile +1 -1
- data/bin/_brightbox-bash-completer +327 -328
- data/bin/brightbox +2 -2
- data/bin/brightbox-accounts +2 -2
- data/bin/brightbox-cloudips +2 -2
- data/bin/brightbox-config +2 -2
- data/bin/brightbox-firewall-policies +2 -2
- data/bin/brightbox-firewall-rules +2 -2
- data/bin/brightbox-groups +2 -2
- data/bin/brightbox-images +2 -2
- data/bin/brightbox-lbs +2 -2
- data/bin/brightbox-servers +2 -2
- data/bin/brightbox-types +2 -2
- data/bin/brightbox-users +2 -2
- data/bin/brightbox-zones +2 -2
- data/brightbox-cli.gemspec +14 -15
- data/lib/brightbox-cli/api.rb +4 -6
- data/lib/brightbox-cli/collaboration.rb +1 -3
- data/lib/brightbox-cli/commands/accounts/accept-invite.rb +1 -1
- data/lib/brightbox-cli/commands/accounts/default.rb +1 -1
- data/lib/brightbox-cli/commands/accounts/list.rb +1 -1
- data/lib/brightbox-cli/commands/accounts/remove.rb +1 -1
- data/lib/brightbox-cli/commands/accounts/reset-ftp-password.rb +1 -1
- data/lib/brightbox-cli/commands/accounts/show.rb +1 -1
- data/lib/brightbox-cli/commands/cloudips/create.rb +1 -1
- data/lib/brightbox-cli/commands/cloudips/destroy.rb +1 -1
- data/lib/brightbox-cli/commands/cloudips/list.rb +1 -1
- data/lib/brightbox-cli/commands/cloudips/show.rb +1 -1
- data/lib/brightbox-cli/commands/cloudips/unmap.rb +1 -1
- data/lib/brightbox-cli/commands/collaborations.rb +4 -4
- data/lib/brightbox-cli/commands/config/client-add.rb +1 -1
- data/lib/brightbox-cli/commands/config/client-default.rb +1 -1
- data/lib/brightbox-cli/commands/config/client-list.rb +1 -1
- data/lib/brightbox-cli/commands/config/client-remove.rb +1 -1
- data/lib/brightbox-cli/commands/config/user-add.rb +1 -1
- data/lib/brightbox-cli/commands/firewall/policies-destroy.rb +1 -1
- data/lib/brightbox-cli/commands/firewall/policies-list.rb +1 -1
- data/lib/brightbox-cli/commands/firewall/policies-show.rb +1 -1
- data/lib/brightbox-cli/commands/firewall/rules-destroy.rb +1 -1
- data/lib/brightbox-cli/commands/firewall/rules-list.rb +1 -1
- data/lib/brightbox-cli/commands/firewall/rules-show.rb +1 -1
- data/lib/brightbox-cli/commands/groups/add-server.rb +1 -1
- data/lib/brightbox-cli/commands/groups/create.rb +1 -1
- data/lib/brightbox-cli/commands/groups/destroy.rb +1 -1
- data/lib/brightbox-cli/commands/groups/list.rb +1 -1
- data/lib/brightbox-cli/commands/groups/show.rb +1 -1
- data/lib/brightbox-cli/commands/images/destroy.rb +1 -1
- data/lib/brightbox-cli/commands/images/locking.rb +37 -0
- data/lib/brightbox-cli/commands/images/register.rb +1 -1
- data/lib/brightbox-cli/commands/images/show.rb +18 -4
- data/lib/brightbox-cli/commands/lbs/add-nodes.rb +1 -1
- data/lib/brightbox-cli/commands/lbs/destroy.rb +1 -1
- data/lib/brightbox-cli/commands/lbs/list.rb +1 -1
- data/lib/brightbox-cli/commands/lbs/locking.rb +37 -0
- data/lib/brightbox-cli/commands/lbs/remove-nodes.rb +1 -1
- data/lib/brightbox-cli/commands/lbs/show.rb +3 -2
- data/lib/brightbox-cli/commands/servers/activate-console.rb +1 -1
- data/lib/brightbox-cli/commands/servers/destroy.rb +1 -1
- data/lib/brightbox-cli/commands/servers/locking.rb +37 -0
- data/lib/brightbox-cli/commands/servers/reboot.rb +20 -0
- data/lib/brightbox-cli/commands/servers/reset.rb +20 -0
- data/lib/brightbox-cli/commands/servers/show.rb +1 -1
- data/lib/brightbox-cli/commands/servers/shutdown.rb +1 -1
- data/lib/brightbox-cli/commands/servers/snapshot.rb +1 -1
- data/lib/brightbox-cli/commands/servers/start.rb +1 -1
- data/lib/brightbox-cli/commands/servers/stop.rb +1 -1
- data/lib/brightbox-cli/commands/sql/instances_create.rb +1 -1
- data/lib/brightbox-cli/commands/sql/instances_destroy.rb +1 -1
- data/lib/brightbox-cli/commands/sql/instances_list.rb +1 -1
- data/lib/brightbox-cli/commands/sql/instances_locking.rb +39 -0
- data/lib/brightbox-cli/commands/sql/instances_reset_password.rb +1 -1
- data/lib/brightbox-cli/commands/sql/instances_show.rb +1 -1
- data/lib/brightbox-cli/commands/sql/instances_snapshot.rb +1 -1
- data/lib/brightbox-cli/commands/sql/snapshots_destroy.rb +1 -1
- data/lib/brightbox-cli/commands/sql/snapshots_list.rb +1 -1
- data/lib/brightbox-cli/commands/sql/snapshots_locking.rb +39 -0
- data/lib/brightbox-cli/commands/sql/snapshots_show.rb +9 -2
- data/lib/brightbox-cli/commands/sql/types.rb +2 -2
- data/lib/brightbox-cli/commands/types.rb +2 -2
- data/lib/brightbox-cli/commands/user-collaborations.rb +2 -2
- data/lib/brightbox-cli/commands/users/list.rb +1 -1
- data/lib/brightbox-cli/commands/users/show.rb +1 -1
- data/lib/brightbox-cli/commands/zones.rb +1 -1
- data/lib/brightbox-cli/config/accounts.rb +1 -1
- data/lib/brightbox-cli/config/api_client.rb +3 -3
- data/lib/brightbox-cli/config/authentication_tokens.rb +2 -2
- data/lib/brightbox-cli/config/cache.rb +1 -1
- data/lib/brightbox-cli/config/dirty.rb +1 -1
- data/lib/brightbox-cli/config/user_application.rb +3 -3
- data/lib/brightbox-cli/config.rb +2 -2
- data/lib/brightbox-cli/database_server.rb +2 -1
- data/lib/brightbox-cli/database_snapshot.rb +1 -0
- data/lib/brightbox-cli/detailed_server.rb +1 -0
- data/lib/brightbox-cli/gli_global_hooks.rb +2 -2
- data/lib/brightbox-cli/images.rb +2 -1
- data/lib/brightbox-cli/legacy/args_adjuster.rb +3 -3
- data/lib/brightbox-cli/load_balancers.rb +1 -0
- data/lib/brightbox-cli/servers.rb +2 -1
- data/lib/brightbox-cli/user_collaboration.rb +1 -1
- data/lib/brightbox-cli/version.rb +1 -1
- data/lib/brightbox_cli.rb +3 -3
- data/locales/en.yml +24 -0
- data/spec/commands/accounts/default_spec.rb +2 -2
- data/spec/commands/accounts/list_spec.rb +7 -7
- data/spec/commands/accounts/reset_ftp_password_spec.rb +2 -2
- data/spec/commands/accounts/show_spec.rb +2 -2
- data/spec/commands/cloudips/create_spec.rb +2 -2
- data/spec/commands/cloudips/destroy_spec.rb +2 -2
- data/spec/commands/cloudips/list_spec.rb +2 -2
- data/spec/commands/cloudips/map_spec.rb +3 -3
- data/spec/commands/cloudips/show_spec.rb +2 -2
- data/spec/commands/cloudips/unmap_spec.rb +2 -2
- data/spec/commands/cloudips/update_spec.rb +2 -2
- data/spec/commands/config/client_add_spec.rb +2 -2
- data/spec/commands/config/client_default_spec.rb +2 -2
- data/spec/commands/config/client_list_spec.rb +2 -2
- data/spec/commands/config/client_remove_spec.rb +2 -2
- data/spec/commands/config/user_add_spec.rb +3 -6
- data/spec/commands/firewall_policies/update_spec.rb +7 -7
- data/spec/commands/groups/add_server_spec.rb +2 -2
- data/spec/commands/groups/create_spec.rb +2 -2
- data/spec/commands/groups/destroy_spec.rb +2 -2
- data/spec/commands/groups/list_spec.rb +2 -2
- data/spec/commands/groups/move_servers_spec.rb +2 -2
- data/spec/commands/groups/remove_servers_spec.rb +2 -2
- data/spec/commands/groups/show_spec.rb +2 -2
- data/spec/commands/groups/update_spec.rb +2 -2
- data/spec/commands/images/destroy_spec.rb +2 -2
- data/spec/commands/images/list_spec.rb +2 -2
- data/spec/commands/images/locking_spec.rb +73 -0
- data/spec/commands/images/register_spec.rb +2 -2
- data/spec/commands/images/show_spec.rb +2 -2
- data/spec/commands/images/update_spec.rb +2 -2
- data/spec/commands/lbs/add_nodes_spec.rb +2 -2
- data/spec/commands/lbs/create_spec.rb +2 -2
- data/spec/commands/lbs/destroy_spec.rb +2 -2
- data/spec/commands/lbs/list_spec.rb +2 -2
- data/spec/commands/lbs/locking_spec.rb +73 -0
- data/spec/commands/lbs/remove_nodes_spec.rb +2 -2
- data/spec/commands/lbs/show_spec.rb +2 -2
- data/spec/commands/lbs/update_spec.rb +2 -2
- data/spec/commands/policies/apply_spec.rb +2 -2
- data/spec/commands/policies/create_spec.rb +2 -2
- data/spec/commands/policies/destroy_spec.rb +2 -2
- data/spec/commands/policies/list_spec.rb +2 -2
- data/spec/commands/policies/remove_spec.rb +2 -2
- data/spec/commands/policies/show_spec.rb +2 -2
- data/spec/commands/policies/update_spec.rb +2 -2
- data/spec/commands/rules/create_spec.rb +2 -2
- data/spec/commands/rules/destroy_spec.rb +2 -2
- data/spec/commands/rules/list_spec.rb +2 -2
- data/spec/commands/rules/show_spec.rb +2 -2
- data/spec/commands/rules/update_spec.rb +2 -2
- data/spec/commands/servers/activate_console_spec.rb +2 -2
- data/spec/commands/servers/create_spec.rb +2 -2
- data/spec/commands/servers/destroy_spec.rb +2 -2
- data/spec/commands/servers/list_spec.rb +2 -2
- data/spec/commands/servers/locking_spec.rb +73 -0
- data/spec/commands/servers/reboot_spec.rb +55 -0
- data/spec/commands/servers/reset_spec.rb +55 -0
- data/spec/commands/servers/show_spec.rb +2 -2
- data/spec/commands/servers/shutdown_spec.rb +2 -2
- data/spec/commands/servers/snapshot_spec.rb +2 -2
- data/spec/commands/servers/start_spec.rb +2 -2
- data/spec/commands/servers/stop_spec.rb +2 -2
- data/spec/commands/servers/update_spec.rb +2 -2
- data/spec/commands/sql/instances/create_spec.rb +4 -4
- data/spec/commands/sql/instances/locking_spec.rb +73 -0
- data/spec/commands/sql/instances/snapshot_spec.rb +2 -2
- data/spec/commands/sql/snapshots/list_spec.rb +1 -1
- data/spec/commands/sql/snapshots/locking_spec.rb +73 -0
- data/spec/commands/sql/snapshots/show_spec.rb +1 -1
- data/spec/commands/sql/types/list_spec.rb +1 -1
- data/spec/commands/types/list_spec.rb +2 -2
- data/spec/commands/users/list_spec.rb +2 -2
- data/spec/commands/users/show_spec.rb +2 -2
- data/spec/commands/users/update_spec.rb +2 -2
- data/spec/commands/zones/list_spec.rb +2 -2
- data/spec/spec_helper.rb +8 -9
- data/spec/support/common_helpers.rb +10 -10
- data/spec/support/config_helpers.rb +0 -1
- data/spec/support/faux_io.rb +10 -14
- data/spec/support/password_prompt_helpers.rb +1 -2
- data/spec/support/server_helper.rb +1 -1
- data/spec/support/shared/api_resource_examples.rb +8 -8
- data/spec/support/shared/collaborating_accounts_context.rb +2 -2
- data/spec/support/shared/config_section_types.rb +2 -2
- data/spec/support/tmp_config.rb +4 -8
- data/spec/support/token_helpers.rb +1 -1
- data/spec/support/vcr.rb +1 -1
- data/spec/unit/brightbox/account/get_spec.rb +1 -1
- data/spec/unit/brightbox/account_spec.rb +3 -3
- data/spec/unit/brightbox/api/find_spec.rb +6 -6
- data/spec/unit/brightbox/api/require_account_spec.rb +1 -1
- data/spec/unit/brightbox/bb_config/account_spec.rb +3 -3
- data/spec/unit/brightbox/bb_config/clear_default_client_spec.rb +8 -8
- data/spec/unit/brightbox/bb_config/client_has_alias_spec.rb +3 -3
- data/spec/unit/brightbox/bb_config/client_name_spec.rb +5 -5
- data/spec/unit/brightbox/bb_config/client_named_spec.rb +6 -6
- data/spec/unit/brightbox/bb_config/config_directory_exists_spec.rb +3 -3
- data/spec/unit/brightbox/bb_config/config_spec.rb +5 -5
- data/spec/unit/brightbox/bb_config/default_account_spec.rb +6 -6
- data/spec/unit/brightbox/bb_config/default_client_spec.rb +2 -2
- data/spec/unit/brightbox/bb_config/find_or_set_default_account_spec.rb +14 -14
- data/spec/unit/brightbox/bb_config/has_multiple_clients_spec.rb +2 -2
- data/spec/unit/brightbox/bb_config/renew_tokens_spec.rb +4 -5
- data/spec/unit/brightbox/bb_config/save_spec.rb +2 -2
- data/spec/unit/brightbox/bb_config/to_fog_spec.rb +2 -2
- data/spec/unit/brightbox/bb_config/using_client_spec.rb +10 -10
- data/spec/unit/brightbox/collaborating_account/resource_type_spec.rb +4 -4
- data/spec/unit/brightbox/collaborating_account_spec.rb +3 -3
- data/spec/unit/brightbox/config/api_client/to_fog_spec.rb +2 -2
- data/spec/unit/brightbox/config/api_client/valid_spec.rb +5 -5
- data/spec/unit/brightbox/config/section_name_deduplicator_spec.rb +1 -1
- data/spec/unit/brightbox/config/to_fog_spec.rb +3 -3
- data/spec/unit/brightbox/config/user_application/to_fog_spec.rb +2 -2
- data/spec/unit/brightbox/config/user_application/valid_spec.rb +6 -6
- data/spec/unit/brightbox/connection_manager/fetch_connection_spec.rb +17 -17
- data/spec/unit/brightbox/firewall_policy/apply_to_spec.rb +3 -3
- data/spec/unit/brightbox/firewall_policy/create_spec.rb +5 -5
- data/spec/unit/brightbox/firewall_policy/destroy_spec.rb +4 -4
- data/spec/unit/brightbox/firewall_policy/find_or_call_spec.rb +1 -1
- data/spec/unit/brightbox/firewall_policy/find_spec.rb +1 -1
- data/spec/unit/brightbox/firewall_rule/create_spec.rb +1 -1
- data/spec/unit/brightbox/firewall_rule/destroy_spec.rb +2 -2
- data/spec/unit/brightbox/firewall_rule/find_spec.rb +3 -3
- data/spec/unit/brightbox/firewall_rule/from_policy_spec.rb +2 -2
- data/spec/unit/brightbox/legacy/args_adjuster_spec.rb +12 -12
- data/spec/unit/brightbox/server/create_spec.rb +2 -2
- data/spec/unit/brightbox/server/destroy_spec.rb +3 -3
- data/spec/unit/brightbox/server/find_or_call_spec.rb +1 -1
- data/spec/unit/brightbox/server/shutdown_spec.rb +2 -4
- data/spec/unit/brightbox/server/start_spec.rb +4 -4
- data/spec/unit/brightbox/server/stop_spec.rb +2 -4
- data/spec/unit/brightbox/server/update_spec.rb +2 -2
- data/spec/unit/brightbox/server_group/find_spec.rb +1 -1
- data/spec/unit/brightbox/user_collaboration/get_for_account_spec.rb +4 -4
- data/spec/unit/brightbox/user_collaboration/remove_spec.rb +11 -11
- data/spec/unit/nilable_hash_spec.rb +6 -6
- data/spec/unit/tmp_config_spec.rb +1 -1
- metadata +67 -31
data/spec/spec_helper.rb
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
LIB_DIR = File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
|
|
2
2
|
|
|
3
|
-
$LOAD_PATH.unshift
|
|
4
|
-
$LOAD_PATH.include?(
|
|
5
|
-
$LOAD_PATH.include?(File.expand_path(__LIB_DIR__))
|
|
3
|
+
$LOAD_PATH.unshift LIB_DIR unless
|
|
4
|
+
$LOAD_PATH.include?(LIB_DIR) || $LOAD_PATH.include?(File.expand_path(LIB_DIR))
|
|
6
5
|
|
|
7
6
|
require "brightbox_cli"
|
|
8
7
|
require "support/common_helpers"
|
|
9
8
|
require "tmpdir"
|
|
10
9
|
|
|
11
|
-
Dir["./spec/support/**/*.rb"].sort.each {|f| require f}
|
|
10
|
+
Dir["./spec/support/**/*.rb"].sort.each { |f| require f }
|
|
12
11
|
|
|
13
|
-
#API_CLIENT_CONFIG_DIR = File.join(File.dirname(__FILE__), "configs/api_client")
|
|
14
|
-
#USER_APP_CONFIG_DIR = File.join(File.dirname(__FILE__), "configs/user_application")
|
|
12
|
+
# API_CLIENT_CONFIG_DIR = File.join(File.dirname(__FILE__), "configs/api_client")
|
|
13
|
+
# USER_APP_CONFIG_DIR = File.join(File.dirname(__FILE__), "configs/user_application")
|
|
15
14
|
|
|
16
|
-
#API_CLIENT_CONFIG = Brightbox::BBConfig.new(:directory => API_CLIENT_CONFIG_DIR)
|
|
17
|
-
#USER_APP_CONFIG = Brightbox::BBConfig.new(:directory => USER_APP_CONFIG_DIR)
|
|
15
|
+
# API_CLIENT_CONFIG = Brightbox::BBConfig.new(:directory => API_CLIENT_CONFIG_DIR)
|
|
16
|
+
# USER_APP_CONFIG = Brightbox::BBConfig.new(:directory => USER_APP_CONFIG_DIR)
|
|
18
17
|
|
|
19
18
|
# These are the contents
|
|
20
19
|
API_CLIENT_CONFIG_CONTENTS = File.read(File.join(File.dirname(__FILE__), "configs/api_client.ini"))
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
module CommonHelpers
|
|
2
2
|
def limit_exceeded_exception(request = {})
|
|
3
3
|
request_options = {
|
|
4
|
-
:headers=> {
|
|
5
|
-
"Content-Type"=>"application/json", "Authorization"=>"OAuth 864b21f13485a7f2de49593f627213075e8eb046",
|
|
6
|
-
"Host"=>"api.gb1.brightbox.com:443", "Content-Length"=>71
|
|
4
|
+
:headers => {
|
|
5
|
+
"Content-Type" => "application/json", "Authorization" => "OAuth 864b21f13485a7f2de49593f627213075e8eb046",
|
|
6
|
+
"Host" => "api.gb1.brightbox.com:443", "Content-Length" => 71
|
|
7
7
|
},
|
|
8
|
-
:host=>"api.gb1.brightbox.com", :mock=>false, :path=>"/1.0/servers",
|
|
9
|
-
:port=>"443", :query=>nil, :scheme=>"https",
|
|
10
|
-
:expects=>[202],
|
|
11
|
-
:method=>"POST",
|
|
12
|
-
:body=>"{\"image\":\"img-4gqhs\",\"server_type\":\"typ-qdiwq\",\"name\":\"medium servers\"}"
|
|
8
|
+
:host => "api.gb1.brightbox.com", :mock => false, :path => "/1.0/servers",
|
|
9
|
+
:port => "443", :query => nil, :scheme => "https",
|
|
10
|
+
:expects => [202],
|
|
11
|
+
:method => "POST",
|
|
12
|
+
:body => "{\"image\":\"img-4gqhs\",\"server_type\":\"typ-qdiwq\",\"name\":\"medium servers\"}"
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
response = Excon::Response.new(
|
|
16
16
|
:body => "{\"error_name\":\"account_limit_reached\",\"errors\":[\"Account limit reached, please contact support for more information\"]}",
|
|
17
17
|
:status => 403,
|
|
18
18
|
:headers => {
|
|
19
|
-
"Date"=>"Tue, 28 Jun 2011 08:07:21 GMT", "Server"=>"Apache", "Cache-Control"=>"no-cache", "Access-Control-Allow-Origin"=>"*", "Access-Control-Allow-Headers"=>"Authorization", "Content-Length"=>"118", "Status"=>"403", "Content-Type"=>"application/json; charset=utf-8"
|
|
19
|
+
"Date" => "Tue, 28 Jun 2011 08:07:21 GMT", "Server" => "Apache", "Cache-Control" => "no-cache", "Access-Control-Allow-Origin" => "*", "Access-Control-Allow-Headers" => "Authorization", "Content-Length" => "118", "Status" => "403", "Content-Type" => "application/json; charset=utf-8"
|
|
20
20
|
}
|
|
21
21
|
)
|
|
22
22
|
|
|
23
|
-
Excon::Errors.status_error(request_options.merge(request),response)
|
|
23
|
+
Excon::Errors.status_error(request_options.merge(request), response)
|
|
24
24
|
end
|
|
25
25
|
end
|
data/spec/support/faux_io.rb
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
# This class encapsulates the pattern of faking STD IO and exposing the streams
|
|
2
2
|
# for testing.
|
|
3
3
|
class FauxIO
|
|
4
|
-
def initialize(&
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
ensure
|
|
15
|
-
$stdout = original_stdout
|
|
16
|
-
$stderr = original_stderr
|
|
17
|
-
end
|
|
4
|
+
def initialize(&_block)
|
|
5
|
+
original_stdout = $stdout
|
|
6
|
+
original_stderr = $stderr
|
|
7
|
+
$stdout = @stdout = StringIO.new
|
|
8
|
+
$stderr = @stderr = StringIO.new
|
|
9
|
+
yield
|
|
10
|
+
rescue SystemExit
|
|
11
|
+
ensure
|
|
12
|
+
$stdout = original_stdout
|
|
13
|
+
$stderr = original_stderr
|
|
18
14
|
end
|
|
19
15
|
|
|
20
16
|
def stdout
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
require "highline"
|
|
2
2
|
|
|
3
3
|
module PasswordPromptHelpers
|
|
4
|
-
|
|
5
4
|
# This password matches the testing users available on dev machines
|
|
6
5
|
def default_test_password
|
|
7
6
|
"N:B3e%7Cmh"
|
|
@@ -11,6 +10,6 @@ module PasswordPromptHelpers
|
|
|
11
10
|
# or a specific value. Otherwise this blocks the specs.
|
|
12
11
|
#
|
|
13
12
|
def mock_password_entry(password = default_test_password)
|
|
14
|
-
HighLine.
|
|
13
|
+
expect_any_instance_of(HighLine).to receive(:ask).at_least(:once).and_return(password)
|
|
15
14
|
end
|
|
16
15
|
end
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
shared_examples "a wrapped API resource" do
|
|
2
|
-
it { described_class.
|
|
3
|
-
it { described_class.
|
|
4
|
-
it { described_class.
|
|
5
|
-
it { described_class.
|
|
2
|
+
it { expect(described_class).to respond_to(:require_account?) }
|
|
3
|
+
it { expect(described_class).to respond_to(:klass_name) }
|
|
4
|
+
it { expect(described_class).to respond_to(:get) }
|
|
5
|
+
it { expect(described_class).to respond_to(:find) }
|
|
6
6
|
|
|
7
|
-
it {
|
|
8
|
-
it {
|
|
9
|
-
it {
|
|
7
|
+
it { is_expected.to respond_to(:fog_model) }
|
|
8
|
+
it { is_expected.to respond_to(:exists?) }
|
|
9
|
+
it { is_expected.to respond_to(:to_row) }
|
|
10
10
|
|
|
11
|
-
it {
|
|
11
|
+
it { is_expected.to respond_to(:to_s) }
|
|
12
12
|
it "#to_s equals the #id" do
|
|
13
13
|
expect(subject.to_s).to eql(subject.id)
|
|
14
14
|
end
|
|
@@ -9,10 +9,10 @@ shared_context "collaborating accounts" do
|
|
|
9
9
|
data = {
|
|
10
10
|
"id" => "acc-12345",
|
|
11
11
|
"resource_type" => "account",
|
|
12
|
-
"url"=>"https://api.gb1.brightbox.com/1.0/accounts/acc-12345",
|
|
12
|
+
"url" => "https://api.gb1.brightbox.com/1.0/accounts/acc-12345",
|
|
13
13
|
"name" => "Owned account name",
|
|
14
14
|
"status" => "active",
|
|
15
|
-
"ram_limit" =>
|
|
15
|
+
"ram_limit" => 3_200_000,
|
|
16
16
|
"ram_used" => 3072,
|
|
17
17
|
"cloud_ips_limit" => 32,
|
|
18
18
|
"cloud_ips_used" => 0,
|
data/spec/support/tmp_config.rb
CHANGED
|
@@ -6,7 +6,7 @@ require "fileutils"
|
|
|
6
6
|
# dispose of
|
|
7
7
|
#
|
|
8
8
|
class TmpConfig
|
|
9
|
-
|
|
9
|
+
attr_reader :path
|
|
10
10
|
# Creates a temporary directory and a "config" file within using the contents
|
|
11
11
|
# of a passed String.
|
|
12
12
|
#
|
|
@@ -15,18 +15,14 @@ class TmpConfig
|
|
|
15
15
|
# @param [String] contents
|
|
16
16
|
#
|
|
17
17
|
def initialize(contents)
|
|
18
|
-
@
|
|
19
|
-
@file = File.open(File.join(@
|
|
18
|
+
@path = Dir.mktmpdir
|
|
19
|
+
@file = File.open(File.join(@path, "config"), "w+")
|
|
20
20
|
@file.write(contents)
|
|
21
21
|
@file.close
|
|
22
22
|
self
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
def path
|
|
26
|
-
@dir
|
|
27
|
-
end
|
|
28
|
-
|
|
29
25
|
def close
|
|
30
|
-
FileUtils.remove_entry_secure(
|
|
26
|
+
FileUtils.remove_entry_secure(path)
|
|
31
27
|
end
|
|
32
28
|
end
|
|
@@ -8,7 +8,7 @@ module TokenHelpers
|
|
|
8
8
|
|
|
9
9
|
# Creates a cached refresh token for the config directly to disk
|
|
10
10
|
def cache_refresh_token(config, token)
|
|
11
|
-
File.open(config.refresh_token_filename, "w") {|f| f.write token }
|
|
11
|
+
File.open(config.refresh_token_filename, "w") { |f| f.write token }
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
# Returns the cached access token for the config directly from disk
|
data/spec/support/vcr.rb
CHANGED
|
@@ -7,7 +7,7 @@ describe Brightbox::Account do
|
|
|
7
7
|
|
|
8
8
|
it_behaves_like "a wrapped API resource"
|
|
9
9
|
|
|
10
|
-
it {
|
|
11
|
-
it {
|
|
12
|
-
it {
|
|
10
|
+
it { is_expected.to respond_to(:ram_free) }
|
|
11
|
+
it { is_expected.to respond_to(:cloud_ip_limit) }
|
|
12
|
+
it { is_expected.to respond_to(:lb_limit) }
|
|
13
13
|
end
|
|
@@ -4,17 +4,17 @@ describe Brightbox::Api, ".find" do
|
|
|
4
4
|
|
|
5
5
|
context "when passed nil" do
|
|
6
6
|
it "raises an error" do
|
|
7
|
-
expect
|
|
7
|
+
expect do
|
|
8
8
|
Brightbox::Api.find(nil)
|
|
9
|
-
|
|
9
|
+
end.to raise_error(Brightbox::Api::InvalidArguments)
|
|
10
10
|
end
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
context "when passed an empty object" do
|
|
14
14
|
it "raises an error" do
|
|
15
|
-
expect
|
|
15
|
+
expect do
|
|
16
16
|
Brightbox::Api.find([])
|
|
17
|
-
|
|
17
|
+
end.to raise_error(Brightbox::Api::InvalidArguments)
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
@@ -55,9 +55,9 @@ describe Brightbox::Api, ".find" do
|
|
|
55
55
|
|
|
56
56
|
context "when passed a bad search value" do
|
|
57
57
|
it "raises an error" do
|
|
58
|
-
expect
|
|
58
|
+
expect do
|
|
59
59
|
Brightbox::Api.find(double)
|
|
60
|
-
|
|
60
|
+
end.to raise_error(Brightbox::Api::InvalidArguments)
|
|
61
61
|
end
|
|
62
62
|
end
|
|
63
63
|
end
|
|
@@ -34,7 +34,7 @@ describe Brightbox::BBConfig do
|
|
|
34
34
|
before do
|
|
35
35
|
@account_name = "acc-ghj32"
|
|
36
36
|
@client_name = "app-b3n5b"
|
|
37
|
-
contents
|
|
37
|
+
contents = <<-EOS
|
|
38
38
|
[#{@client_name}]
|
|
39
39
|
default_account = #{@account_name}
|
|
40
40
|
EOS
|
|
@@ -49,9 +49,9 @@ describe Brightbox::BBConfig do
|
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
it "does not dirty the config" do
|
|
52
|
-
expect
|
|
52
|
+
expect do
|
|
53
53
|
@config.account
|
|
54
|
-
|
|
54
|
+
end.to_not change(@config, :dirty?)
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
57
|
end
|
|
@@ -19,16 +19,16 @@ describe Brightbox::BBConfig do
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
it "does alters the value" do
|
|
22
|
-
expect
|
|
22
|
+
expect do
|
|
23
23
|
@config.clear_default_client
|
|
24
|
-
|
|
24
|
+
end.to change(@config, :default_client)
|
|
25
25
|
expect(@config.default_client).to be_nil
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
it "dirties the config" do
|
|
29
|
-
expect
|
|
29
|
+
expect do
|
|
30
30
|
@config.clear_default_client
|
|
31
|
-
|
|
31
|
+
end.to change(@config, :dirty?)
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
|
|
@@ -39,15 +39,15 @@ describe Brightbox::BBConfig do
|
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
it "does not alter the value" do
|
|
42
|
-
expect
|
|
42
|
+
expect do
|
|
43
43
|
@config.clear_default_client
|
|
44
|
-
|
|
44
|
+
end.to_not change(@config, :default_client)
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
it "does not dirty the config" do
|
|
48
|
-
expect
|
|
48
|
+
expect do
|
|
49
49
|
@config.clear_default_client
|
|
50
|
-
|
|
50
|
+
end.to_not change(@config, :dirty?)
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
end
|
|
@@ -20,21 +20,21 @@ describe Brightbox::BBConfig do
|
|
|
20
20
|
context "when client has old 'alias' key" do
|
|
21
21
|
it "returns true" do
|
|
22
22
|
config.client_name = "old_alias"
|
|
23
|
-
expect(config.client_has_alias?).to
|
|
23
|
+
expect(config.client_has_alias?).to be true
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
context "when client has a section header" do
|
|
28
28
|
it "returns true" do
|
|
29
29
|
config.client_name = "alias"
|
|
30
|
-
expect(config.client_has_alias?).to
|
|
30
|
+
expect(config.client_has_alias?).to be true
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
context "when client 'alias' is the identifier" do
|
|
35
35
|
it "returns false" do
|
|
36
36
|
config.client_name = "cli-12345"
|
|
37
|
-
expect(config.client_has_alias?).to
|
|
37
|
+
expect(config.client_has_alias?).to be false
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
end
|
|
@@ -17,7 +17,7 @@ describe Brightbox::BBConfig do
|
|
|
17
17
|
context "when config file contains a default client" do
|
|
18
18
|
before do
|
|
19
19
|
@client_name = "app-b3n5b"
|
|
20
|
-
contents
|
|
20
|
+
contents = <<-EOS
|
|
21
21
|
[core]
|
|
22
22
|
default_client = #{@client_name}
|
|
23
23
|
EOS
|
|
@@ -32,7 +32,7 @@ describe Brightbox::BBConfig do
|
|
|
32
32
|
context "when config file contains only one client" do
|
|
33
33
|
before do
|
|
34
34
|
@client_name = "cli-sdio2"
|
|
35
|
-
contents
|
|
35
|
+
contents = <<-EOS
|
|
36
36
|
[core]
|
|
37
37
|
default_client = #{@client_name}
|
|
38
38
|
|
|
@@ -49,7 +49,7 @@ describe Brightbox::BBConfig do
|
|
|
49
49
|
|
|
50
50
|
context "when config contains no default and multiple clients" do
|
|
51
51
|
before do
|
|
52
|
-
contents
|
|
52
|
+
contents = <<-EOS
|
|
53
53
|
[app-first]
|
|
54
54
|
client_id = app-first
|
|
55
55
|
|
|
@@ -73,9 +73,9 @@ describe Brightbox::BBConfig do
|
|
|
73
73
|
end
|
|
74
74
|
|
|
75
75
|
it "raises an error" do
|
|
76
|
-
expect
|
|
76
|
+
expect do
|
|
77
77
|
@config.client_name
|
|
78
|
-
|
|
78
|
+
end.to raise_error(Brightbox::BBConfigError, "You must specify a default client using brightbox config client_default")
|
|
79
79
|
end
|
|
80
80
|
end
|
|
81
81
|
|
|
@@ -20,37 +20,37 @@ describe Brightbox::BBConfig do
|
|
|
20
20
|
describe "#client_named?" do
|
|
21
21
|
context "when no client with that name" do
|
|
22
22
|
it "returns false" do
|
|
23
|
-
expect(config.client_named?("missing")).to
|
|
23
|
+
expect(config.client_named?("missing")).to be false
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
context "when client with that ID exists" do
|
|
28
28
|
it "returns false" do
|
|
29
|
-
expect(config.client_named?("cli-12345")).to
|
|
29
|
+
expect(config.client_named?("cli-12345")).to be false
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
context "when client with that alias exists" do
|
|
34
34
|
it "returns true" do
|
|
35
|
-
expect(config.client_named?("test")).to
|
|
35
|
+
expect(config.client_named?("test")).to be true
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
context "when client with that alias exists" do
|
|
40
40
|
it "returns true" do
|
|
41
|
-
expect(config.client_named?("dev")).to
|
|
41
|
+
expect(config.client_named?("dev")).to be true
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
context "when client a section header exists" do
|
|
46
46
|
it "returns true" do
|
|
47
|
-
expect(config.client_named?("jason.null@brightbox.com")).to
|
|
47
|
+
expect(config.client_named?("jason.null@brightbox.com")).to be true
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
context "when client is named 'core'" do
|
|
52
52
|
it "returns false" do
|
|
53
|
-
expect(config.client_named?("core")).to
|
|
53
|
+
expect(config.client_named?("core")).to be false
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
56
|
end
|
|
@@ -10,7 +10,7 @@ describe Brightbox::BBConfig do
|
|
|
10
10
|
it "returns true" do
|
|
11
11
|
Dir.mktmpdir do |dir|
|
|
12
12
|
@dir = dir
|
|
13
|
-
expect(config.config_directory_exists?).to
|
|
13
|
+
expect(config.config_directory_exists?).to be true
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
end
|
|
@@ -19,7 +19,7 @@ describe Brightbox::BBConfig do
|
|
|
19
19
|
it "returns false" do
|
|
20
20
|
Tempfile.open("config_clash") do |tmp_file|
|
|
21
21
|
@dir = tmp_file.path
|
|
22
|
-
expect(config.config_directory_exists?).to
|
|
22
|
+
expect(config.config_directory_exists?).to be false
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
end
|
|
@@ -27,7 +27,7 @@ describe Brightbox::BBConfig do
|
|
|
27
27
|
context "when directory does not exist" do
|
|
28
28
|
it "returns false" do
|
|
29
29
|
@dir = "fnord"
|
|
30
|
-
expect(config.config_directory_exists?).to
|
|
30
|
+
expect(config.config_directory_exists?).to be false
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
end
|
|
@@ -10,7 +10,7 @@ describe Brightbox::BBConfig do
|
|
|
10
10
|
Dir.mktmpdir do |tmp_dir|
|
|
11
11
|
target_dir = File.join(tmp_dir, "config")
|
|
12
12
|
@config = Brightbox::BBConfig.new :directory => target_dir
|
|
13
|
-
expect(@config.config_directory_exists?).to
|
|
13
|
+
expect(@config.config_directory_exists?).to be false
|
|
14
14
|
example.run
|
|
15
15
|
end
|
|
16
16
|
end
|
|
@@ -21,7 +21,7 @@ describe Brightbox::BBConfig do
|
|
|
21
21
|
|
|
22
22
|
it "creates the config directory" do
|
|
23
23
|
expect { @config.config }.to_not raise_error
|
|
24
|
-
expect(@config.config_directory_exists?).to
|
|
24
|
+
expect(@config.config_directory_exists?).to be true
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
|
|
@@ -49,9 +49,9 @@ describe Brightbox::BBConfig do
|
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
-
# FIXME This appears to be current behaviour, at least under testing which
|
|
53
|
-
#
|
|
54
|
-
#
|
|
52
|
+
# FIXME: This appears to be current behaviour, at least under testing which
|
|
53
|
+
# seems a bit off. Might be an issue with the setup because I did have
|
|
54
|
+
# failures initially.
|
|
55
55
|
context "when config dir exists as a file" do
|
|
56
56
|
it "does not raise an error" do
|
|
57
57
|
Tempfile.open("tmp") do |target_dir|
|
|
@@ -9,15 +9,15 @@ describe Brightbox::BBConfig do
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
it "does not raise an error" do
|
|
12
|
-
expect
|
|
12
|
+
expect do
|
|
13
13
|
Brightbox::BBConfig.new.default_account
|
|
14
|
-
|
|
14
|
+
end.to_not raise_error
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
context "when not available in config" do
|
|
19
19
|
before do
|
|
20
|
-
contents
|
|
20
|
+
contents = <<-EOS
|
|
21
21
|
[app-12345]
|
|
22
22
|
EOS
|
|
23
23
|
@config = config_from_contents(contents)
|
|
@@ -30,9 +30,9 @@ describe Brightbox::BBConfig do
|
|
|
30
30
|
|
|
31
31
|
context "when blank in config" do
|
|
32
32
|
before do
|
|
33
|
-
contents
|
|
33
|
+
contents = <<-EOS
|
|
34
34
|
[app-12345]
|
|
35
|
-
default_account =
|
|
35
|
+
default_account =
|
|
36
36
|
EOS
|
|
37
37
|
@config = config_from_contents(contents)
|
|
38
38
|
end
|
|
@@ -46,7 +46,7 @@ describe Brightbox::BBConfig do
|
|
|
46
46
|
before do
|
|
47
47
|
@account_name = "acc-ghj32"
|
|
48
48
|
@client_name = "app-b3n5b"
|
|
49
|
-
contents
|
|
49
|
+
contents = <<-EOS
|
|
50
50
|
[#{@client_name}]
|
|
51
51
|
default_account = #{@account_name}
|
|
52
52
|
EOS
|
|
@@ -16,7 +16,7 @@ describe Brightbox::BBConfig do
|
|
|
16
16
|
|
|
17
17
|
context "when config file has no default" do
|
|
18
18
|
before do
|
|
19
|
-
contents
|
|
19
|
+
contents = <<-EOS
|
|
20
20
|
[core]
|
|
21
21
|
EOS
|
|
22
22
|
@tmp_config = config_from_contents(contents)
|
|
@@ -31,7 +31,7 @@ describe Brightbox::BBConfig do
|
|
|
31
31
|
context "when config file contains a default client" do
|
|
32
32
|
before do
|
|
33
33
|
@client_name = "app-b3n5b"
|
|
34
|
-
contents
|
|
34
|
+
contents = <<-EOS
|
|
35
35
|
[core]
|
|
36
36
|
default_client = #{@client_name}
|
|
37
37
|
EOS
|
|
@@ -10,9 +10,9 @@ describe Brightbox::BBConfig do
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
it "does not raise an error" do
|
|
13
|
-
expect
|
|
13
|
+
expect do
|
|
14
14
|
Brightbox::BBConfig.new.find_or_set_default_account
|
|
15
|
-
|
|
15
|
+
end.to_not raise_error
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
|
|
@@ -28,9 +28,9 @@ describe Brightbox::BBConfig do
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
it "does not update" do
|
|
31
|
-
expect
|
|
31
|
+
expect do
|
|
32
32
|
config.find_or_set_default_account
|
|
33
|
-
|
|
33
|
+
end.to_not change(config, :default_account)
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
|
|
@@ -45,16 +45,16 @@ describe Brightbox::BBConfig do
|
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
it "does not raise an error" do
|
|
48
|
-
expect
|
|
48
|
+
expect do
|
|
49
49
|
config.find_or_set_default_account
|
|
50
|
-
|
|
50
|
+
end.to_not raise_error
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
it "does not update " do
|
|
54
|
-
|
|
55
|
-
expect
|
|
54
|
+
skip
|
|
55
|
+
expect do
|
|
56
56
|
config.find_or_set_default_account
|
|
57
|
-
|
|
57
|
+
end.to_not change(config, :default_account)
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
60
|
|
|
@@ -69,9 +69,9 @@ describe Brightbox::BBConfig do
|
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
it "updates the setting" do
|
|
72
|
-
expect
|
|
72
|
+
expect do
|
|
73
73
|
config.find_or_set_default_account
|
|
74
|
-
|
|
74
|
+
end.to change(config, :default_account)
|
|
75
75
|
end
|
|
76
76
|
end
|
|
77
77
|
|
|
@@ -86,10 +86,10 @@ describe Brightbox::BBConfig do
|
|
|
86
86
|
end
|
|
87
87
|
|
|
88
88
|
it "does not update" do
|
|
89
|
-
|
|
90
|
-
expect
|
|
89
|
+
skip
|
|
90
|
+
expect do
|
|
91
91
|
config.find_or_set_default_account
|
|
92
|
-
|
|
92
|
+
end.to_not change(config, :default_account)
|
|
93
93
|
end
|
|
94
94
|
end
|
|
95
95
|
end
|