morpheus-cli 5.5.2.2 → 5.5.3.1
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/.gitignore +2 -1
- data/Dockerfile +1 -1
- data/README.md +57 -4
- data/Rakefile +9 -0
- data/bin/morpheus +4 -4
- data/lib/morpheus/api/api_client.rb +20 -2
- data/lib/morpheus/api/appliance_settings_interface.rb +15 -0
- data/lib/morpheus/api/archive_buckets_interface.rb +1 -1
- data/lib/morpheus/api/archive_files_interface.rb +3 -3
- data/lib/morpheus/api/clients_interface.rb +2 -2
- data/lib/morpheus/api/clusters_interface.rb +8 -1
- data/lib/morpheus/api/containers_interface.rb +29 -16
- data/lib/morpheus/api/custom_instance_types_interface.rb +0 -2
- data/lib/morpheus/api/cypher_interface.rb +1 -2
- data/lib/morpheus/api/doc_interface.rb +8 -6
- data/lib/morpheus/api/file_copy_request_interface.rb +1 -1
- data/lib/morpheus/api/guidance_settings_interface.rb +17 -0
- data/lib/morpheus/api/health_interface.rb +1 -1
- data/lib/morpheus/api/image_builder_interface.rb +3 -3
- data/lib/morpheus/api/instances_interface.rb +25 -0
- data/lib/morpheus/api/logs_interface.rb +2 -4
- data/lib/morpheus/api/monitoring_interface.rb +6 -6
- data/lib/morpheus/api/monitoring_settings_interface.rb +25 -0
- data/lib/morpheus/api/network_server_groups_interface.rb +7 -0
- data/lib/morpheus/api/packages_interface.rb +1 -1
- data/lib/morpheus/api/reports_interface.rb +1 -1
- data/lib/morpheus/api/servers_interface.rb +9 -1
- data/lib/morpheus/api/storage_providers_interface.rb +2 -2
- data/lib/morpheus/api/virtual_images_interface.rb +1 -1
- data/lib/morpheus/api.rb +2 -0
- data/lib/morpheus/benchmarking.rb +1 -1
- data/lib/morpheus/cli/cli_command.rb +79 -37
- data/lib/morpheus/cli/cli_registry.rb +19 -10
- data/lib/morpheus/cli/commands/access_token_command.rb +1 -1
- data/lib/morpheus/cli/commands/appliance_settings_command.rb +57 -2
- data/lib/morpheus/cli/commands/apps.rb +1 -1
- data/lib/morpheus/cli/commands/archives_command.rb +25 -33
- data/lib/morpheus/cli/commands/backup_settings_command.rb +1 -1
- data/lib/morpheus/cli/commands/blueprints_command.rb +10 -21
- data/lib/morpheus/cli/commands/boot_scripts_command.rb +2 -2
- data/lib/morpheus/cli/commands/cat_command.rb +1 -1
- data/lib/morpheus/cli/commands/catalog_item_types_command.rb +18 -13
- data/lib/morpheus/cli/commands/clouds.rb +3 -3
- data/lib/morpheus/cli/commands/clusters.rb +154 -3
- data/lib/morpheus/cli/commands/containers_command.rb +398 -253
- data/lib/morpheus/cli/commands/cypher_command.rb +3 -0
- data/lib/morpheus/cli/commands/deployments.rb +1 -1
- data/lib/morpheus/cli/commands/deploys.rb +9 -9
- data/lib/morpheus/cli/commands/doc.rb +15 -16
- data/lib/morpheus/cli/commands/execution_request_command.rb +2 -2
- data/lib/morpheus/cli/commands/file_copy_request_command.rb +5 -5
- data/lib/morpheus/cli/commands/groups.rb +2 -2
- data/lib/morpheus/cli/commands/guidance_command.rb +2 -2
- data/lib/morpheus/cli/commands/guidance_settings.rb +148 -0
- data/lib/morpheus/cli/commands/health_command.rb +4 -4
- data/lib/morpheus/cli/commands/hosts.rb +43 -5
- data/lib/morpheus/cli/commands/image_builder_command.rb +1 -1
- data/lib/morpheus/cli/commands/instances.rb +419 -148
- data/lib/morpheus/cli/commands/integrations_command.rb +22 -20
- data/lib/morpheus/cli/commands/key_pairs.rb +2 -2
- data/lib/morpheus/cli/commands/library_container_scripts_command.rb +2 -2
- data/lib/morpheus/cli/commands/library_container_templates_command.rb +2 -2
- data/lib/morpheus/cli/commands/library_instance_types_command.rb +3 -3
- data/lib/morpheus/cli/commands/library_spec_templates_command.rb +2 -2
- data/lib/morpheus/cli/commands/log_settings_command.rb +1 -1
- data/lib/morpheus/cli/commands/login.rb +1 -1
- data/lib/morpheus/cli/commands/man_command.rb +32 -18
- data/lib/morpheus/cli/commands/monitoring_settings.rb +228 -0
- data/lib/morpheus/cli/commands/network_server_groups_command.rb +222 -0
- data/lib/morpheus/cli/commands/packages_command.rb +11 -11
- data/lib/morpheus/cli/commands/plugins.rb +1 -1
- data/lib/morpheus/cli/commands/policies_command.rb +4 -4
- data/lib/morpheus/cli/commands/preseed_scripts_command.rb +2 -2
- data/lib/morpheus/cli/commands/provisioning_settings_command.rb +1 -1
- data/lib/morpheus/cli/commands/remote.rb +1 -1
- data/lib/morpheus/cli/commands/reports_command.rb +13 -3
- data/lib/morpheus/cli/commands/security_groups.rb +1 -1
- data/lib/morpheus/cli/commands/shell.rb +40 -62
- data/lib/morpheus/cli/commands/snapshots.rb +3 -5
- data/lib/morpheus/cli/commands/source_command.rb +8 -16
- data/lib/morpheus/cli/commands/storage_providers_command.rb +7 -7
- data/lib/morpheus/cli/commands/tasks.rb +2 -2
- data/lib/morpheus/cli/commands/vdi_pools_command.rb +6 -6
- data/lib/morpheus/cli/commands/view.rb +5 -1
- data/lib/morpheus/cli/commands/whitelabel_settings_command.rb +5 -5
- data/lib/morpheus/cli/commands/whoami.rb +2 -2
- data/lib/morpheus/cli/credentials.rb +30 -8
- data/lib/morpheus/cli/dot_file.rb +8 -15
- data/lib/morpheus/cli/error_handler.rb +16 -0
- data/lib/morpheus/cli/errors.rb +8 -1
- data/lib/morpheus/cli/mixins/print_helper.rb +17 -13
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +14 -12
- data/lib/morpheus/cli/mixins/rest_command.rb +23 -19
- data/lib/morpheus/cli/mixins/secondary_rest_command.rb +47 -24
- data/lib/morpheus/cli/option_parser.rb +5 -1
- data/lib/morpheus/cli/option_types.rb +59 -12
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli.rb +26 -16
- data/lib/morpheus/ext/rest_client.rb +3 -2
- data/lib/morpheus/ext/string.rb +6 -4
- data/lib/morpheus/formatters.rb +1 -1
- data/lib/morpheus/logging.rb +4 -4
- data/lib/morpheus/morpkg.rb +4 -4
- data/lib/morpheus/rest_client.rb +2 -2
- data/lib/morpheus/routes.rb +41 -9
- data/lib/morpheus/terminal.rb +65 -16
- data/lib/morpheus.rb +1 -1
- data/morpheus-cli.gemspec +1 -0
- data/test/api/containers_interface_test.rb +68 -0
- data/test/api/doc_interface_test.rb +35 -0
- data/test/api/instances_interface_test.rb +22 -0
- data/test/api/whoami_interface_test.rb +14 -0
- data/test/cli/access_token_test.rb +36 -0
- data/test/cli/auth_test.rb +82 -0
- data/test/cli/cli_test.rb +48 -0
- data/test/cli/containers_test.rb +92 -0
- data/test/cli/doc_test.rb +35 -0
- data/test/cli/help_test.rb +25 -0
- data/test/cli/instances_test.rb +36 -0
- data/test/cli/man_test.rb +14 -0
- data/test/cli/remote_test.rb +89 -0
- data/test/cli/roles_test.rb +34 -0
- data/test/cli/shell_test.rb +81 -0
- data/test/cli/version_test.rb +23 -0
- data/test/cli/view_test.rb +55 -0
- data/test/cli/whoami_test.rb +17 -0
- data/test/morpheus_test.rb +16 -0
- data/test/test_case.rb +338 -0
- data/test/test_config.rb +137 -0
- data/test/test_data_helper.rb +97 -0
- metadata +67 -3
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
require 'morpheus_test'
|
|
2
|
+
|
|
3
|
+
# Tests for Morpheus::ContainersInterface
|
|
4
|
+
class MorpheusTest::ContainersInterfaceTest < MorpheusTest::TestCase
|
|
5
|
+
|
|
6
|
+
include MorpheusTest::TestDataHelper
|
|
7
|
+
|
|
8
|
+
def setup()
|
|
9
|
+
super
|
|
10
|
+
#load_container_test_data()
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_get
|
|
14
|
+
container_id = find_first_container_id()
|
|
15
|
+
response = client.containers.get(container_id)
|
|
16
|
+
assert response['container'].is_a?(Hash)
|
|
17
|
+
assert_equal response['container']['id'], container_id
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# todo: need to wait and refresh status for this to work well
|
|
21
|
+
|
|
22
|
+
=begin
|
|
23
|
+
def test_stop
|
|
24
|
+
response = client.containers.stop(@id, {})
|
|
25
|
+
assert_equal response['success'], true
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def test_start
|
|
29
|
+
response = client.containers.start(@id, {})
|
|
30
|
+
assert_equal response['success'], true
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_restart
|
|
34
|
+
response = client.containers.restart(@id, {})
|
|
35
|
+
assert_equal response['success'], true
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_suspend
|
|
39
|
+
response = client.containers.suspend(@id, {})
|
|
40
|
+
assert_equal response['success'], true
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_eject
|
|
44
|
+
response = client.containers.eject(@id, {})
|
|
45
|
+
assert_equal response['success'], true
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_available_actions
|
|
49
|
+
response = client.containers.available_actions(@id)
|
|
50
|
+
assert response['actions'].is_a?(Array)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_action
|
|
54
|
+
response = client.containers.action(@id, {})
|
|
55
|
+
assert_equal response['success'], true
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def test_import
|
|
59
|
+
response = client.containers.import(@id, {})
|
|
60
|
+
assert_equal response['success'], true
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def test_clone_image
|
|
64
|
+
response = client.containers.clone_image(@id, {})
|
|
65
|
+
assert_equal response['success'], true
|
|
66
|
+
end
|
|
67
|
+
=end
|
|
68
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require 'morpheus_test'
|
|
2
|
+
|
|
3
|
+
# Tests for Morpheus::DocInterface
|
|
4
|
+
class MorpheusTest::DocInterfaceTest < MorpheusTest::TestCase
|
|
5
|
+
|
|
6
|
+
def test_doc_list
|
|
7
|
+
@doc_interface = client.doc
|
|
8
|
+
response = @doc_interface.list()
|
|
9
|
+
assert_equal response['links'].class, Array
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_doc_get
|
|
13
|
+
@doc_interface = client.doc
|
|
14
|
+
response = @doc_interface.openapi()
|
|
15
|
+
assert_equal response['openapi'], '3.0.3'
|
|
16
|
+
# todo: fix this, can be cached and fail
|
|
17
|
+
#assert_equal response['version'], Morpheus::Cli::Remote.load_remote(@config.remote_name)[:build_version]
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_doc_get_yaml
|
|
21
|
+
@doc_interface = client.doc
|
|
22
|
+
response = @doc_interface.openapi({'format' => "yaml"})
|
|
23
|
+
assert response.body
|
|
24
|
+
assert YAML.load(response.body)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# def test_doc_download
|
|
28
|
+
# @doc_interface = client.doc
|
|
29
|
+
# response = @doc_interface.download_openapi('/path/to/openapi.json')
|
|
30
|
+
# yaml_content = response.body
|
|
31
|
+
# yaml_data = YAML.load(yaml_content)
|
|
32
|
+
# assert_not_nil yaml_data
|
|
33
|
+
# end
|
|
34
|
+
|
|
35
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'morpheus_test'
|
|
2
|
+
|
|
3
|
+
# Tests for Morpheus::InstancesInterface
|
|
4
|
+
class MorpheusTest::InstancesInterfaceTest < MorpheusTest::TestCase
|
|
5
|
+
|
|
6
|
+
def test_instances_interface
|
|
7
|
+
@instances_interface = client.instances
|
|
8
|
+
response = @instances_interface.list()
|
|
9
|
+
instances = response['instances']
|
|
10
|
+
assert instances.is_a?(Array)
|
|
11
|
+
if !instances.empty?
|
|
12
|
+
response = @instances_interface.get(instances[0]['id'])
|
|
13
|
+
instance = response['instance']
|
|
14
|
+
assert instance.is_a?(Hash)
|
|
15
|
+
assert_equal instance['id'], instances[0]['id']
|
|
16
|
+
else
|
|
17
|
+
#puts "No instances found in this environment"
|
|
18
|
+
end
|
|
19
|
+
#todo: create and delete
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'morpheus_test'
|
|
2
|
+
|
|
3
|
+
# Tests for Morpheus::WhoamiInterface
|
|
4
|
+
class MorpheusTest::WhoamiInterfaceTest < MorpheusTest::TestCase
|
|
5
|
+
|
|
6
|
+
def test_whoami_interface
|
|
7
|
+
@whoami_interface = client.whoami
|
|
8
|
+
response = @whoami_interface.get()
|
|
9
|
+
assert_equal response['user']['username'], @config.username
|
|
10
|
+
# todo: fix this, can be cached and fail
|
|
11
|
+
#assert_equal response['appliance']['buildVersion'], Morpheus::Cli::Remote.load_remote(@config.remote_name)[:build_version]
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require 'morpheus_test'
|
|
2
|
+
|
|
3
|
+
# Tests for Morpheus::Cli::AccessTokenCommand
|
|
4
|
+
class MorpheusTest::AccessTokenTest < MorpheusTest::TestCase
|
|
5
|
+
|
|
6
|
+
def test_access_token
|
|
7
|
+
assert_execute("access-token")
|
|
8
|
+
assert_execute("access-token get")
|
|
9
|
+
assert_equal(is_logged_in(), true, "is_logged_in() should be true after access-token refresh")
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_access_token_details
|
|
13
|
+
assert_execute("access-token details")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_access_token_refresh
|
|
17
|
+
previous_token = get_access_token()
|
|
18
|
+
without_authentication do
|
|
19
|
+
login()
|
|
20
|
+
assert_execute("access-token refresh -y")
|
|
21
|
+
assert_equal(is_logged_in(), true, "is_logged_in() should be true after access-token refresh")
|
|
22
|
+
new_token = get_access_token()
|
|
23
|
+
assert_not_equal(previous_token, new_token, "Access token should have changed")
|
|
24
|
+
assert_error("login --test --token #{previous_token} ", "Old token should no longer be valid after refresh")
|
|
25
|
+
assert_execute("login --token #{new_token} ", "New token should be valid after refresh")
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_access_token_unauthenticated
|
|
30
|
+
without_authentication do
|
|
31
|
+
assert_error("access-token")
|
|
32
|
+
assert_error("access-token get")
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
require 'morpheus_test'
|
|
2
|
+
|
|
3
|
+
# Tests for login and logout
|
|
4
|
+
class MorpheusTest::AuthTest < MorpheusTest::TestCase
|
|
5
|
+
|
|
6
|
+
def requires_authentication
|
|
7
|
+
false
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def test_login
|
|
11
|
+
assert_execute %(login "#{escape_arg @config.username}" "#{escape_arg @config.password_decrypted}")
|
|
12
|
+
assert is_logged_in()
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def test_login_bad_credentials
|
|
16
|
+
assert_error %(login "#{escape_arg @config.username}" "invalid_password")
|
|
17
|
+
assert !is_logged_in()
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_login_test_option
|
|
21
|
+
without_authentication do
|
|
22
|
+
assert_equal(is_logged_in(), false, "begin as logged out")
|
|
23
|
+
assert_execute(%(login --test "#{escape_arg @config.username}" "#{escape_arg @config.password_decrypted}"))
|
|
24
|
+
assert_equal(is_logged_in(), false, "should still be logged out")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
with_authentication do
|
|
28
|
+
assert is_logged_in()
|
|
29
|
+
assert_error %(login --test "#{escape_arg @config.username}" "invalid_password")
|
|
30
|
+
assert is_logged_in(), "should still be logged in"
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_logout
|
|
35
|
+
with_authentication do
|
|
36
|
+
assert_execute %(logout)
|
|
37
|
+
assert !is_logged_in()
|
|
38
|
+
end
|
|
39
|
+
without_authentication do
|
|
40
|
+
assert_execute %(logout)
|
|
41
|
+
assert !is_logged_in()
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_login_prompt
|
|
46
|
+
with_input @config.username.to_s, @config.password_decrypted do
|
|
47
|
+
assert_execute %(login)
|
|
48
|
+
end
|
|
49
|
+
with_input @config.username.to_s, "invalid_password" do
|
|
50
|
+
assert_error %(login --test)
|
|
51
|
+
end
|
|
52
|
+
without_authentication do
|
|
53
|
+
with_input @config.username, @config.password_decrypted do
|
|
54
|
+
assert_execute %(instances list)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def test_login_adhoc
|
|
60
|
+
assert_execute %(login "#{escape_arg @config.username}" "#{escape_arg @config.password_decrypted}")
|
|
61
|
+
assert is_logged_in()
|
|
62
|
+
assert_execute %(login "#{escape_arg @config.username}" "#{escape_arg @config.password_decrypted}")
|
|
63
|
+
assert is_logged_in()
|
|
64
|
+
assert_execute("logout")
|
|
65
|
+
assert !is_logged_in()
|
|
66
|
+
|
|
67
|
+
# a bit meta, but let's test our helper methods here..
|
|
68
|
+
# login()
|
|
69
|
+
# assert_equal(is_logged_in(), true, "should be logged in")
|
|
70
|
+
# logout()
|
|
71
|
+
# assert_equal(is_logged_in(), false, "should be logged out")
|
|
72
|
+
# login_if_needed()
|
|
73
|
+
# assert_equal(is_logged_in(), true, "should be logged in")
|
|
74
|
+
# logout_if_needed()
|
|
75
|
+
# assert_equal(is_logged_in(), false, "should be logged out")
|
|
76
|
+
# logout()
|
|
77
|
+
# assert_equal(is_logged_in(), false, "should be logged out")
|
|
78
|
+
# login_if_needed()
|
|
79
|
+
# assert_equal(is_logged_in(), true, "should be logged in")
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
require 'morpheus_test'
|
|
2
|
+
|
|
3
|
+
# Tests for top level CLI functionality
|
|
4
|
+
class MorpheusTest::CliTest < MorpheusTest::TestCase
|
|
5
|
+
|
|
6
|
+
def requires_remote
|
|
7
|
+
false
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def requires_authentication
|
|
11
|
+
false
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_cli_no_arguments
|
|
15
|
+
assert_error("")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_cli_unknown_command
|
|
19
|
+
assert_error("unknown_command")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_cli_unknown_subcommand
|
|
23
|
+
assert_error("instances unknown_subcommand")
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_cli_version_option
|
|
27
|
+
assert_execute("-v")
|
|
28
|
+
assert_execute("--version")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_cli_nocolor
|
|
32
|
+
assert_execute("version -C")
|
|
33
|
+
assert_execute("echo -C \"disable coloring with the -C option\"")
|
|
34
|
+
# todo: fix bug here that makes this persist for all subsequent terminal commands
|
|
35
|
+
# this re-enavbles it for remainder of tests
|
|
36
|
+
# assert_execute("coloring on?")
|
|
37
|
+
assert_execute("coloring off?")
|
|
38
|
+
assert_execute("coloring")
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# HelpTest handles this now..
|
|
42
|
+
# def test_help
|
|
43
|
+
# assert_execute("help")
|
|
44
|
+
# assert_execute("-h")
|
|
45
|
+
# assert_execute("--help")
|
|
46
|
+
# end
|
|
47
|
+
|
|
48
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
require 'morpheus_test'
|
|
2
|
+
require 'test_data_helper'
|
|
3
|
+
|
|
4
|
+
# Tests for Morpheus::Cli::Containers
|
|
5
|
+
class MorpheusTest::ContainersTest < MorpheusTest::TestCase
|
|
6
|
+
|
|
7
|
+
include MorpheusTest::TestDataHelper
|
|
8
|
+
|
|
9
|
+
def setup()
|
|
10
|
+
super
|
|
11
|
+
#load_container_test_data()
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_containers_get
|
|
15
|
+
id = find_first_container_id()
|
|
16
|
+
assert_execute %(containers get #{id})
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# todo: need to wait and refresh status for this to work well
|
|
20
|
+
|
|
21
|
+
=begin
|
|
22
|
+
def test_containers_get_many
|
|
23
|
+
ids = find_many_container_ids().take(5)
|
|
24
|
+
assert_execute %(containers get #{ids.join(' ')})
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_containers_stop
|
|
28
|
+
with_input ["n", "y"] do
|
|
29
|
+
assert_execute %(containers stop #{@id}), exit_code: 9
|
|
30
|
+
assert_execute %(containers stop #{@id})
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_containers_start
|
|
35
|
+
with_input ["n", "y"] do
|
|
36
|
+
assert_execute %(containers start #{@id}), exit_code: 9
|
|
37
|
+
assert_execute %(containers start #{@id})
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_containers_restart
|
|
42
|
+
with_input ["n", "y"] do
|
|
43
|
+
assert_execute %(containers restart #{@id}), exit_code: 9
|
|
44
|
+
assert_execute %(containers restart #{@id})
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_containers_suspend
|
|
49
|
+
with_input ["n", "y"] do
|
|
50
|
+
assert_execute %(containers suspend #{@id}), exit_code: 9
|
|
51
|
+
assert_execute %(containers suspend #{@id})
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_containers_eject
|
|
56
|
+
with_input ["n", "y"] do
|
|
57
|
+
assert_execute %(containers eject #{@id}), exit_code: 9
|
|
58
|
+
assert_execute %(containers eject #{@id})
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
=end
|
|
62
|
+
|
|
63
|
+
def test_containers_actions
|
|
64
|
+
@id = find_first_container_id()
|
|
65
|
+
assert_execute %(containers actions #{@id})
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
=begin
|
|
69
|
+
# do not run random actions for now
|
|
70
|
+
# def test_containers_action
|
|
71
|
+
# #action_code = "docker-remove-node"
|
|
72
|
+
# action = client.containers.available_actions(@id)['actions'].first
|
|
73
|
+
# assert action.is_a?(Hash), "Expected to find an action to run"
|
|
74
|
+
# action_code = action['code']
|
|
75
|
+
# assert_execute %(containers action #{@id} -a #{action_code} -y)
|
|
76
|
+
# end
|
|
77
|
+
|
|
78
|
+
def test_containers_import
|
|
79
|
+
with_input ["n", "y"] do
|
|
80
|
+
assert_execute %(containers import #{@id} -N), exit_code: 9
|
|
81
|
+
assert_execute %(containers import #{@id} -N)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def test_containers_clone_image
|
|
86
|
+
with_input ["n", "y"] do
|
|
87
|
+
assert_execute %(containers clone-image #{@id} -N), exit_code: 9
|
|
88
|
+
assert_execute %(containers clone-image #{@id} -N)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
=end
|
|
92
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require 'morpheus_test'
|
|
2
|
+
|
|
3
|
+
# Tests for Morpheus::Cli::Doc
|
|
4
|
+
class MorpheusTest::DocTest < MorpheusTest::TestCase
|
|
5
|
+
|
|
6
|
+
def test_doc_list
|
|
7
|
+
assert_execute("doc list")
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def test_doc_get
|
|
11
|
+
# using --quiet because the output is massive
|
|
12
|
+
assert_execute("doc get --quiet")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def test_doc_get_yaml
|
|
16
|
+
# using --quiet because the output is massive
|
|
17
|
+
assert_execute("doc get --yaml --quiet")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# def test_doc_download
|
|
21
|
+
# assert_execute("doc download '/path/to/openapi.json')
|
|
22
|
+
# end
|
|
23
|
+
|
|
24
|
+
# def test_doc_download_yaml
|
|
25
|
+
# assert_execute("doc download '/path/to/openapi.yaml' --yaml")
|
|
26
|
+
# end
|
|
27
|
+
|
|
28
|
+
def test_doc_get_unauthorized
|
|
29
|
+
# authentication is NOT required for this api
|
|
30
|
+
without_authentication do
|
|
31
|
+
assert_success("doc get -q")
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'morpheus_test'
|
|
2
|
+
|
|
3
|
+
# Tests for help command and global --help option
|
|
4
|
+
class MorpheusTest::HelpTest < MorpheusTest::TestCase
|
|
5
|
+
|
|
6
|
+
def requires_authentication
|
|
7
|
+
false
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def test_help
|
|
11
|
+
assert_execute %(help)
|
|
12
|
+
assert_execute %(-h)
|
|
13
|
+
assert_execute %(--help)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_subcommand_help
|
|
17
|
+
assert_execute %(remote --help)
|
|
18
|
+
assert_execute %(remote -h)
|
|
19
|
+
assert_execute %(remote use --help)
|
|
20
|
+
assert_execute %(instances list --help)
|
|
21
|
+
assert_execute %(whoami --help)
|
|
22
|
+
assert_execute %(whoami -h)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require 'morpheus_test'
|
|
2
|
+
|
|
3
|
+
# Tests for Morpheus::Cli::Instances
|
|
4
|
+
class MorpheusTest::InstancesTest < MorpheusTest::TestCase
|
|
5
|
+
|
|
6
|
+
def test_instances_list
|
|
7
|
+
assert_execute %(instances list)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def test_instances_get
|
|
11
|
+
instance = client.instances.list({})['instances'][0]
|
|
12
|
+
if instance
|
|
13
|
+
assert_execute %(instances get "#{instance['id']}")
|
|
14
|
+
assert_execute %(instances get "#{escape_arg instance['name']}")
|
|
15
|
+
else
|
|
16
|
+
puts "No instance found, unable to execute test `#{__method__}`"
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# def test_instances_add
|
|
21
|
+
# warn "Skipped test test_instances_add() because it is not implemented"
|
|
22
|
+
# end
|
|
23
|
+
|
|
24
|
+
# def test_instances_update
|
|
25
|
+
# warn "Skipped test test_instances_update() because it is not implemented"
|
|
26
|
+
# end
|
|
27
|
+
|
|
28
|
+
# def test_instances_delete
|
|
29
|
+
# warn "Skipped test test_instances_remove() because it is not implemented"
|
|
30
|
+
# end
|
|
31
|
+
|
|
32
|
+
# todo: many more instance commands to add
|
|
33
|
+
|
|
34
|
+
protected
|
|
35
|
+
|
|
36
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'morpheus_test'
|
|
2
|
+
|
|
3
|
+
class MorpheusTest::ManTest < MorpheusTest::TestCase
|
|
4
|
+
|
|
5
|
+
def test_man
|
|
6
|
+
# need to use -q to avoid interactive right now...
|
|
7
|
+
assert_execute("man -q")
|
|
8
|
+
assert_execute("man -g -q")
|
|
9
|
+
assert_execute("man -q")
|
|
10
|
+
man_file_path = Morpheus::Cli::ManCommand.man_file_path
|
|
11
|
+
assert(File.exist?(man_file_path), "File #{man_file_path} should have been created.")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
end
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
require 'morpheus_test'
|
|
2
|
+
|
|
3
|
+
# Tests for Morpheus::Cli::Remote
|
|
4
|
+
class MorpheusTest::RemoteTest < MorpheusTest::TestCase
|
|
5
|
+
|
|
6
|
+
def requires_remote
|
|
7
|
+
false
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def requires_authentication
|
|
11
|
+
false
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def setup
|
|
15
|
+
super()
|
|
16
|
+
@@test_remote_name ||= "test_remote_#{SecureRandom.hex(10)}"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def teardown
|
|
20
|
+
# switch back aftwards
|
|
21
|
+
assert_execute %(remote use "#{escape_arg @config.remote_name}")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_remote_add
|
|
25
|
+
assert_execute %(remote add "#{@@test_remote_name}" "#{escape_arg @config.url}" --insecure --use -N)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def test_remote_list
|
|
29
|
+
assert_execute %(remote list)
|
|
30
|
+
assert_execute %(remote list "#{@@test_remote_name}")
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_remote_get
|
|
34
|
+
assert_execute %(remote get)
|
|
35
|
+
assert_execute %(remote get current)
|
|
36
|
+
assert_execute %(remote get "#{@@test_remote_name}")
|
|
37
|
+
assert_execute %(remote get "#{@@test_remote_name}" --offline)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_remote_current
|
|
41
|
+
assert_execute %(remote current)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def test_remote_version
|
|
45
|
+
assert_execute %(remote version)
|
|
46
|
+
#assert_execute %(remote version "#{@@test_remote_name}")
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_remote_check
|
|
50
|
+
assert_execute %(remote check)
|
|
51
|
+
assert_execute %(remote check "#{@@test_remote_name}")
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_remote_check_all
|
|
55
|
+
assert_execute %(remote check-all)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def test_remote_update
|
|
59
|
+
assert_execute %(remote update "#{@@test_remote_name}" --url "#{escape_arg @config.url}" --insecure)
|
|
60
|
+
#assert_execute %(remote update "#{@@test_remote_name}" --name "#{@@test_remote_name}_updated")
|
|
61
|
+
#assert_execute %(remote update "#{@@test_remote_name}_updated" --name "#{@@test_remote_name}")
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def test_remote_rename
|
|
65
|
+
assert_execute %(remote rename "#{@@test_remote_name}" "#{@@test_remote_name}_renamed" -y)
|
|
66
|
+
assert_execute %(remote rename "#{@@test_remote_name}_renamed" "#{@@test_remote_name}" -y)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def test_remote_use
|
|
70
|
+
assert_error %(remote use)
|
|
71
|
+
assert_error %(remote use unknown_remote)
|
|
72
|
+
assert_execute %(remote use "#{@@test_remote_name}")
|
|
73
|
+
assert_execute %(remote use "#{@@test_remote_name}")
|
|
74
|
+
assert_execute %(remote get current)
|
|
75
|
+
assert_execute %(remote unuse)
|
|
76
|
+
assert_error %(remote get current)
|
|
77
|
+
assert_execute %(remote use "#{@@test_remote_name}" -q)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def test_remote_remove
|
|
81
|
+
# test remove confirmation reploy of n or no
|
|
82
|
+
with_input(["n", "No"]) do
|
|
83
|
+
assert_error %(remote remove "#{@@test_remote_name}")
|
|
84
|
+
assert_error %(remote remove "#{@@test_remote_name}")
|
|
85
|
+
end
|
|
86
|
+
assert_execute %(remote remove "#{@@test_remote_name}" -y)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require 'morpheus_test'
|
|
2
|
+
|
|
3
|
+
class MorpheusTest::RolesTest < MorpheusTest::TestCase
|
|
4
|
+
|
|
5
|
+
def test_roles_list
|
|
6
|
+
assert_execute %(roles list)
|
|
7
|
+
assert_execute %(roles list "System Admin")
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def test_roles_get
|
|
11
|
+
assert_execute %(roles get "System Admin")
|
|
12
|
+
assert_execute %(roles get "System Admin" --permissions)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def test_roles_list_permissions
|
|
16
|
+
assert_execute %(roles list-permissions "System Admin")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# todo: test all the other commands
|
|
20
|
+
|
|
21
|
+
# def test_roles_add
|
|
22
|
+
# assert_execute %(roles add "test_role_#{random_id}" -N)
|
|
23
|
+
# end
|
|
24
|
+
|
|
25
|
+
# def test_roles_update
|
|
26
|
+
# #skip "Test needs to be added"
|
|
27
|
+
# assert_execute %(roles update "test_role_#{random_id}" --description "neat")
|
|
28
|
+
# end
|
|
29
|
+
|
|
30
|
+
# def test_roles_remove
|
|
31
|
+
# assert_execute %(roles remove "test_role_#{random_id}" -y")
|
|
32
|
+
# end
|
|
33
|
+
|
|
34
|
+
end
|