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,57 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ShowProjectCommandTest < 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::ShowProjectCommand.new(@mock_client)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "fail if project type can't be determined" do
|
13
|
+
assert_raise EPC::Error::FatalError do
|
14
|
+
@command.expects(:infer_project_context).returns(nil)
|
15
|
+
assert_equal(@command.execute, 1)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "retrieval " do
|
21
|
+
setup do
|
22
|
+
@mock_client = mock("Client")
|
23
|
+
@command = EPC::Command::ShowProjectCommand.new(@mock_client)
|
24
|
+
@command.expects(:infer_project_context).returns([1, "FirstProject"])
|
25
|
+
end
|
26
|
+
|
27
|
+
should "notify if retrieval fails" do
|
28
|
+
@mock_client.expects(:get).returns([404, {:message => "Not Found"}, {}])
|
29
|
+
@command.expects(:say).with("Request failed: [Not Found]")
|
30
|
+
assert_equal(@command.execute, 404)
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
should "show details about the requested project" do
|
35
|
+
time = Time.now.to_s
|
36
|
+
@mock_client.expects(:get).with(EPC::Config::PROJECTS_PATH+"/1?include=dependencies,roles,config_values").
|
37
|
+
returns(
|
38
|
+
[
|
39
|
+
200,
|
40
|
+
{
|
41
|
+
:id => 1, :name => "Project1", :uri_name => "project1", :solution_id => 1, :service_version_id => 1, :created_at => Time.now, :last_push_date => Time.now, :last_push_by => {:id => 1, :name => "PusherName"},
|
42
|
+
:config_values => [{:id => 1, :name => "N1", :value => "V1"}],
|
43
|
+
:roles => [{:id => 1, :name => "role 1"}],
|
44
|
+
:dependency_definitions => [{:dependency_id => 1, :dependency => {:id => 1, :name => "dep_name"}, :dependency_kind => "dep_kind"}]
|
45
|
+
},
|
46
|
+
{}
|
47
|
+
]
|
48
|
+
)
|
49
|
+
|
50
|
+
Time.expects(:parse).at_least_once.returns(Time.now)
|
51
|
+
@command.expects(:say).at_least_once
|
52
|
+
assert_equal(@command.execute, 200)
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require File.expand_path "../../../lib/epc", __FILE__
|
2
|
+
require "test/unit"
|
3
|
+
require 'shoulda'
|
4
|
+
require 'mocha'
|
5
|
+
|
6
|
+
class ShowProjecttypeCommandTest < Test::Unit::TestCase
|
7
|
+
should_require_login
|
8
|
+
|
9
|
+
context "pre-execution checks" do
|
10
|
+
setup do
|
11
|
+
@mock_client = mock("Client")
|
12
|
+
@command = EPC::Command::ShowProjecttypeCommand.new(@mock_client)
|
13
|
+
end
|
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
|
+
end
|
21
|
+
|
22
|
+
context "retrieval " do
|
23
|
+
setup do
|
24
|
+
@mock_client = mock("Client")
|
25
|
+
@command = EPC::Command::ShowProjecttypeCommand.new(@mock_client)
|
26
|
+
end
|
27
|
+
|
28
|
+
should "show error if status is not 201" do
|
29
|
+
@mock_client.expects(:get).with(EPC::Config::PROJECT_TYPES_PATH+"/1").
|
30
|
+
returns([404, {:message => "Not Found"}, {}])
|
31
|
+
|
32
|
+
@command.expects(:say).with("Request failed: [Not Found]")
|
33
|
+
assert_equal(@command.execute(1), 404)
|
34
|
+
end
|
35
|
+
|
36
|
+
should "show details about the request solution" do
|
37
|
+
@mock_client.expects(:get).with(EPC::Config::PROJECT_TYPES_PATH+"/1").
|
38
|
+
returns([200, {:id => 1, :name => "JS", :runtime => "js", :framework => "node", :build_type => "build"}, {}])
|
39
|
+
|
40
|
+
@command.expects(:say).at_least_once
|
41
|
+
assert_equal(@command.execute(1), 200)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ShowRoleCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execute" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::ShowRoleCommand.new(@mock_client)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "fail if status is not 200" do
|
13
|
+
@mock_client.expects(:get).with(EPC::Config::ROLES_PATH + "/1?include=users,user_groups,grants").
|
14
|
+
returns([404, {:message => "Not Found"}, {}])
|
15
|
+
@command.expects(:say).with("Request failed: [Not Found]")
|
16
|
+
assert_equal(@command.execute(1), 1)
|
17
|
+
end
|
18
|
+
|
19
|
+
should "show a role specified by id" do
|
20
|
+
@mock_client.expects(:get).with(EPC::Config::ROLES_PATH + "/1?include=users,user_groups,grants").
|
21
|
+
returns([200, {}, {}])
|
22
|
+
@command.expects(:say).at_least_once
|
23
|
+
|
24
|
+
assert_equal(@command.execute(1), 200)
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
should "show a role specified by name" do
|
29
|
+
@command.expects(:retrieve_system_role_identifier).returns(1)
|
30
|
+
@mock_client.expects(:get).with(EPC::Config::ROLES_PATH + "/1?include=users,user_groups,grants").
|
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
|
+
@command.expects(:say).at_least_once
|
33
|
+
|
34
|
+
assert_equal(@command.execute("admin"), 200)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require File.expand_path "../../../lib/epc", __FILE__
|
2
|
+
require "test/unit"
|
3
|
+
require 'shoulda'
|
4
|
+
require 'mocha'
|
5
|
+
|
6
|
+
class ShowSolutionCommandTest < Test::Unit::TestCase
|
7
|
+
should_require_login
|
8
|
+
|
9
|
+
context "pre-execution checks" do
|
10
|
+
setup do
|
11
|
+
@mock_client = mock("Client")
|
12
|
+
@command = EPC::Command::ShowSolutionCommand.new(@mock_client)
|
13
|
+
end
|
14
|
+
|
15
|
+
should "fail if solution can't be determined" do
|
16
|
+
assert_raise EPC::Error::InputError do
|
17
|
+
@command.expects(:infer_solution_context).returns(nil)
|
18
|
+
assert_equal(@command.execute, 1)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "retrieval " do
|
24
|
+
setup do
|
25
|
+
@mock_client = mock("Client")
|
26
|
+
@command = EPC::Command::ShowSolutionCommand.new(@mock_client)
|
27
|
+
@command.expects(:infer_solution_context).returns([1, "FirstSolution"])
|
28
|
+
end
|
29
|
+
|
30
|
+
should "notify if retrieval fails" do
|
31
|
+
@mock_client.expects(:get).returns([404, {:message => "Not Found"}, {}])
|
32
|
+
@command.expects(:say).with("Request failed: [Not Found]")
|
33
|
+
assert_equal(@command.execute, 404)
|
34
|
+
end
|
35
|
+
|
36
|
+
should "show details about the request solution" do
|
37
|
+
time1 = (Time.now - 5).to_s
|
38
|
+
time2 = Time.now.to_s
|
39
|
+
@mock_client.expects(:get).with(EPC::Config::SOLUTIONS_PATH+"/1?include=config_values,projects,deployments,deployment_configs").
|
40
|
+
returns(
|
41
|
+
[
|
42
|
+
200,
|
43
|
+
{:id => 1, :name => "Solution1", :updated_at => time1,
|
44
|
+
:projects =>[
|
45
|
+
{:id => 1, :name => "Project1", :last_build_status => true, :updated_at => time2, :current_version_number => 3, :builds => [
|
46
|
+
{:id => 1, :built => true, :current_version_number => 5}]}],
|
47
|
+
:deployments => [{:updated_at => time2, :deployment_stage_name => "development"}]
|
48
|
+
},
|
49
|
+
{}
|
50
|
+
]
|
51
|
+
)
|
52
|
+
|
53
|
+
@command.expects(:say).at_least_once
|
54
|
+
assert_equal(@command.execute, 200)
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ShowUserCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execute" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::ShowUserCommand.new(@mock_client)
|
10
|
+
end
|
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
|
+
|
18
|
+
should "fail if status is not 200" do
|
19
|
+
@mock_client.expects(:get).with(EPC::Config::USERS_PATH + "/1?include=user_groups").
|
20
|
+
returns([404, {:message => "Not Found"}, {}])
|
21
|
+
@command.expects(:say).with("Request failed: [Not Found]")
|
22
|
+
assert_equal(@command.execute(1), 404)
|
23
|
+
end
|
24
|
+
|
25
|
+
should "fail if user_id can't be determined" do
|
26
|
+
@command.expects(:get_resource_id).with(EPC::Config::USERS_PATH, :email, "admin").returns(nil)
|
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
|
33
|
+
@mock_client.expects(:get).with(EPC::Config::USERS_PATH + "/1?include=user_groups").
|
34
|
+
returns([200, {:id => 1, :name => "admin", :user_groups => [{:id => 1, :name => "Administrators"}]}, {}])
|
35
|
+
@command.expects(:say).at_least_once
|
36
|
+
|
37
|
+
assert_equal(@command.execute(1), 200)
|
38
|
+
end
|
39
|
+
|
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
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class SubmitDeploymentCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execution" do
|
7
|
+
should "report error if deployment_id is nil" do
|
8
|
+
command = EPC::Command::SubmitDeploymentCommand.new(@mock_client)
|
9
|
+
command.expects(:say).with("You must specify a deployment id")
|
10
|
+
command.expects(:say).with(EPC::Help::COMMAND_USAGES[:submit_deployment])
|
11
|
+
command.execute(nil)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context "submitting" do
|
16
|
+
setup do
|
17
|
+
@mock_client = mock("Client")
|
18
|
+
@command = EPC::Command::SubmitDeploymentCommand.new(@mock_client)
|
19
|
+
end
|
20
|
+
|
21
|
+
should "submit the deployment if the status is 200" do
|
22
|
+
@mock_client.expects(:put).with("/api/v1/deployments/1/submit").
|
23
|
+
returns([200, {:id => 1}, {}])
|
24
|
+
|
25
|
+
@command.expects(:say).with("Deployment submitted for approval")
|
26
|
+
assert_equal(@command.execute("1"), 200)
|
27
|
+
end
|
28
|
+
|
29
|
+
should "report failure if the status is not 200" do
|
30
|
+
|
31
|
+
@mock_client.expects(:put).with("/api/v1/deployments/1/submit").
|
32
|
+
returns([404, { :message => "Not Found"}, {}])
|
33
|
+
@command.expects(:say).with("Request failed: [Not Found]")
|
34
|
+
assert_equal(@command.execute("1"), 404)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TargetCommandTest < Test::Unit::TestCase
|
4
|
+
context "execute" do
|
5
|
+
setup do
|
6
|
+
@mock_client = mock("Client")
|
7
|
+
EPC::Config.target_file = '~/.epc_test_target'
|
8
|
+
@command = EPC::Command::TargetCommand.new(@mock_client)
|
9
|
+
end
|
10
|
+
|
11
|
+
teardown do
|
12
|
+
file = File.expand_path(EPC::Config.target_file)
|
13
|
+
FileUtils.rm(file) if File.exists?(file)
|
14
|
+
|
15
|
+
EPC::Config.target_url = nil
|
16
|
+
end
|
17
|
+
|
18
|
+
should "print the target if not arguments supplied" do
|
19
|
+
EPC::Config.store_target_url ("http://www.example.com")
|
20
|
+
@command.expects(:say).with("TARGET: http://www.example.com")
|
21
|
+
assert_equal(@command.execute, 1)
|
22
|
+
end
|
23
|
+
|
24
|
+
should "store a valid http URL" do
|
25
|
+
@mock_client.expects(:get).returns([200, {}, {}])
|
26
|
+
@command.expects(:say).with("Successfully targeted to [http://www.example.com]")
|
27
|
+
@command.execute("http://www.example.com")
|
28
|
+
assert_equal("http://www.example.com", EPC::Config.target_url)
|
29
|
+
end
|
30
|
+
|
31
|
+
should "store a valid https URL" do
|
32
|
+
@mock_client.expects(:get).returns([200, {}, {}])
|
33
|
+
@command.expects(:say).with("Successfully targeted to [https://www.example.com]")
|
34
|
+
@command.execute("https://www.example.com")
|
35
|
+
assert_equal("https://www.example.com", EPC::Config.target_url)
|
36
|
+
end
|
37
|
+
|
38
|
+
should "store a valid URL with no protocol" do
|
39
|
+
@mock_client.expects(:get).returns([200, {}, {}])
|
40
|
+
@command.expects(:say).with("Successfully targeted to [http://www.example.com]")
|
41
|
+
@command.execute("www.example.com")
|
42
|
+
assert_equal("http://www.example.com", EPC::Config.target_url)
|
43
|
+
end
|
44
|
+
|
45
|
+
should "store a valid URL with trailing slash removed" do
|
46
|
+
@mock_client.expects(:get).returns([200, {}, {}])
|
47
|
+
@command.expects(:say).with("Successfully targeted to [http://www.example.com]")
|
48
|
+
@command.execute("http://www.example.com/")
|
49
|
+
assert_equal("http://www.example.com", EPC::Config.target_url)
|
50
|
+
end
|
51
|
+
|
52
|
+
should "not store an invalid URL" do
|
53
|
+
@command.expects(:say).with("The URL you entered [http://www.example com] is not valid. Please try again.")
|
54
|
+
@command.execute("http://www.example com/")
|
55
|
+
assert_equal("http://#{EPC::Config::DEFAULT_TARGET}", EPC::Config.target_url)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.expand_path "../../../lib/epc", __FILE__
|
2
|
+
require "test/unit"
|
3
|
+
require 'shoulda'
|
4
|
+
require 'mocha'
|
5
|
+
|
6
|
+
class UnarchiveProjectCommandTest < Test::Unit::TestCase
|
7
|
+
context "pre-execution checks" do
|
8
|
+
setup do
|
9
|
+
@mock_client = mock("Client")
|
10
|
+
@command = EPC::Command::UnarchiveProjectCommand.new(@mock_client)
|
11
|
+
end
|
12
|
+
|
13
|
+
should "fail if no project specified" do
|
14
|
+
assert_raise EPC::Error::FatalError do
|
15
|
+
@command.execute
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "archiving" do
|
21
|
+
setup do
|
22
|
+
@mock_client = mock("Client")
|
23
|
+
@command = EPC::Command::UnarchiveProjectCommand.new(@mock_client)
|
24
|
+
@command.expects(:infer_solution_context).returns([1, "FirstSolution"])
|
25
|
+
@command.expects(:infer_project_context).returns([1, "FirstProject"])
|
26
|
+
end
|
27
|
+
|
28
|
+
should "fail if status is not 201" do
|
29
|
+
@mock_client.expects(:put).with(EPC::Config::PROJECTS_PATH + "/1", {:archived => false}).
|
30
|
+
returns([404, {:message => "Not Found"}, {}])
|
31
|
+
|
32
|
+
@command.expects(:say).with("Project could not be unarchived. Request failed with: [Not Found]")
|
33
|
+
assert_equal(@command.execute, 404)
|
34
|
+
end
|
35
|
+
|
36
|
+
should "archive the project" do
|
37
|
+
@mock_client.expects(:put).with(EPC::Config::PROJECTS_PATH + "/1", {:archived => false}).
|
38
|
+
returns([200, {}, {}])
|
39
|
+
|
40
|
+
@command.expects(:say).with("Project has been unarchived.")
|
41
|
+
assert_equal(@command.execute, 200)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.expand_path "../../../lib/epc", __FILE__
|
2
|
+
require "test/unit"
|
3
|
+
require 'shoulda'
|
4
|
+
require 'mocha'
|
5
|
+
|
6
|
+
class UnarchiveSolutionCommandTest < Test::Unit::TestCase
|
7
|
+
context "pre-execution checks" do
|
8
|
+
setup do
|
9
|
+
@mock_client = mock("Client")
|
10
|
+
@command = EPC::Command::UnarchiveSolutionCommand.new(@mock_client)
|
11
|
+
end
|
12
|
+
|
13
|
+
should "fail if no solution specified" do
|
14
|
+
assert_raise EPC::Error::FatalError do
|
15
|
+
@command.execute
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
context "archiving" do
|
20
|
+
setup do
|
21
|
+
@mock_client = mock("Client")
|
22
|
+
@command = EPC::Command::UnarchiveSolutionCommand.new(@mock_client)
|
23
|
+
@command.expects(:infer_solution_context).returns([1, "FirstSolution"])
|
24
|
+
end
|
25
|
+
|
26
|
+
should "fail if status is not 201" do
|
27
|
+
@mock_client.expects(:put).with(EPC::Config::SOLUTIONS_PATH + "/1", {:archived => false, :name => "FirstSolution"}).
|
28
|
+
returns([400, {:message => "Not Found"}, {}])
|
29
|
+
|
30
|
+
@command.expects(:say).with("Solution could not be unarchived. Request failed with: [Not Found]")
|
31
|
+
assert_equal(@command.execute, 400)
|
32
|
+
end
|
33
|
+
|
34
|
+
should "archive the solution" do
|
35
|
+
@mock_client.expects(:put).with(EPC::Config::SOLUTIONS_PATH + "/1", {:archived => false, :name => "FirstSolution"}).
|
36
|
+
returns([200, {}, {}])
|
37
|
+
|
38
|
+
@command.expects(:say).with("Solution has been unarchived.")
|
39
|
+
assert_equal(@command.execute, 200)
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class UnbindServiceCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execute" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::UnbindServiceCommand.new(@mock_client)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "fail if service version not specified" do
|
13
|
+
@command.expects(:say).with("You must specify the service version to be unbound.")
|
14
|
+
@command.expects(:say).with(EPC::Help::COMMAND_USAGES[:unbind_service])
|
15
|
+
|
16
|
+
assert_equal(@command.execute, 1)
|
17
|
+
end
|
18
|
+
|
19
|
+
should "fail if service version id cannot be determined" do
|
20
|
+
@command.expects(:infer_project_context).returns([nil, nil])
|
21
|
+
@command.expects(:get_resource_id).with(EPC::Config::SERVICE_VERSIONS_PATH, :label, "main_db").returns(nil)
|
22
|
+
|
23
|
+
@command.expects(:say).with("Project or service incorrectly specified.")
|
24
|
+
@command.expects(:say).with(EPC::Help::COMMAND_USAGES[:unbind_service])
|
25
|
+
|
26
|
+
assert_equal(@command.execute("main_db"), 1)
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
should "fail if status is not 200" do
|
31
|
+
@command.expects(:infer_project_context).returns([1, "FirstProject"])
|
32
|
+
@mock_client.expects(:delete).with(EPC::Config::PROJECTS_PATH + "/1/remove_service_version/1").
|
33
|
+
returns([404, {:message => "Not Found"}, {}])
|
34
|
+
@command.expects(:say).with("Request failed: [Not Found]")
|
35
|
+
|
36
|
+
assert_equal(@command.execute(1), 404)
|
37
|
+
end
|
38
|
+
|
39
|
+
should "unbind the service from the project" do
|
40
|
+
@command.expects(:infer_project_context).returns([1, "FirstProject"])
|
41
|
+
@mock_client.expects(:delete).with(EPC::Config::PROJECTS_PATH + "/1/remove_service_version/1").
|
42
|
+
returns([200, {}, {}])
|
43
|
+
@command.expects(:say).with("Service version unbound.")
|
44
|
+
|
45
|
+
assert_equal(@command.execute(1), 200)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|