epc 1.0.2
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.
- data/CHANGELOG +1 -0
- data/Gemfile +22 -0
- data/Rakefile +67 -0
- data/Rakefile.gem +1 -0
- data/bin/epc +10 -0
- data/lib/epc.rb +126 -0
- data/lib/epc/client/base_client.rb +80 -0
- data/lib/epc/client/http_client.rb +19 -0
- data/lib/epc/client/json_client.rb +48 -0
- data/lib/epc/command/archive_project_command.rb +24 -0
- data/lib/epc/command/archive_solution_command.rb +21 -0
- data/lib/epc/command/attach_library_command.rb +82 -0
- data/lib/epc/command/attach_libraryset_command.rb +32 -0
- data/lib/epc/command/attach_runtime_command.rb +27 -0
- data/lib/epc/command/base_command.rb +451 -0
- data/lib/epc/command/bind_service_command.rb +35 -0
- data/lib/epc/command/build_command.rb +83 -0
- data/lib/epc/command/config/create_config_command.rb +55 -0
- data/lib/epc/command/copy_deployment_command.rb +21 -0
- data/lib/epc/command/create_command.rb +13 -0
- data/lib/epc/command/create_dependency_command.rb +43 -0
- data/lib/epc/command/define_service_command.rb +37 -0
- data/lib/epc/command/delete_config_command.rb +63 -0
- data/lib/epc/command/delete_dependency_command.rb +40 -0
- data/lib/epc/command/delete_group_command.rb +40 -0
- data/lib/epc/command/delete_library_command.rb +30 -0
- data/lib/epc/command/delete_librarylanguage_command.rb +40 -0
- data/lib/epc/command/delete_libraryset_command.rb +40 -0
- data/lib/epc/command/delete_project_command.rb +54 -0
- data/lib/epc/command/delete_role_command.rb +25 -0
- data/lib/epc/command/delete_serviceversion_command.rb +52 -0
- data/lib/epc/command/delete_solution_command.rb +39 -0
- data/lib/epc/command/delete_user_command.rb +31 -0
- data/lib/epc/command/deploy_command.rb +142 -0
- data/lib/epc/command/deployment/create_deployment_command.rb +82 -0
- data/lib/epc/command/detach_library_command.rb +35 -0
- data/lib/epc/command/detach_libraryset_command.rb +8 -0
- data/lib/epc/command/group/create_group_command.rb +21 -0
- data/lib/epc/command/info_command.rb +11 -0
- data/lib/epc/command/library/create_library_command.rb +45 -0
- data/lib/epc/command/librarylanguage/create_librarylanguage_command.rb +24 -0
- data/lib/epc/command/libraryset/create_libraryset_command.rb +54 -0
- data/lib/epc/command/list_approvals_command.rb +27 -0
- data/lib/epc/command/list_attachedlibraries_command.rb +42 -0
- data/lib/epc/command/list_boundservices_command.rb +40 -0
- data/lib/epc/command/list_config_command.rb +60 -0
- data/lib/epc/command/list_dependencies_command.rb +43 -0
- data/lib/epc/command/list_deployments_command.rb +68 -0
- data/lib/epc/command/list_groups_command.rb +19 -0
- data/lib/epc/command/list_libraries_command.rb +19 -0
- data/lib/epc/command/list_librarylanguages_command.rb +19 -0
- data/lib/epc/command/list_librarysets_command.rb +26 -0
- data/lib/epc/command/list_objectroles_command.rb +25 -0
- data/lib/epc/command/list_objecttypes_command.rb +20 -0
- data/lib/epc/command/list_permissiongroups_command.rb +20 -0
- data/lib/epc/command/list_projects_command.rb +36 -0
- data/lib/epc/command/list_projecttypes_command.rb +20 -0
- data/lib/epc/command/list_rolepermissions_command.rb +21 -0
- data/lib/epc/command/list_roles_command.rb +26 -0
- data/lib/epc/command/list_runtimes_command.rb +16 -0
- data/lib/epc/command/list_service_types_command.rb +19 -0
- data/lib/epc/command/list_servicedefinitions_command.rb +19 -0
- data/lib/epc/command/list_serviceversions_command.rb +21 -0
- data/lib/epc/command/list_solutions_command.rb +25 -0
- data/lib/epc/command/list_stages_command.rb +21 -0
- data/lib/epc/command/list_users_command.rb +26 -0
- data/lib/epc/command/list_versions_command.rb +39 -0
- data/lib/epc/command/login_command.rb +32 -0
- data/lib/epc/command/logout_command.rb +20 -0
- data/lib/epc/command/objectrole/create_objectrole_command.rb +19 -0
- data/lib/epc/command/project/create_project_command.rb +78 -0
- data/lib/epc/command/pull_command.rb +209 -0
- data/lib/epc/command/push_command.rb +194 -0
- data/lib/epc/command/refresh_solution_command.rb +71 -0
- data/lib/epc/command/renew_command.rb +19 -0
- data/lib/epc/command/request_passwordchange_command.rb +23 -0
- data/lib/epc/command/role/create_role_command.rb +17 -0
- data/lib/epc/command/serviceversion/create_serviceversion_command.rb +33 -0
- data/lib/epc/command/show_deployment_command.rb +57 -0
- data/lib/epc/command/show_group_command.rb +35 -0
- data/lib/epc/command/show_libraryset_command.rb +54 -0
- data/lib/epc/command/show_project_command.rb +74 -0
- data/lib/epc/command/show_projecttype_command.rb +18 -0
- data/lib/epc/command/show_role_command.rb +46 -0
- data/lib/epc/command/show_solution_command.rb +54 -0
- data/lib/epc/command/show_user_command.rb +42 -0
- data/lib/epc/command/solution/create_solution_command.rb +34 -0
- data/lib/epc/command/solution/list_solutions_command.rb +25 -0
- data/lib/epc/command/solution/update_solution_command.rb +43 -0
- data/lib/epc/command/submit_deployment_command.rb +19 -0
- data/lib/epc/command/target_command.rb +26 -0
- data/lib/epc/command/unarchive_project_command.rb +23 -0
- data/lib/epc/command/unarchive_solution_command.rb +21 -0
- data/lib/epc/command/unbind_service_command.rb +42 -0
- data/lib/epc/command/undefine_service_command.rb +33 -0
- data/lib/epc/command/undeploy_command.rb +106 -0
- data/lib/epc/command/update_config_command.rb +62 -0
- data/lib/epc/command/update_deploymentproject_command.rb +54 -0
- data/lib/epc/command/update_group_command.rb +43 -0
- data/lib/epc/command/update_librarylanguage_command.rb +28 -0
- data/lib/epc/command/update_libraryset_command.rb +80 -0
- data/lib/epc/command/update_project_command.rb +49 -0
- data/lib/epc/command/update_role_command.rb +47 -0
- data/lib/epc/command/update_rolepermissions_command.rb +83 -0
- data/lib/epc/command/update_solution_command.rb +45 -0
- data/lib/epc/command/update_user_command.rb +57 -0
- data/lib/epc/command/user/create_user_command.rb +27 -0
- data/lib/epc/command/vote_deployment_command.rb +29 -0
- data/lib/epc/config.rb +245 -0
- data/lib/epc/error/basic_error.rb +6 -0
- data/lib/epc/error/fatal_error.rb +6 -0
- data/lib/epc/error/input_error.rb +6 -0
- data/lib/epc/error/internal_error.rb +6 -0
- data/lib/epc/help.rb +292 -0
- data/lib/epc/persistent_attributes.rb +18 -0
- data/lib/epc/runner.rb +177 -0
- data/lib/epc/tabular_outputter.rb +161 -0
- data/lib/epc/version.rb +3 -0
- data/lib/fixnum.rb +9 -0
- data/lib/object.rb +13 -0
- data/test/command/archive_project_command_test.rb +41 -0
- data/test/command/archive_solution_command_test.rb +40 -0
- data/test/command/attach_library_command_test.rb +124 -0
- data/test/command/attach_libraryset_command_test.rb +49 -0
- data/test/command/attach_runtime_command_test.rb +44 -0
- data/test/command/base_command_test.rb +276 -0
- data/test/command/bind_service_command_test.rb +46 -0
- data/test/command/build_command_test.rb +103 -0
- data/test/command/copy_deployment_command_test.rb +38 -0
- data/test/command/create_config_command_test.rb +124 -0
- data/test/command/create_dependency_command_test.rb +55 -0
- data/test/command/create_deployment_command_test.rb +136 -0
- data/test/command/create_group_command_test.rb +34 -0
- data/test/command/create_library_command_test.rb +61 -0
- data/test/command/create_librarylanguage_command_test.rb +51 -0
- data/test/command/create_libraryset_command_test.rb +81 -0
- data/test/command/create_objectrole_command_test.rb +37 -0
- data/test/command/create_project_command_test.rb +102 -0
- data/test/command/create_role_command_test.rb +31 -0
- data/test/command/create_serviceversion_command_test.rb +60 -0
- data/test/command/create_solution_command_test.rb +70 -0
- data/test/command/create_user_command_test.rb +54 -0
- data/test/command/define_service_command_test.rb +55 -0
- data/test/command/delete_config_command_test.rb +82 -0
- data/test/command/delete_dependency_command_test.rb +50 -0
- data/test/command/delete_group_command_test.rb +56 -0
- data/test/command/delete_library_command_test.rb +43 -0
- data/test/command/delete_librarylanguage_command_test.rb +55 -0
- data/test/command/delete_libraryset_command_test.rb +55 -0
- data/test/command/delete_project_command_test.rb +76 -0
- data/test/command/delete_role_command_test.rb +41 -0
- data/test/command/delete_serviceversion_command_test.rb +53 -0
- data/test/command/delete_solution_command_test.rb +79 -0
- data/test/command/delete_user_command_test.rb +56 -0
- data/test/command/deploy_command_test.rb +185 -0
- data/test/command/detach_library_command_test.rb +53 -0
- data/test/command/info_command_test.rb +17 -0
- data/test/command/list_approvals_command_test.rb +41 -0
- data/test/command/list_boundservices_command_test.rb +46 -0
- data/test/command/list_config_command_test.rb +72 -0
- data/test/command/list_dependencies_command_test.rb +46 -0
- data/test/command/list_deployments_command_test.rb +112 -0
- data/test/command/list_deploymentstages_command_test.rb +44 -0
- data/test/command/list_libraries_command_test.rb +42 -0
- data/test/command/list_librarylanguages_command_test.rb +34 -0
- data/test/command/list_librarysets_command_test.rb +33 -0
- data/test/command/list_objectroles_command_test.rb +41 -0
- data/test/command/list_objecttypes_command_test.rb +25 -0
- data/test/command/list_permissiongroups_command_test.rb +25 -0
- data/test/command/list_projects_command_test.rb +63 -0
- data/test/command/list_projecttypes_command_test.rb +39 -0
- data/test/command/list_rolepermissions_command_test.rb +39 -0
- data/test/command/list_roles_command_test.rb +46 -0
- data/test/command/list_runtimes_command_test.rb +30 -0
- data/test/command/list_service_types_command_test.rb +44 -0
- data/test/command/list_servicedefinitions_command_test.rb +44 -0
- data/test/command/list_serviceversions_command_test.rb +47 -0
- data/test/command/list_solutions_command_test.rb +48 -0
- data/test/command/list_users_command_test.rb +33 -0
- data/test/command/login_command_test.rb +83 -0
- data/test/command/logout_command_test.rb +30 -0
- data/test/command/pull_command_test.rb +229 -0
- data/test/command/push_command_test.rb +246 -0
- data/test/command/refresh_solution_command_test.rb +35 -0
- data/test/command/renew_command_test.rb +43 -0
- data/test/command/request_passwordchange_command_test.rb +31 -0
- data/test/command/show_group_command_test.rb +50 -0
- data/test/command/show_libraryset_command_test.rb +51 -0
- data/test/command/show_project_command_test.rb +57 -0
- data/test/command/show_projecttype_command_test.rb +46 -0
- data/test/command/show_role_command_test.rb +37 -0
- data/test/command/show_solution_command_test.rb +59 -0
- data/test/command/show_user_command_test.rb +50 -0
- data/test/command/submit_deployment_command_test.rb +37 -0
- data/test/command/target_command_test.rb +58 -0
- data/test/command/unarchive_project_command_test.rb +45 -0
- data/test/command/unarchive_solution_command_test.rb +43 -0
- data/test/command/unbind_service_command_test.rb +48 -0
- data/test/command/undefine_service_command_test.rb +49 -0
- data/test/command/update_config_command_test.rb +74 -0
- data/test/command/update_deploymentproject_command_test.rb +77 -0
- data/test/command/update_group_command_test.rb +69 -0
- data/test/command/update_librarylanguage_command_test.rb +43 -0
- data/test/command/update_libraryset_command_test.rb +113 -0
- data/test/command/update_project_command_test.rb +56 -0
- data/test/command/update_role_command_test.rb +42 -0
- data/test/command/update_rolepermissions_command_test.rb +54 -0
- data/test/command/update_solution_command_test.rb +58 -0
- data/test/command/update_user_command_test.rb +76 -0
- data/test/command/vote_deployment_command_test.rb +33 -0
- data/test/config_test.rb +70 -0
- data/test/successful_test.rb +21 -0
- data/test/test_files/pom.xml +273 -0
- data/test/test_helper.rb +25 -0
- metadata +470 -0
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ListLibrarylanguagesCommandTest < 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::ListLibrarylanguagesCommand.new(@mock_client)
|
11
|
+
end
|
12
|
+
|
13
|
+
should "fail if status is not 200(ok)" do
|
14
|
+
@mock_client.expects(:get).with(EPC::Config::LIBRARY_LANGUAGES_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 languages are created" do
|
20
|
+
@mock_client.expects(:get).with(EPC::Config::LIBRARY_LANGUAGES_PATH).returns([200, {}, {}])
|
21
|
+
@command.expects(:say).with("No languages created")
|
22
|
+
@command.expects(:say).with("You can create one with epc create library-language")
|
23
|
+
assert_equal 200, @command.execute
|
24
|
+
end
|
25
|
+
|
26
|
+
should "list users" do
|
27
|
+
|
28
|
+
@mock_client.expects(:get).with(EPC::Config::LIBRARY_LANGUAGES_PATH).returns([200, [{:id => 1, :name => "ruby"}, {:id => 2, :name => "java"}], {}])
|
29
|
+
@command.expects(:say)
|
30
|
+
assert_equal 200, @command.execute
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ListLibrarysetsCommandTest < 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::ListLibrarysetsCommand.new(@mock_client)
|
11
|
+
end
|
12
|
+
|
13
|
+
should "fail if status is not 200(ok)" do
|
14
|
+
@mock_client.expects(:get).with(EPC::Config::LIBRARY_SETS_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 sets are created" do
|
20
|
+
@mock_client.expects(:get).with(EPC::Config::LIBRARY_SETS_PATH).returns([200, {}, {}])
|
21
|
+
@command.expects(:say).with("No sets created")
|
22
|
+
@command.expects(:say).with("You can create one with epc create library-set")
|
23
|
+
assert_equal 200, @command.execute
|
24
|
+
end
|
25
|
+
|
26
|
+
should "list sets" do
|
27
|
+
@mock_client.expects(:get).with(EPC::Config::LIBRARY_SETS_PATH).returns([200, [{:id => 1, :name => "ruby"}, {:id => 2, :name => "java"}], {}])
|
28
|
+
@command.expects(:say)
|
29
|
+
assert_equal 200, @command.execute
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ListObjectrolesCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execute" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::ListObjectrolesCommand.new(@mock_client)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "raise exception if no parameters are given" do
|
13
|
+
assert_raise EPC::Error::FatalError do
|
14
|
+
@command.execute
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
should "raise exception if parameters are incorrect" do
|
19
|
+
assert_raise EPC::Error::FatalError do
|
20
|
+
@command.execute("Solution")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
should "show a message if status is not 200" do
|
25
|
+
@mock_client.expects(:get).with(EPC::Config::ROLES_PATH + "/for_object/Solution/1").
|
26
|
+
returns([404, {:message => "Not Found"}, {}])
|
27
|
+
|
28
|
+
@command.expects(:say).with("Request failed: [Not Found]")
|
29
|
+
assert_equal(@command.execute("Solution:1"), 404)
|
30
|
+
end
|
31
|
+
|
32
|
+
should "list roles" do
|
33
|
+
@mock_client.expects(:get).with(EPC::Config::ROLES_PATH + "/for_object/Solution/1").
|
34
|
+
returns([200, [{:id => 1, :name => "SuperAdmin"}, {:id => 2, :name => "Admin"}], {}])
|
35
|
+
|
36
|
+
@command.expects(:say)
|
37
|
+
assert_equal(@command.execute("Solution:1"), 200)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ListObjecttypesCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execution" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::ListObjecttypesCommand.new(@mock_client)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "show reason for request failure" do
|
13
|
+
@mock_client.expects(:get).with(EPC::Config::OBJECT_TYPES_PATH).returns([500, {:message => "System Exception"}, {}])
|
14
|
+
@command.expects(:say).with("Request failed: [System Exception]")
|
15
|
+
assert_equal(@command.execute, 500)
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
should "list object-types" do
|
20
|
+
@mock_client.expects(:get).with(EPC::Config::OBJECT_TYPES_PATH).returns([200, [], {}])
|
21
|
+
@command.expects(:say)
|
22
|
+
assert_equal(@command.execute, 200)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ListPermissiongroupsCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execution" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::ListPermissiongroupsCommand.new(@mock_client)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "show reason for request failure" do
|
13
|
+
@mock_client.expects(:get).with(EPC::Config::PERMISSIONS_PATH).returns([500, {:message => "System Exception"}, {}])
|
14
|
+
@command.expects(:say).with("Request failed: [System Exception]")
|
15
|
+
assert_equal(@command.execute, 500)
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
should "list permission-groups" do
|
20
|
+
@mock_client.expects(:get).with(EPC::Config::PERMISSIONS_PATH).returns([200, [], {}])
|
21
|
+
@command.expects(:say)
|
22
|
+
assert_equal(@command.execute, 200)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ListProjectsCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "pre-execution checks" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::ListProjectsCommand.new(@mock_client)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "fail if solution id can't be determined" do
|
13
|
+
@command.expects(:infer_solution_context).returns(nil)
|
14
|
+
@command.expects(:say).with("Solution could not be inferred")
|
15
|
+
@command.expects(:say).with(EPC::Help::COMMAND_USAGES[:list_projects])
|
16
|
+
|
17
|
+
|
18
|
+
assert_equal(@command.execute("FirstSolution"), 1)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "list projects" do
|
23
|
+
setup do
|
24
|
+
@mock_client = mock("Client")
|
25
|
+
|
26
|
+
@command = EPC::Command::ListProjectsCommand.new(@mock_client)
|
27
|
+
@command.expects(:infer_solution_context).returns([1, "FirstSolution"])
|
28
|
+
end
|
29
|
+
|
30
|
+
should "show exception message status is not 201" do
|
31
|
+
@mock_client.expects(:get).with(EPC::Config::SOLUTIONS_PATH + "/1/projects").
|
32
|
+
returns([400, {:message => "Not Found"}, {}])
|
33
|
+
@command.expects(:say).with("Projects retrieval failed with [Not Found]")
|
34
|
+
|
35
|
+
assert_equal(@command.execute, 400)
|
36
|
+
end
|
37
|
+
|
38
|
+
should "show a message if there are no projects" do
|
39
|
+
|
40
|
+
@mock_client.expects(:get).with(EPC::Config::SOLUTIONS_PATH + "/1/projects").
|
41
|
+
returns([200, {}, {}])
|
42
|
+
|
43
|
+
@command.expects(:say).returns("You have no projects created.You can create them with epc create project.")
|
44
|
+
|
45
|
+
assert_equal(@command.execute, 200)
|
46
|
+
end
|
47
|
+
|
48
|
+
should "list available projects" do
|
49
|
+
@mock_client.expects(:get).with(EPC::Config::SOLUTIONS_PATH + "/1/projects").
|
50
|
+
returns([200,
|
51
|
+
[
|
52
|
+
{:id => 1, :name => "Project1", :last_build_status => "failed", :project_type => {:id => 1, :name => "JAVA"} },
|
53
|
+
{:id => 2, :name => "Project2", :last_build_status => "built", :project_type => {:id => 2, :name => "Ruby" }}],
|
54
|
+
{}])
|
55
|
+
|
56
|
+
|
57
|
+
@command.expects(:say).at_least_once
|
58
|
+
|
59
|
+
assert_equal(@command.execute, 200)
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ListProjecttypesCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "list project types" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::ListProjecttypesCommand.new(@mock_client)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "show exception message status is not 201" do
|
13
|
+
@mock_client.expects(:get).with(EPC::Config::PROJECT_TYPES_PATH).
|
14
|
+
returns([400, {:message => "Not Found"}, {}])
|
15
|
+
@command.expects(:say).with("Request failed: [Not Found]")
|
16
|
+
|
17
|
+
assert_equal(@command.execute, 400)
|
18
|
+
end
|
19
|
+
|
20
|
+
should "output the results" do
|
21
|
+
@mock_client.expects(:get).with(EPC::Config::PROJECT_TYPES_PATH).
|
22
|
+
returns([200, [{:id => 1, :name => "JS"}, {:id => 2, :name => "Ruby on Rails"}], {}])
|
23
|
+
|
24
|
+
@command.expects(:say)
|
25
|
+
|
26
|
+
assert_equal(@command.execute, 200)
|
27
|
+
end
|
28
|
+
|
29
|
+
should "notify if there are no types defined" do
|
30
|
+
@mock_client.expects(:get).with(EPC::Config::PROJECT_TYPES_PATH).
|
31
|
+
returns([200, [], {}])
|
32
|
+
|
33
|
+
@command.expects(:say).with("No project types defined")
|
34
|
+
|
35
|
+
assert_equal(@command.execute, 200)
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ListRolepermissionsCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execute" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::ListRolepermissionsCommand.new(@mock_client)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "show a message if status is not 200" do
|
13
|
+
@mock_client.expects(:get).with(EPC::Config::PERMISSIONS_PATH).
|
14
|
+
returns([404, {:message => "Not Found"}, {}])
|
15
|
+
|
16
|
+
@command.expects(:say).with("Request failed: [Not Found]")
|
17
|
+
assert_equal(@command.execute, 404)
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
should "show a message if no permissions are defined" do
|
22
|
+
@mock_client.expects(:get).with(EPC::Config::PERMISSIONS_PATH).
|
23
|
+
returns([200, {}, {}])
|
24
|
+
|
25
|
+
@command.expects(:say).with("No permissions defined")
|
26
|
+
assert_equal(@command.execute, 200)
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
should "list roles" do
|
31
|
+
@mock_client.expects(:get).with(EPC::Config::PERMISSIONS_PATH).
|
32
|
+
returns([200, [{}], {}])
|
33
|
+
|
34
|
+
@command.expects(:say)
|
35
|
+
assert_equal(@command.execute, 200)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ListRolesCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execute" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::ListRolesCommand.new(@mock_client)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "show a message if status is not 200" do
|
13
|
+
@mock_client.expects(:get).with(EPC::Config::ROLES_PATH + "?system_roles=true").
|
14
|
+
returns([404, {:message => "Not Found"}, {}])
|
15
|
+
|
16
|
+
@command.expects(:say).with("Request failed: [Not Found]")
|
17
|
+
assert_equal(@command.execute, 404)
|
18
|
+
end
|
19
|
+
|
20
|
+
should "show a message if no roles are defined" do
|
21
|
+
@mock_client.expects(:get).with(EPC::Config::ROLES_PATH + "?system_roles=true").
|
22
|
+
returns([200, {}, {}])
|
23
|
+
|
24
|
+
@command.expects(:say).with("No roles defined")
|
25
|
+
assert_equal(@command.execute, 200)
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
should "list roles" do
|
30
|
+
@mock_client.expects(:get).with(EPC::Config::ROLES_PATH + "?system_roles=true").
|
31
|
+
returns([200, [{:id => 1, :name => "SuperAdmin"}, {:id => 2, :name => "Admin"}], {}])
|
32
|
+
|
33
|
+
@command.expects(:say)
|
34
|
+
assert_equal(@command.execute, 200)
|
35
|
+
end
|
36
|
+
|
37
|
+
should "retrieve roles for the user when --user is specified" do
|
38
|
+
@command.options[:user] = 1
|
39
|
+
@mock_client.expects(:get).with(EPC::Config::USERS_PATH + "/1?include=roles").
|
40
|
+
returns([200, {:roles => [{:id => 1, :name => "SuperAdmin"}, {:id => 2, :name => "Admin"}]}, {}])
|
41
|
+
@command.expects(:say)
|
42
|
+
assert_equal(@command.execute, 200)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ListRuntimesCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "list runtimes" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
|
10
|
+
@command = EPC::Command::ListRuntimesCommand.new(@mock_client)
|
11
|
+
end
|
12
|
+
|
13
|
+
should "show exception message status is not 201" do
|
14
|
+
@mock_client.expects(:get).with(EPC::Config::RUNTIMES_PATH).
|
15
|
+
returns([400, {'message' => "Not Found"}, {}])
|
16
|
+
@command.expects(:say).with("Request failed with: [Not Found]")
|
17
|
+
|
18
|
+
assert_equal(@command.execute, 400)
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
should "display the runtimes" do
|
23
|
+
@mock_client.expects(:get).with(EPC::Config::RUNTIMES_PATH).
|
24
|
+
returns([200, [], {}])
|
25
|
+
@command.expects(:say)
|
26
|
+
|
27
|
+
assert_equal(@command.execute, 200)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ListServicetypesCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "list service types" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
|
10
|
+
@command = EPC::Command::ListServicetypesCommand.new(@mock_client)
|
11
|
+
end
|
12
|
+
|
13
|
+
should "show exception message status is not 201" do
|
14
|
+
@mock_client.expects(:get).with(EPC::Config::SERVICE_TYPES_PATH).
|
15
|
+
returns([400, {:message => "Not Found"}, {}])
|
16
|
+
@command.expects(:say).with("Service types retrieval failed with [Not Found]")
|
17
|
+
|
18
|
+
assert_equal(@command.execute, 400)
|
19
|
+
end
|
20
|
+
|
21
|
+
should "show a message if there are no service types" do
|
22
|
+
|
23
|
+
@mock_client.expects(:get).with(EPC::Config::SERVICE_TYPES_PATH).
|
24
|
+
returns([200, {}, {}])
|
25
|
+
|
26
|
+
@command.expects(:say).returns("There are no service types available")
|
27
|
+
|
28
|
+
assert_equal(@command.execute, 200)
|
29
|
+
end
|
30
|
+
|
31
|
+
should "list available service types" do
|
32
|
+
@mock_client.expects(:get).with(EPC::Config::SERVICE_TYPES_PATH).
|
33
|
+
returns([200,
|
34
|
+
[
|
35
|
+
{:id => 1, :name => "MongoDB"},
|
36
|
+
{:id => 2, :name => "MySQL"}],
|
37
|
+
{}])
|
38
|
+
|
39
|
+
@command.expects(:say).at_least_once
|
40
|
+
assert_equal(@command.execute, 200)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ListServicedefinitionsCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "list services" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::ListServicedefinitionsCommand.new(@mock_client)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "show exception message status is not 200" do
|
13
|
+
@mock_client.expects(:get).with(EPC::Config::SERVICE_DEFINITIONS_PATH).
|
14
|
+
returns([400, {'message' => "Not Found"}, {}])
|
15
|
+
@command.expects(:say).with("Request failed with: [Not Found]")
|
16
|
+
|
17
|
+
assert_equal(@command.execute, 400)
|
18
|
+
end
|
19
|
+
|
20
|
+
should "show a message if there are no service definitions" do
|
21
|
+
|
22
|
+
@mock_client.expects(:get).with(EPC::Config::SERVICE_DEFINITIONS_PATH).
|
23
|
+
returns([200, {}, {}])
|
24
|
+
|
25
|
+
@command.expects(:say).returns("No service definitions found. You can define one with #{EPC::Help::COMMAND_USAGES[:define_service]}")
|
26
|
+
|
27
|
+
assert_equal(@command.execute, 200)
|
28
|
+
end
|
29
|
+
|
30
|
+
should "list available service definitions" do
|
31
|
+
@mock_client.expects(:get).with(EPC::Config::SERVICE_DEFINITIONS_PATH).
|
32
|
+
returns([200,
|
33
|
+
[
|
34
|
+
{:id => 1, :name => "dev_mysql", :service_type => {:id => 1, :name => "MySQL"} },
|
35
|
+
{:id => 2, :name => "mongodb_instance", :service_type => {:id => 1, :name => "MongoDB"} }],
|
36
|
+
{}])
|
37
|
+
|
38
|
+
|
39
|
+
@command.expects(:say).at_least_once
|
40
|
+
assert_equal(@command.execute, 200)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|