epc 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/epc.rb +71 -54
- data/lib/epc/command/archive_command.rb +12 -0
- data/lib/epc/command/attach_libraryset_command.rb +1 -2
- data/lib/epc/command/attach_runtime_command.rb +0 -1
- data/lib/epc/command/base_command.rb +52 -63
- data/lib/epc/command/config/delete_config_command.rb +57 -0
- data/lib/epc/command/{list_config_command.rb → config/list_configs_command.rb} +1 -1
- data/lib/epc/command/config/update_config_command.rb +56 -0
- data/lib/epc/command/create_command.rb +0 -1
- data/lib/epc/command/delete_command.rb +16 -0
- data/lib/epc/command/{delete_dependency_command.rb → dependency/delete_dependency_command.rb} +14 -16
- data/lib/epc/command/deploy_command.rb +1 -2
- data/lib/epc/command/deployment/list_deployments_command.rb +49 -0
- data/lib/epc/command/deployment/show_deployment_command.rb +61 -0
- data/lib/epc/command/{update_deploymentproject_command.rb → deployment/update_deployment_command.rb} +3 -3
- data/lib/epc/command/{list_stages_command.rb → deploymentstage/list_deploymentstages_command.rb} +1 -1
- data/lib/epc/command/group/delete_group_command.rb +25 -0
- data/lib/epc/command/{list_groups_command.rb → group/list_groups_command.rb} +1 -1
- data/lib/epc/command/{show_group_command.rb → group/show_group_command.rb} +2 -9
- data/lib/epc/command/{update_group_command.rb → group/update_group_command.rb} +3 -20
- data/lib/epc/command/library/create_library_command.rb +2 -5
- data/lib/epc/command/library/delete_library_command.rb +23 -0
- data/lib/epc/command/{list_libraries_command.rb → library/list_libraries_command.rb} +1 -1
- data/lib/epc/command/librarylanguage/delete_librarylanguage_command.rb +24 -0
- data/lib/epc/command/{list_librarylanguages_command.rb → librarylanguage/list_librarylanguages_command.rb} +1 -1
- data/lib/epc/command/{update_librarylanguage_command.rb → librarylanguage/update_librarylanguage_command.rb} +6 -10
- data/lib/epc/command/libraryset/create_libraryset_command.rb +1 -6
- data/lib/epc/command/{delete_libraryset_command.rb → libraryset/delete_libraryset_command.rb} +2 -18
- data/lib/epc/command/{list_librarysets_command.rb → libraryset/list_librarysets_command.rb} +1 -1
- data/lib/epc/command/{show_libraryset_command.rb → libraryset/show_libraryset_command.rb} +2 -17
- data/lib/epc/command/{update_libraryset_command.rb → libraryset/update_libraryset_command.rb} +4 -16
- data/lib/epc/command/list_command.rb +22 -0
- data/lib/epc/command/list_metrics_command.rb +25 -0
- data/lib/epc/command/list_objecttypes_command.rb +2 -4
- data/lib/epc/command/list_versions_command.rb +0 -1
- data/lib/epc/command/{list_objectroles_command.rb → objectrole/list_objectroles_command.rb} +3 -3
- data/lib/epc/command/objectrole/update_objectrole_command.rb +14 -0
- data/lib/epc/command/{list_rolepermissions_command.rb → permission/list_permissions_command.rb} +2 -2
- data/lib/epc/command/{list_permissiongroups_command.rb → permissiongroup/list_permissiongroups_command.rb} +1 -1
- data/lib/epc/command/plugin/create_plugin_command.rb +42 -0
- data/lib/epc/command/plugin/delete_plugin_command.rb +26 -0
- data/lib/epc/command/plugin/list_plugins_command.rb +19 -0
- data/lib/epc/command/plugin/show_plugin_command.rb +29 -0
- data/lib/epc/command/plugin/update_plugin_command.rb +53 -0
- data/lib/epc/command/{archive_project_command.rb → project/archive_project_command.rb} +4 -3
- data/lib/epc/command/{delete_project_command.rb → project/delete_project_command.rb} +11 -7
- data/lib/epc/command/{list_projects_command.rb → project/list_projects_command.rb} +8 -9
- data/lib/epc/command/{show_project_command.rb → project/show_project_command.rb} +64 -29
- data/lib/epc/command/{unarchive_project_command.rb → project/unarchive_project_command.rb} +5 -4
- data/lib/epc/command/{update_project_command.rb → project/update_project_command.rb} +11 -5
- data/lib/epc/command/{list_projecttypes_command.rb → projecttype/list_projecttypes_command.rb} +1 -1
- data/lib/epc/command/{show_projecttype_command.rb → projecttype/show_projecttype_command.rb} +4 -3
- data/lib/epc/command/pull_command.rb +33 -35
- data/lib/epc/command/{delete_role_command.rb → role/delete_role_command.rb} +3 -4
- data/lib/epc/command/{list_roles_command.rb → role/list_roles_command.rb} +4 -3
- data/lib/epc/command/{show_role_command.rb → role/show_role_command.rb} +18 -10
- data/lib/epc/command/role/update_role_command.rb +95 -0
- data/lib/epc/command/{list_runtimes_command.rb → runtime/list_runtimes_command.rb} +0 -0
- data/lib/epc/command/servicedefinition/create_servicedefinition_command.rb +23 -0
- data/lib/epc/command/{list_servicedefinitions_command.rb → servicedefinition/list_servicedefinitions_command.rb} +1 -0
- data/lib/epc/command/{list_service_types_command.rb → servicetype/list_servicetypes_command.rb} +0 -0
- data/lib/epc/command/serviceversion/delete_serviceversion_command.rb +24 -0
- data/lib/epc/command/{list_serviceversions_command.rb → serviceversion/list_serviceversions_command.rb} +1 -1
- data/lib/epc/command/show_command.rb +27 -0
- data/lib/epc/command/show_instances_command.rb +33 -0
- data/lib/epc/command/show_metrics_command.rb +55 -0
- data/lib/epc/command/{archive_solution_command.rb → solution/archive_solution_command.rb} +2 -1
- data/lib/epc/command/solution/create_solution_command.rb +0 -1
- data/lib/epc/command/{delete_solution_command.rb → solution/delete_solution_command.rb} +5 -10
- data/lib/epc/command/solution/list_solutions_command.rb +1 -1
- data/lib/epc/command/{show_solution_command.rb → solution/show_solution_command.rb} +12 -7
- data/lib/epc/command/{unarchive_solution_command.rb → solution/unarchive_solution_command.rb} +1 -1
- data/lib/epc/command/solution/update_solution_command.rb +2 -1
- data/lib/epc/command/unarchive_command.rb +12 -0
- data/lib/epc/command/update_command.rb +15 -0
- data/lib/epc/command/update_rolepermissions_command.rb +2 -2
- data/lib/epc/command/{delete_user_command.rb → user/delete_user_command.rb} +4 -12
- data/lib/epc/command/{list_users_command.rb → user/list_users_command.rb} +1 -1
- data/lib/epc/command/{show_user_command.rb → user/show_user_command.rb} +3 -17
- data/lib/epc/command/{update_user_command.rb → user/update_user_command.rb} +2 -4
- data/lib/epc/config.rb +4 -1
- data/lib/epc/help.rb +50 -35
- data/lib/epc/runner.rb +16 -5
- data/lib/epc/version.rb +1 -1
- data/lib/epc/vertical_bar.rb +40 -0
- data/test/command/create_library_command_test.rb +5 -2
- data/test/command/create_libraryset_command_test.rb +1 -1
- data/test/command/create_plugin_command_test.rb +44 -0
- data/test/command/create_servicedefinition_command_test.rb +43 -0
- data/test/command/delete_config_command_test.rb +0 -11
- data/test/command/delete_dependency_command_test.rb +3 -11
- data/test/command/delete_library_command_test.rb +2 -15
- data/test/command/delete_librarylanguage_command_test.rb +2 -24
- data/test/command/delete_libraryset_command_test.rb +2 -24
- data/test/command/delete_plugin_command_test.rb +32 -0
- data/test/command/delete_project_command_test.rb +0 -6
- data/test/command/delete_role_command_test.rb +1 -1
- data/test/command/delete_serviceversion_command_test.rb +0 -22
- data/test/command/delete_solution_command_test.rb +4 -4
- data/test/command/delete_user_command_test.rb +2 -24
- data/test/command/list_config_command_test.rb +3 -3
- data/test/command/list_deployments_command_test.rb +17 -20
- data/test/command/list_deploymentstages_command_test.rb +2 -2
- data/test/command/list_metrics_command_test.rb +40 -0
- data/test/command/{list_rolepermissions_command_test.rb → list_permissions_command_test.rb} +2 -2
- data/test/command/list_plugins_command_test.rb +27 -0
- data/test/command/list_projects_command_test.rb +3 -5
- data/test/command/list_roles_command_test.rb +2 -3
- data/test/command/pull_command_test.rb +13 -9
- data/test/command/show_group_command_test.rb +1 -23
- data/test/command/show_instances_command_test.rb +33 -0
- data/test/command/show_libraryset_command_test.rb +0 -11
- data/test/command/show_metrics_command_test.rb +51 -0
- data/test/command/show_plugin_command_test.rb +28 -0
- data/test/command/show_project_command_test.rb +1 -1
- data/test/command/show_projecttype_command_test.rb +0 -5
- data/test/command/show_role_command_test.rb +1 -1
- data/test/command/show_solution_command_test.rb +1 -1
- data/test/command/show_user_command_test.rb +2 -22
- data/test/command/update_config_command_test.rb +3 -9
- data/test/command/{update_deploymentproject_command_test.rb → update_deployment_command_test.rb} +6 -11
- data/test/command/update_group_command_test.rb +1 -20
- data/test/command/update_librarylanguage_command_test.rb +0 -15
- data/test/command/update_libraryset_command_test.rb +0 -13
- data/test/command/update_plugin_command_test.rb +41 -0
- data/test/command/update_project_command_test.rb +3 -3
- data/test/command/update_role_command_test.rb +2 -1
- data/test/command/update_solution_command_test.rb +3 -9
- data/test/command/update_user_command_test.rb +0 -6
- metadata +177 -165
- data/lib/epc/command/define_service_command.rb +0 -37
- data/lib/epc/command/delete_config_command.rb +0 -63
- data/lib/epc/command/delete_group_command.rb +0 -40
- data/lib/epc/command/delete_library_command.rb +0 -30
- data/lib/epc/command/delete_librarylanguage_command.rb +0 -40
- data/lib/epc/command/delete_serviceversion_command.rb +0 -52
- data/lib/epc/command/list_approvals_command.rb +0 -27
- data/lib/epc/command/list_attachedlibraries_command.rb +0 -42
- data/lib/epc/command/list_boundservices_command.rb +0 -40
- data/lib/epc/command/list_dependencies_command.rb +0 -43
- data/lib/epc/command/list_deployments_command.rb +0 -68
- data/lib/epc/command/list_solutions_command.rb +0 -25
- data/lib/epc/command/show_deployment_command.rb +0 -57
- data/lib/epc/command/update_config_command.rb +0 -62
- data/lib/epc/command/update_role_command.rb +0 -47
- data/lib/epc/command/update_solution_command.rb +0 -45
- data/test/command/define_service_command_test.rb +0 -55
- data/test/command/delete_group_command_test.rb +0 -56
- data/test/command/list_approvals_command_test.rb +0 -41
- data/test/command/list_boundservices_command_test.rb +0 -46
- data/test/command/list_dependencies_command_test.rb +0 -46
- data/test/command/update_rolepermissions_command_test.rb +0 -54
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class
|
3
|
+
class ListDeploymentstagesCommandTest < Test::Unit::TestCase
|
4
4
|
should_require_login
|
5
5
|
|
6
6
|
context "list solutions" do
|
7
7
|
setup do
|
8
8
|
@mock_client = mock("Client")
|
9
9
|
|
10
|
-
@command = EPC::Command::
|
10
|
+
@command = EPC::Command::ListDeploymentstagesCommand.new(@mock_client)
|
11
11
|
end
|
12
12
|
|
13
13
|
should "show exception message status is not 201" do
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ListMetricsCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
|
7
|
+
context "execution" do
|
8
|
+
setup do
|
9
|
+
@mock_client = mock("Client")
|
10
|
+
@command = EPC::Command::ListMetricsCommand.new(@mock_client)
|
11
|
+
end
|
12
|
+
|
13
|
+
should "fail if status is not 200(ok)" do
|
14
|
+
@mock_client.expects(:get).with(EPC::Config::METRICS_PATH).returns([500, {:message => "System exception encountered"}, {}])
|
15
|
+
@command.expects(:say).with("Request failed: [System exception encountered]")
|
16
|
+
assert_equal 500, @command.execute
|
17
|
+
end
|
18
|
+
|
19
|
+
should "show a message if no metrics are returned" do
|
20
|
+
@mock_client.expects(:get).with(EPC::Config::METRICS_PATH).returns([200, {}, {}])
|
21
|
+
@command.expects(:say).with("No metrics available.")
|
22
|
+
assert_equal 200, @command.execute
|
23
|
+
end
|
24
|
+
|
25
|
+
should "show a message if no metrics are returned for a given target" do
|
26
|
+
@command = EPC::Command::ListMetricsCommand.new(@mock_client, {target: 'jimmy'})
|
27
|
+
@mock_client.expects(:get).with("#{EPC::Config::METRICS_PATH}?target=jimmy").returns([200, {}, {}])
|
28
|
+
@command.expects(:say).with("No metrics available for target jimmy.")
|
29
|
+
assert_equal 200, @command.execute
|
30
|
+
end
|
31
|
+
|
32
|
+
should "list metrics" do
|
33
|
+
metrics = [{target: 'target', id: 'id', name: 'name', type: 'type', function: 'function'}]
|
34
|
+
@mock_client.expects(:get).with(EPC::Config::METRICS_PATH).returns([200, metrics, {}])
|
35
|
+
@command.expects(:say)
|
36
|
+
assert_equal 200, @command.execute
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class
|
3
|
+
class ListPermissionsCommandTest < Test::Unit::TestCase
|
4
4
|
should_require_login
|
5
5
|
|
6
6
|
context "execute" do
|
7
7
|
setup do
|
8
8
|
@mock_client = mock("Client")
|
9
|
-
@command = EPC::Command::
|
9
|
+
@command = EPC::Command::ListPermissionsCommand.new(@mock_client)
|
10
10
|
end
|
11
11
|
|
12
12
|
should "show a message if status is not 200" do
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ListPluginsCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execute" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::ListPluginsCommand.new(@mock_client)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "list the plugins" do
|
13
|
+
@mock_client.expects(:get).with(EPC::Config::PLUGINS_PATH).returns([200, [{}], {}])
|
14
|
+
@command.expects(:say)
|
15
|
+
@command.execute("")
|
16
|
+
end
|
17
|
+
|
18
|
+
should "report reason for request failure" do
|
19
|
+
@mock_client.expects(:get).with(EPC::Config::PLUGINS_PATH).returns([500, {:message => "System Exception"}, {}])
|
20
|
+
@command.expects(:say).with("Request failed: [System Exception]")
|
21
|
+
@command.execute("")
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
end
|
@@ -11,11 +11,9 @@ class ListProjectsCommandTest < Test::Unit::TestCase
|
|
11
11
|
|
12
12
|
should "fail if solution id can't be determined" do
|
13
13
|
@command.expects(:infer_solution_context).returns(nil)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
assert_equal(@command.execute("FirstSolution"), 1)
|
14
|
+
assert_raise EPC::Error::InputError do
|
15
|
+
assert_equal(@command.execute, 1)
|
16
|
+
end
|
19
17
|
end
|
20
18
|
end
|
21
19
|
|
@@ -34,12 +34,11 @@ class ListRolesCommandTest < Test::Unit::TestCase
|
|
34
34
|
assert_equal(@command.execute, 200)
|
35
35
|
end
|
36
36
|
|
37
|
-
should "retrieve roles for the user
|
38
|
-
@command.options[:user] = 1
|
37
|
+
should "retrieve roles for the user" do
|
39
38
|
@mock_client.expects(:get).with(EPC::Config::USERS_PATH + "/1?include=roles").
|
40
39
|
returns([200, {:roles => [{:id => 1, :name => "SuperAdmin"}, {:id => 2, :name => "Admin"}]}, {}])
|
41
40
|
@command.expects(:say)
|
42
|
-
assert_equal(@command.execute, 200)
|
41
|
+
assert_equal(@command.execute("User:1"), 200)
|
43
42
|
end
|
44
43
|
end
|
45
44
|
|
@@ -117,8 +117,10 @@ class PullCommandTest < Test::Unit::TestCase
|
|
117
117
|
@mock_client.expects(:put).with("/api/v1/pulls/1/sign").
|
118
118
|
returns([200, { :signed_url => "http://download/from/here" }, {}])
|
119
119
|
|
120
|
-
status,
|
121
|
-
|
120
|
+
status, response, headers = command.send(:sign_pull, 1)
|
121
|
+
code = response[:error_code]
|
122
|
+
url = response[:signed_url]
|
123
|
+
|
122
124
|
assert_equal(200, status)
|
123
125
|
assert_nil(code)
|
124
126
|
assert_equal("http://download/from/here", url)
|
@@ -130,8 +132,10 @@ class PullCommandTest < Test::Unit::TestCase
|
|
130
132
|
@mock_client.expects(:put).with("/api/v1/pulls/1/sign").
|
131
133
|
returns([404, { :message => "not found", :error_code => 801 }, {}])
|
132
134
|
|
133
|
-
status,
|
134
|
-
|
135
|
+
status, response, headers = command.send(:sign_pull, 1)
|
136
|
+
code = response[:error_code]
|
137
|
+
url = response[:signed_url]
|
138
|
+
|
135
139
|
assert_equal(404, status)
|
136
140
|
assert_equal(801, code)
|
137
141
|
assert_nil(url)
|
@@ -173,15 +177,15 @@ class PullCommandTest < Test::Unit::TestCase
|
|
173
177
|
@command = EPC::Command::PullCommand.new(@mock_client)
|
174
178
|
end
|
175
179
|
|
176
|
-
should "poll
|
177
|
-
@command.expects(:sign_pull).returns([200,
|
178
|
-
assert_equal(@command.send(:poll_for_pull_url, 1), [true, "url_to_zip"])
|
180
|
+
should "poll until if receives and url" do
|
181
|
+
@command.expects(:sign_pull).returns([200, {:signed_url => "url_to_zip"}, nil])
|
182
|
+
assert_equal(@command.send(:poll_for_pull_url, 1), [true, "url_to_zip", {:signed_url => "url_to_zip"}])
|
179
183
|
end
|
180
184
|
|
181
185
|
should "notify when there's an error in polling" do
|
182
|
-
@command.expects(:sign_pull).returns([500,
|
186
|
+
@command.expects(:sign_pull).returns([500, {}, nil])
|
183
187
|
@command.expects(:say).with("Poller failed to get the pull URL. Aborting.")
|
184
|
-
assert_equal(@command.send(:poll_for_pull_url, 1), [false, nil])
|
188
|
+
assert_equal(@command.send(:poll_for_pull_url, 1), [false, nil, nil])
|
185
189
|
end
|
186
190
|
|
187
191
|
end
|
@@ -9,12 +9,6 @@ class ShowGroupCommandTest < Test::Unit::TestCase
|
|
9
9
|
@command = EPC::Command::ShowGroupCommand.new(@mock_client)
|
10
10
|
end
|
11
11
|
|
12
|
-
should "fail if no group is specified" do
|
13
|
-
assert_raise EPC::Error::FatalError do
|
14
|
-
assert_equal(@command.execute, 1)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
12
|
should "fail if status is not 200" do
|
19
13
|
@mock_client.expects(:get).with(EPC::Config::GROUPS_PATH + "/1?include=users").
|
20
14
|
returns([404, {:message => "Not Found"}, {}])
|
@@ -22,24 +16,8 @@ class ShowGroupCommandTest < Test::Unit::TestCase
|
|
22
16
|
assert_equal(@command.execute(1), 1)
|
23
17
|
end
|
24
18
|
|
25
|
-
should "fail if group_id can't be determined" do
|
26
|
-
@command.expects(:get_resource_id).with(EPC::Config::GROUPS_PATH, :name, "admins").returns(nil)
|
27
|
-
assert_raise EPC::Error::FatalError do
|
28
|
-
assert_equal(@command.execute("admins"), 1)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
should "show a group specified by id" do
|
33
|
-
@mock_client.expects(:get).with(EPC::Config::GROUPS_PATH + "/1?include=users").
|
34
|
-
returns([200, {}, {}])
|
35
|
-
@command.expects(:say).at_least_once
|
36
|
-
|
37
|
-
assert_equal(@command.execute(1), 200)
|
38
|
-
end
|
39
|
-
|
40
|
-
|
41
19
|
should "show a group specified by name" do
|
42
|
-
@command.expects(:
|
20
|
+
@command.expects(:retrieve_identifier_for).returns(1)
|
43
21
|
@mock_client.expects(:get).with(EPC::Config::GROUPS_PATH + "/1?include=users").
|
44
22
|
returns([200, {:id => 1, :name => "Grp1", :users => [{:id => 1, :name => "Group Leader", :email => "group_leader@epaas.com"}]}, {}])
|
45
23
|
@command.expects(:say).at_least_once
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ShowInstancesCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execution" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@id = "123"
|
10
|
+
@url = "#{EPC::Config::INSTANCES_PATH}/#{CGI.escape(@id)}/instances"
|
11
|
+
@command = EPC::Command::ShowInstancesCommand.new(@mock_client)
|
12
|
+
end
|
13
|
+
|
14
|
+
should "fail if no id is specified" do
|
15
|
+
@command.expects(:say).with("You must specify the deployed project id.")
|
16
|
+
@command.expects(:say).with(EPC::Help::COMMAND_USAGES[:show_instances])
|
17
|
+
assert_equal @command.execute, 1
|
18
|
+
end
|
19
|
+
|
20
|
+
should "fail if status is not 200 (ok)" do
|
21
|
+
@mock_client.expects(:get).with(@url).returns([500, {:message => "System exception encountered"}, {}])
|
22
|
+
@command.expects(:say).with("Request failed: [System exception encountered]")
|
23
|
+
assert_equal 500, @command.execute("", "", @id)
|
24
|
+
end
|
25
|
+
|
26
|
+
should "show deployed project instances" do
|
27
|
+
@mock_client.expects(:get).with(@url).returns([200, {instance_id: { active: true }}, {}])
|
28
|
+
@command.expects(:say)
|
29
|
+
assert_equal 200, @command.execute("", "", @id)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -9,17 +9,6 @@ class ShowLibrarysetCommandTest < Test::Unit::TestCase
|
|
9
9
|
@command = EPC::Command::ShowLibrarysetCommand.new(@mock_client)
|
10
10
|
end
|
11
11
|
|
12
|
-
should "fail if library set is not specified" do
|
13
|
-
@command.expects(:say).with("You must specify a library-set")
|
14
|
-
@command.expects(:say).with(EPC::Help::COMMAND_USAGES[:show_libraryset])
|
15
|
-
assert_equal(@command.execute, 1)
|
16
|
-
end
|
17
|
-
|
18
|
-
should "fail if library set id can't be determined" do
|
19
|
-
@command.expects(:get_resource_id).with(EPC::Config::LIBRARY_SETS_PATH, :name, "lib-set").returns(nil)
|
20
|
-
@command.expects(:say).with("Library set could not be determined")
|
21
|
-
assert_equal(@command.execute("lib-set"), 1)
|
22
|
-
end
|
23
12
|
|
24
13
|
should "show error if status is not 201" do
|
25
14
|
@mock_client.expects(:get).with(EPC::Config::LIBRARY_SETS_PATH+"/1").
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ShowMetricsCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execution" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@id = "target"
|
10
|
+
@metrics = "mem-max"
|
11
|
+
@url = "#{EPC::Config::MONITORED_PATH}/#{CGI.escape(@id)}/metrics/#{CGI.escape(@metrics)}"
|
12
|
+
@redirect_url = "http://localhost/#{CGI.escape(@id)}/metrics/#{CGI.escape(@metrics)}"
|
13
|
+
@command = EPC::Command::ShowMetricsCommand.new(@mock_client, {graph: true})
|
14
|
+
end
|
15
|
+
|
16
|
+
should "fail if no target is specified" do
|
17
|
+
@command.expects(:say).with("You must specify the target object id.")
|
18
|
+
@command.expects(:say).with(EPC::Help::COMMAND_USAGES[:show_metrics])
|
19
|
+
assert_equal(@command.execute, 1)
|
20
|
+
end
|
21
|
+
|
22
|
+
should "fail if no metrics are specified" do
|
23
|
+
@command = EPC::Command::ShowMetricsCommand.new(@mock_client)
|
24
|
+
@command.expects(:say).with("You must specify the metrics to display.")
|
25
|
+
@command.expects(:say).with(EPC::Help::COMMAND_USAGES[:show_metrics])
|
26
|
+
assert_equal(@command.execute("", "", @id), 1)
|
27
|
+
end
|
28
|
+
|
29
|
+
should "fail if status is not 302 (ok)" do
|
30
|
+
@mock_client.expects(:get).with(@url).returns([500, {:message => "System exception encountered"}, {}])
|
31
|
+
@command.expects(:say).with("Request failed: [System exception encountered]")
|
32
|
+
assert_equal 500, @command.execute("", "", @id, @metrics)
|
33
|
+
end
|
34
|
+
|
35
|
+
should "fail if second status is not 200 (ok)" do
|
36
|
+
@mock_client.expects(:get).with(@url).returns([302, {}, {uri: @redirect_url}])
|
37
|
+
EPC::Client::HttpClient.any_instance.expects(:get).with(@redirect_url).returns([500, {:message => "System exception encountered"}, {}])
|
38
|
+
@command.expects(:say).with("Request failed: [System exception encountered]")
|
39
|
+
assert_equal 500, @command.execute("", "", @id, @metrics)
|
40
|
+
end
|
41
|
+
|
42
|
+
should "show metrics" do
|
43
|
+
@mock_client.expects(:get).with(@url).returns([302, {}, {uri: @redirect_url}])
|
44
|
+
json = '{"id":{"metric":{"start":0,"stop":2,"step":3,"data":[1,2,3]}}}'
|
45
|
+
EPC::Client::HttpClient.any_instance.expects(:get).with(@redirect_url).returns([200, json, {}])
|
46
|
+
@command.expects(:say).times(3)
|
47
|
+
assert_equal 200, @command.execute("", "", @id, @metrics)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ShowPluginCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execute" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::ShowPluginCommand.new(@mock_client)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "show the plugin" do
|
13
|
+
@command.expects(:retrieve_identifier_for).returns(1)
|
14
|
+
@mock_client.expects(:get).with(EPC::Config::PLUGINS_PATH + "/1").returns([200, {:id => 1, :name => "plugin_name", :plugin_version => "1", :group => "plugin_groups", :inherited => true, :extensions => false, :executions => "exec_string", :configuration => "config_string"}, {}])
|
15
|
+
@command.expects(:say).at_least_once
|
16
|
+
@command.execute("plugin_name")
|
17
|
+
end
|
18
|
+
|
19
|
+
should "report reason for request failure" do
|
20
|
+
@command.expects(:retrieve_identifier_for).returns(1)
|
21
|
+
@mock_client.expects(:get).with(EPC::Config::PLUGINS_PATH + "/1").returns([500, {:message => "System Exception"}, {}])
|
22
|
+
@command.expects(:say).with("Request failed: [System Exception]")
|
23
|
+
@command.execute("plugin_name")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
end
|
@@ -33,7 +33,7 @@ class ShowProjectCommandTest < Test::Unit::TestCase
|
|
33
33
|
|
34
34
|
should "show details about the requested project" do
|
35
35
|
time = Time.now.to_s
|
36
|
-
@mock_client.expects(:get).with(EPC::Config::PROJECTS_PATH+"/1?include=dependencies,roles,config_values").
|
36
|
+
@mock_client.expects(:get).with(EPC::Config::PROJECTS_PATH+"/1?include=dependencies,roles,config_values,service_versions,libraries").
|
37
37
|
returns(
|
38
38
|
[
|
39
39
|
200,
|
@@ -12,11 +12,6 @@ class ShowProjecttypeCommandTest < Test::Unit::TestCase
|
|
12
12
|
@command = EPC::Command::ShowProjecttypeCommand.new(@mock_client)
|
13
13
|
end
|
14
14
|
|
15
|
-
should "fail if project type can't be determined" do
|
16
|
-
assert_raise EPC::Error::FatalError do
|
17
|
-
assert_equal(@command.execute, 1)
|
18
|
-
end
|
19
|
-
end
|
20
15
|
end
|
21
16
|
|
22
17
|
context "retrieval " do
|
@@ -26,7 +26,7 @@ class ShowRoleCommandTest < Test::Unit::TestCase
|
|
26
26
|
|
27
27
|
|
28
28
|
should "show a role specified by name" do
|
29
|
-
@command.expects(:
|
29
|
+
@command.expects(:retrieve_identifier_for).returns(1)
|
30
30
|
@mock_client.expects(:get).with(EPC::Config::ROLES_PATH + "/1?include=users,user_groups,grants").
|
31
31
|
returns([200, {:id => 1, :name => "admin", :users => [{:id => 1, :name => "Group Leader", :email => "group_leader@epaas.com"}], :user_groups => [{:id => 1, :name => "The Leaders"}]}, {}])
|
32
32
|
@command.expects(:say).at_least_once
|
@@ -33,7 +33,7 @@ class ShowSolutionCommandTest < Test::Unit::TestCase
|
|
33
33
|
assert_equal(@command.execute, 404)
|
34
34
|
end
|
35
35
|
|
36
|
-
should "show details about the
|
36
|
+
should "show details about the requested solution" do
|
37
37
|
time1 = (Time.now - 5).to_s
|
38
38
|
time2 = Time.now.to_s
|
39
39
|
@mock_client.expects(:get).with(EPC::Config::SOLUTIONS_PATH+"/1?include=config_values,projects,deployments,deployment_configs").
|
@@ -9,11 +9,6 @@ class ShowUserCommandTest < Test::Unit::TestCase
|
|
9
9
|
@command = EPC::Command::ShowUserCommand.new(@mock_client)
|
10
10
|
end
|
11
11
|
|
12
|
-
should "fail if no user is specified" do
|
13
|
-
@command.expects(:say).with("You need to specify a user id/email")
|
14
|
-
@command.expects(:say).with(EPC::Help::COMMAND_USAGES[:show_user])
|
15
|
-
assert_equal(@command.execute, 1)
|
16
|
-
end
|
17
12
|
|
18
13
|
should "fail if status is not 200" do
|
19
14
|
@mock_client.expects(:get).with(EPC::Config::USERS_PATH + "/1?include=user_groups").
|
@@ -22,14 +17,8 @@ class ShowUserCommandTest < Test::Unit::TestCase
|
|
22
17
|
assert_equal(@command.execute(1), 404)
|
23
18
|
end
|
24
19
|
|
25
|
-
should "
|
26
|
-
@command.expects(:
|
27
|
-
@command.expects(:say).with("User could not be found")
|
28
|
-
|
29
|
-
assert_equal(@command.execute("admin"), 1)
|
30
|
-
end
|
31
|
-
|
32
|
-
should "show a user specified by id" do
|
20
|
+
should "show a user" do
|
21
|
+
@command.expects(:retrieve_identifier_for).returns(1)
|
33
22
|
@mock_client.expects(:get).with(EPC::Config::USERS_PATH + "/1?include=user_groups").
|
34
23
|
returns([200, {:id => 1, :name => "admin", :user_groups => [{:id => 1, :name => "Administrators"}]}, {}])
|
35
24
|
@command.expects(:say).at_least_once
|
@@ -37,14 +26,5 @@ class ShowUserCommandTest < Test::Unit::TestCase
|
|
37
26
|
assert_equal(@command.execute(1), 200)
|
38
27
|
end
|
39
28
|
|
40
|
-
|
41
|
-
should "show a user specified by name" do
|
42
|
-
@command.expects(:get_resource_id).with(EPC::Config::USERS_PATH, :email, "admin").returns(1)
|
43
|
-
@mock_client.expects(:get).with(EPC::Config::USERS_PATH + "/1?include=user_groups").
|
44
|
-
returns([200, {}, {}])
|
45
|
-
@command.expects(:say)
|
46
|
-
|
47
|
-
assert_equal(@command.execute("admin"), 200)
|
48
|
-
end
|
49
29
|
end
|
50
30
|
end
|
@@ -9,12 +9,6 @@ class UpdateConfigCommandTest < Test::Unit::TestCase
|
|
9
9
|
@command = EPC::Command::UpdateConfigCommand.new(@mock_client)
|
10
10
|
end
|
11
11
|
|
12
|
-
should "fail if no key specified" do
|
13
|
-
@command.expects(:say).with("You have to specify a key and its value.")
|
14
|
-
assert_equal(@command.execute, 1)
|
15
|
-
end
|
16
|
-
|
17
|
-
|
18
12
|
should "fail if status code is not 200" do
|
19
13
|
@command.expects(:extract_configuration_level).returns(["Project", 1])
|
20
14
|
|
@@ -28,7 +22,7 @@ class UpdateConfigCommandTest < Test::Unit::TestCase
|
|
28
22
|
).returns([400, {:message => "Not Found"}, {}])
|
29
23
|
|
30
24
|
@command.expects("say").with("Request failed with message [Not Found]")
|
31
|
-
assert_equal(@command.execute("key1
|
25
|
+
assert_equal(@command.execute("key1", "", "value1"), 400)
|
32
26
|
|
33
27
|
end
|
34
28
|
|
@@ -41,7 +35,7 @@ class UpdateConfigCommandTest < Test::Unit::TestCase
|
|
41
35
|
{}])
|
42
36
|
|
43
37
|
@command.expects(:say).with("Key does not exist.")
|
44
|
-
assert_equal(@command.execute("key1
|
38
|
+
assert_equal(@command.execute("key1", "", "value1"), 1)
|
45
39
|
|
46
40
|
end
|
47
41
|
end
|
@@ -67,7 +61,7 @@ class UpdateConfigCommandTest < Test::Unit::TestCase
|
|
67
61
|
).returns([200, {:id => 1}, {}])
|
68
62
|
|
69
63
|
@command.expects(:say).with("key1 saved.")
|
70
|
-
assert_equal(@command.execute("key1
|
64
|
+
assert_equal(@command.execute("key1", "", "value1"), 200)
|
71
65
|
end
|
72
66
|
end
|
73
67
|
|