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,42 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class UpdateRoleCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execution" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::UpdateRoleCommand.new(@mock_client)
|
10
|
+
@command.expects(:retrieve_system_role_identifier).returns(1)
|
11
|
+
end
|
12
|
+
|
13
|
+
should "add a user to a role" do
|
14
|
+
@command.options[:add_user] = "1"
|
15
|
+
|
16
|
+
@mock_client.expects(:put).with(EPC::Config::ROLES_PATH + "/1/assign_members", {:role_memberships => [{:member_id => 1, :member_type => "User"}]}).
|
17
|
+
returns([200, {}, {}])
|
18
|
+
@command.expects(:say).with("User added to role")
|
19
|
+
assert_equal(@command.execute(1), 200)
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
should "remove a user from a role" do
|
24
|
+
@command.options[:remove_user] = 1
|
25
|
+
|
26
|
+
@mock_client.expects(:delete).with(EPC::Config::ROLES_PATH + "/1/remove_member", {:member_id => 1, :member_type => "User"}).
|
27
|
+
returns([200, {}, {}])
|
28
|
+
@command.expects(:say).with("User removed from role")
|
29
|
+
assert_equal(@command.execute(1), 200)
|
30
|
+
end
|
31
|
+
|
32
|
+
should "notify on failure" do
|
33
|
+
@command.options[:add_user] = "1"
|
34
|
+
|
35
|
+
@mock_client.expects(:put).with(EPC::Config::ROLES_PATH + "/1/assign_members", {:role_memberships => [{:member_id => 1, :member_type => "User"}]}).
|
36
|
+
returns([404, {:message => "Not Found"}, {}])
|
37
|
+
@command.expects(:say).with("Request failed: [Not Found]")
|
38
|
+
assert_equal(@command.execute(1), 404)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class UpdateRolepermissionsCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execution" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::UpdateRolepermissionsCommand.new(@mock_client)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "fail if no role specified" do
|
13
|
+
assert_raise EPC::Error::FatalError do
|
14
|
+
@command.execute
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
should "fail if grant incorrectly specified" do
|
19
|
+
@command.options[:add_grant] = "Solution"
|
20
|
+
assert_raise EPC::Error::FatalError do
|
21
|
+
@command.execute(1)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "adding grants" do
|
26
|
+
setup do
|
27
|
+
@command.options[:add_grant] = "Solution:create"
|
28
|
+
end
|
29
|
+
|
30
|
+
should "show reason for request failure" do
|
31
|
+
@mock_client.expects(:post).
|
32
|
+
with(EPC::Config::GRANTS_PATH, {:grant_action => "create",
|
33
|
+
:permitted_type => "Role",
|
34
|
+
:permitted_id => 1,
|
35
|
+
:secured_type => "Solution"}).
|
36
|
+
returns([500, {:message => "System exception"}, {}])
|
37
|
+
@command.expects(:say).with("Request failed: [System exception]")
|
38
|
+
@command.execute(1)
|
39
|
+
end
|
40
|
+
|
41
|
+
should "notify of success" do
|
42
|
+
@mock_client.expects(:post).
|
43
|
+
with(EPC::Config::GRANTS_PATH, {:grant_action => "create",
|
44
|
+
:permitted_type => "Role",
|
45
|
+
:permitted_id => 1,
|
46
|
+
:secured_type => "Solution"}).
|
47
|
+
returns([200, {}, {}])
|
48
|
+
@command.expects(:say).with("Role permission updated")
|
49
|
+
@command.execute(1)
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class UpdateSolutionCommandTest < 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::UpdateSolutionCommand.new(@mock_client)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "fail if solution id can't be determined" do
|
13
|
+
assert_raise EPC::Error::FatalError do
|
14
|
+
assert_equal @command.execute, 1
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
context "updating" do
|
21
|
+
setup do
|
22
|
+
@mock_client = mock("Client")
|
23
|
+
@command = EPC::Command::UpdateSolutionCommand.new(@mock_client)
|
24
|
+
@command.expects(:infer_solution_context).returns([1, "FirstSolution"])
|
25
|
+
end
|
26
|
+
|
27
|
+
should "read options from a file if specified" do
|
28
|
+
@command.options[:file] = "attr_file"
|
29
|
+
EPC::Config.expects(:read_content_as_json).with("attr_file").returns({"name" => "UpdatedSolution"})
|
30
|
+
@mock_client.expects(:put).returns([200, {}, {}])
|
31
|
+
@command.expects(:say).with("Update succesful")
|
32
|
+
assert_equal(@command.execute, 200)
|
33
|
+
end
|
34
|
+
|
35
|
+
should "only update the allowed attributes" do
|
36
|
+
@command.expects(:say).with("Cannot update unallowed_attribute. Updatable attributes are: #{EPC::Command::UpdateSolutionCommand::UPDATABLE_ATTRIBUTES.join(",")}")
|
37
|
+
@command.execute("unallowed_attribute=value")
|
38
|
+
end
|
39
|
+
|
40
|
+
should "show a message if request is unsuccesful" do
|
41
|
+
@mock_client.expects(:put).with(EPC::Config::SOLUTIONS_PATH+"/1", {'name' => "new_name"}).
|
42
|
+
returns([400, {'message' => "Not Found"}, {}])
|
43
|
+
@command.expects(:say).with("Update failed with: [Not Found]")
|
44
|
+
|
45
|
+
assert_equal(@command.execute("name=new_name"), 400)
|
46
|
+
end
|
47
|
+
|
48
|
+
should "update the solution attributes" do
|
49
|
+
@mock_client.expects(:put).with(EPC::Config::SOLUTIONS_PATH+"/1", {'name' => "new_name"}).
|
50
|
+
returns([200, {}, {}])
|
51
|
+
@command.expects(:say).with("Update succesful")
|
52
|
+
|
53
|
+
assert_equal(@command.execute("name=new_name"), 200)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class UpdateUserCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "password change" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::UpdateUserCommand.new(@mock_client)
|
10
|
+
@command.options[:password] = "1234567890"
|
11
|
+
end
|
12
|
+
|
13
|
+
should "fail if no user identifier specified" do
|
14
|
+
assert_raise EPC::Error::FatalError do
|
15
|
+
@command.execute
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
should "fail if email can't be determined" do
|
20
|
+
@command.expects(:get_resource_attribute).returns(nil)
|
21
|
+
assert_raise EPC::Error::FatalError do
|
22
|
+
@command.execute(1)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
should "fail if token parameter is not specified" do
|
27
|
+
assert_nil @command.options[:token]
|
28
|
+
assert_raise EPC::Error::FatalError do
|
29
|
+
@command.execute("user@epaas.com")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
should "show reason for failure when status is unsuccessful" do
|
34
|
+
@command.options[:token] = "1213445"
|
35
|
+
@mock_client.expects(:put).with(EPC::Config::USERS_PATH + "/user@epaas.com/change_password", {:token => '1213445', :password => "1234567890"}).returns([500, {:message => "system exception"}, {}])
|
36
|
+
@command.expects(:say).with("Request failed: [system exception]")
|
37
|
+
@command.execute("user@epaas.com")
|
38
|
+
end
|
39
|
+
|
40
|
+
should "change the password" do
|
41
|
+
@command.options[:token] = "1213445"
|
42
|
+
@mock_client.expects(:put).with(EPC::Config::USERS_PATH + "/user@epaas.com/change_password", {:token => '1213445', :password => "1234567890"}).returns([200, {}, {}])
|
43
|
+
@command.expects(:say).with("Password change successful")
|
44
|
+
@command.execute("user@epaas.com")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "email/name change" do
|
49
|
+
setup do
|
50
|
+
@mock_client = mock("Client")
|
51
|
+
@command = EPC::Command::UpdateUserCommand.new(@mock_client)
|
52
|
+
@command.options[:email] = "user2@epaas.com"
|
53
|
+
@command.options[:name] = "user2"
|
54
|
+
end
|
55
|
+
|
56
|
+
should "fail if user_id can't be determined" do
|
57
|
+
@command.expects(:get_resource_id).returns(nil)
|
58
|
+
assert_raise EPC::Error::FatalError do
|
59
|
+
@command.execute("user@epaas.com")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
should "show reason for failure when status is unsuccessful" do
|
64
|
+
@mock_client.expects(:put).with(EPC::Config::USERS_PATH + "/1", {:name => 'user2', :email => "user2@epaas.com"}).returns([500, {:message => "system exception"}, {}])
|
65
|
+
@command.expects(:say).with("Request failed: [system exception]")
|
66
|
+
@command.execute(1)
|
67
|
+
end
|
68
|
+
|
69
|
+
should "update the attributes" do
|
70
|
+
@mock_client.expects(:put).with(EPC::Config::USERS_PATH + "/1", {:name => 'user2', :email => "user2@epaas.com"}).returns([200, {}, {}])
|
71
|
+
@command.expects(:say).with("User updated")
|
72
|
+
@command.execute(1)
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class VoteDeploymentCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "voting" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::VoteDeploymentCommand.new(@mock_client, {:approval => "approve"})
|
10
|
+
end
|
11
|
+
|
12
|
+
should "fail if deployment id can't be determined" do
|
13
|
+
@command.expects(:say).with("You must specify a deployment id.")
|
14
|
+
@command.expects(:say).with("epc approve deployment <DEPLOYMENT_ID>")
|
15
|
+
assert_equal @command.execute, 1
|
16
|
+
end
|
17
|
+
|
18
|
+
should "show a message if status is not 200" do
|
19
|
+
@mock_client.expects(:put).with(EPC::Config::DEPLOYMENTS_PATH + "/1/vote", {:approved => true}).
|
20
|
+
returns([400, {:message => "Not Found"}, {}])
|
21
|
+
@command.expects(:say).with("Request failed: [Not Found]")
|
22
|
+
assert_equal(@command.execute(1), 400)
|
23
|
+
end
|
24
|
+
|
25
|
+
should "cast a vote for the deployment" do
|
26
|
+
@mock_client.expects(:put).with(EPC::Config::DEPLOYMENTS_PATH + "/1/vote", {:approved => true}).
|
27
|
+
returns([200, {}, {}])
|
28
|
+
@command.expects(:say).with("Deployment [1] has been approved by you.")
|
29
|
+
assert_equal(@command.execute(1), 200)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
data/test/config_test.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
class ConfigTest < Test::Unit::TestCase
|
5
|
+
context "target url management" do
|
6
|
+
setup do
|
7
|
+
EPC::Config.target_file = '~/.epc_test_target'
|
8
|
+
end
|
9
|
+
|
10
|
+
teardown do
|
11
|
+
file = File.expand_path(EPC::Config.target_file)
|
12
|
+
FileUtils.rm(file) if File.exists?(file)
|
13
|
+
end
|
14
|
+
|
15
|
+
should "manage the target url" do
|
16
|
+
EPC::Config.store_target_url("http://here/is/my/target")
|
17
|
+
assert_equal("http://here/is/my/target", EPC::Config.target_url)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "caller id management" do
|
22
|
+
setup do
|
23
|
+
EPC::Config.caller_file = '~/.epc_test_caller'
|
24
|
+
end
|
25
|
+
|
26
|
+
teardown do
|
27
|
+
file = File.expand_path(EPC::Config.caller_file)
|
28
|
+
FileUtils.rm(file) if File.exists?(file)
|
29
|
+
end
|
30
|
+
|
31
|
+
should "manage the caller id" do
|
32
|
+
EPC::Config.store_caller_id("a0b1-c2d3-e4f5")
|
33
|
+
assert_equal("a0b1-c2d3-e4f5", EPC::Config.caller_id)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "auth token management" do
|
38
|
+
setup do
|
39
|
+
EPC::Config.token_file = '~/.epc_test_token'
|
40
|
+
end
|
41
|
+
|
42
|
+
teardown do
|
43
|
+
file = File.expand_path(EPC::Config.token_file)
|
44
|
+
FileUtils.rm(file) if File.exists?(file)
|
45
|
+
end
|
46
|
+
|
47
|
+
should "manage the auth token" do
|
48
|
+
EPC::Config.auth_token = nil
|
49
|
+
EPC::Config.store_auth_token("aaabb111222")
|
50
|
+
assert_equal("aaabb111222", EPC::Config.auth_token)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context "username management" do
|
55
|
+
setup do
|
56
|
+
EPC::Config.username_file = '~/.epc_test_username'
|
57
|
+
end
|
58
|
+
|
59
|
+
teardown do
|
60
|
+
file = File.expand_path(EPC::Config.username_file)
|
61
|
+
FileUtils.rm(file) if File.exists?(file)
|
62
|
+
end
|
63
|
+
|
64
|
+
should "manage the target url" do
|
65
|
+
EPC::Config.store_username("user@domain.com")
|
66
|
+
assert_equal("user@domain.com", EPC::Config.username)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'lib/object'
|
3
|
+
require 'lib/fixnum'
|
4
|
+
|
5
|
+
class SuccessfulTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
should "be true if in the 200 range" do
|
8
|
+
assert 200.successful?
|
9
|
+
assert 201.successful?
|
10
|
+
assert 299.successful?
|
11
|
+
end
|
12
|
+
|
13
|
+
should "be false otherwise" do
|
14
|
+
assert !400.successful?
|
15
|
+
assert !nil.successful?
|
16
|
+
assert !true.successful?
|
17
|
+
assert !false.successful?
|
18
|
+
assert !1.successful?
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,273 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
3
|
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
4
|
+
<modelVersion>4.0.0</modelVersion>
|
5
|
+
<groupId>org.springframework.samples</groupId>
|
6
|
+
<artifactId>travel</artifactId>
|
7
|
+
<name>travel</name>
|
8
|
+
<packaging>war</packaging>
|
9
|
+
<version>1.0.0-BUILD-SNAPSHOT</version>
|
10
|
+
<properties>
|
11
|
+
<java-version>1.6</java-version>
|
12
|
+
<org.springwebflow-version>2.2.1.RELEASE</org.springwebflow-version>
|
13
|
+
<org.springsecurity-version>3.0.5.RELEASE</org.springsecurity-version>
|
14
|
+
<org.aspectj-version>1.6.9</org.aspectj-version>
|
15
|
+
<org.cloudfoundry-version>0.8.1</org.cloudfoundry-version>
|
16
|
+
<org.slf4j-version>1.6.1</org.slf4j-version>
|
17
|
+
<org.springframework-version>3.1.0.M2</org.springframework-version>
|
18
|
+
</properties>
|
19
|
+
<dependencies>
|
20
|
+
|
21
|
+
<!-- cloudfoundry-->
|
22
|
+
<dependency>
|
23
|
+
<groupId>org.cloudfoundry</groupId>
|
24
|
+
<artifactId>cloudfoundry-runtime</artifactId>
|
25
|
+
<version>0.8.1</version>
|
26
|
+
</dependency>
|
27
|
+
|
28
|
+
|
29
|
+
<!-- Spring -->
|
30
|
+
|
31
|
+
|
32
|
+
<dependency>
|
33
|
+
<groupId>org.springframework</groupId>
|
34
|
+
<artifactId>spring-context</artifactId>
|
35
|
+
<version>3.1.0.M2</version>
|
36
|
+
</dependency>
|
37
|
+
<dependency>
|
38
|
+
<groupId>mysql</groupId>
|
39
|
+
<artifactId>mysql-connector-java</artifactId>
|
40
|
+
<version>5.0.5</version>
|
41
|
+
</dependency>
|
42
|
+
<dependency>
|
43
|
+
<groupId>org.springframework</groupId>
|
44
|
+
<artifactId>spring-jdbc</artifactId>
|
45
|
+
<version>3.1.0.M2</version>
|
46
|
+
</dependency>
|
47
|
+
<dependency>
|
48
|
+
<groupId>org.springframework</groupId>
|
49
|
+
<artifactId>spring-orm</artifactId>
|
50
|
+
<version>3.1.0.M2</version>
|
51
|
+
</dependency>
|
52
|
+
<dependency>
|
53
|
+
<groupId>org.springframework</groupId>
|
54
|
+
<artifactId>spring-web</artifactId>
|
55
|
+
<version>3.1.0.M2</version>
|
56
|
+
</dependency>
|
57
|
+
<dependency>
|
58
|
+
<groupId>org.springframework</groupId>
|
59
|
+
<artifactId>spring-webmvc</artifactId>
|
60
|
+
<version>3.1.0.M2</version>
|
61
|
+
</dependency>
|
62
|
+
<dependency>
|
63
|
+
<groupId>org.springframework.webflow</groupId>
|
64
|
+
<artifactId>spring-webflow</artifactId>
|
65
|
+
<version>2.2.1.RELEASE</version>
|
66
|
+
</dependency>
|
67
|
+
<dependency>
|
68
|
+
<groupId>org.springframework.webflow</groupId>
|
69
|
+
<artifactId>spring-js</artifactId>
|
70
|
+
<version>2.2.1.RELEASE</version>
|
71
|
+
</dependency>
|
72
|
+
<dependency>
|
73
|
+
<groupId>org.springframework.security</groupId>
|
74
|
+
<artifactId>spring-security-web</artifactId>
|
75
|
+
<version>3.0.5.RELEASE</version>
|
76
|
+
</dependency>
|
77
|
+
<dependency>
|
78
|
+
<groupId>org.springframework.security</groupId>
|
79
|
+
<artifactId>spring-security-taglibs</artifactId>
|
80
|
+
<version>3.0.5.RELEASE</version>
|
81
|
+
</dependency>
|
82
|
+
<dependency>
|
83
|
+
<groupId>org.springframework.security</groupId>
|
84
|
+
<artifactId>spring-security-config</artifactId>
|
85
|
+
<version>3.0.5.RELEASE</version>
|
86
|
+
</dependency>
|
87
|
+
|
88
|
+
<!-- RESTful support-->
|
89
|
+
<dependency>
|
90
|
+
<groupId>jaxen</groupId>
|
91
|
+
<artifactId>jaxen</artifactId>
|
92
|
+
<version>1.1.1</version>
|
93
|
+
</dependency>
|
94
|
+
<dependency>
|
95
|
+
<groupId>org.springframework</groupId>
|
96
|
+
<artifactId>spring-oxm</artifactId>
|
97
|
+
<version>3.1.0.M2</version>
|
98
|
+
</dependency>
|
99
|
+
<dependency>
|
100
|
+
<groupId>org.codehaus.jackson</groupId>
|
101
|
+
<artifactId>jackson-mapper-asl</artifactId>
|
102
|
+
<version>1.4.2</version>
|
103
|
+
</dependency>
|
104
|
+
<dependency>
|
105
|
+
<groupId>com.sun.xml.bind</groupId>
|
106
|
+
<artifactId>jaxb-impl</artifactId>
|
107
|
+
<version>2.1.7</version>
|
108
|
+
</dependency>
|
109
|
+
<!-- AspectJ -->
|
110
|
+
<dependency>
|
111
|
+
<groupId>org.aspectj</groupId>
|
112
|
+
<artifactId>aspectjrt</artifactId>
|
113
|
+
<version>1.6.9</version>
|
114
|
+
</dependency>
|
115
|
+
|
116
|
+
<!-- Logging -->
|
117
|
+
<dependency>
|
118
|
+
<groupId>org.slf4j</groupId>
|
119
|
+
<artifactId>slf4j-api</artifactId>
|
120
|
+
<version>1.6.1</version>
|
121
|
+
</dependency>
|
122
|
+
<dependency>
|
123
|
+
<groupId>org.slf4j</groupId>
|
124
|
+
<artifactId>jcl-over-slf4j</artifactId>
|
125
|
+
<version>1.6.1</version>
|
126
|
+
</dependency>
|
127
|
+
<dependency>
|
128
|
+
<groupId>org.slf4j</groupId>
|
129
|
+
<artifactId>slf4j-log4j12</artifactId>
|
130
|
+
<version>1.6.1</version>
|
131
|
+
<scope>runtime</scope>
|
132
|
+
</dependency>
|
133
|
+
<dependency>
|
134
|
+
<groupId>log4j</groupId>
|
135
|
+
<artifactId>log4j</artifactId>
|
136
|
+
<version>1.2.16</version>
|
137
|
+
<scope>runtime</scope>
|
138
|
+
</dependency>
|
139
|
+
|
140
|
+
<!-- @Inject -->
|
141
|
+
<dependency>
|
142
|
+
<groupId>javax.inject</groupId>
|
143
|
+
<artifactId>javax.inject</artifactId>
|
144
|
+
<version>1</version>
|
145
|
+
</dependency>
|
146
|
+
|
147
|
+
<!-- Database -->
|
148
|
+
<dependency>
|
149
|
+
<groupId>org.hsqldb</groupId>
|
150
|
+
<artifactId>hsqldb</artifactId>
|
151
|
+
<version>1.8.0.10</version>
|
152
|
+
<scope>runtime</scope>
|
153
|
+
</dependency>
|
154
|
+
|
155
|
+
<!-- Servlet -->
|
156
|
+
<dependency>
|
157
|
+
<groupId>javax.servlet</groupId>
|
158
|
+
<artifactId>servlet-api</artifactId>
|
159
|
+
<version>2.5</version>
|
160
|
+
<scope>provided</scope>
|
161
|
+
</dependency>
|
162
|
+
<dependency>
|
163
|
+
<groupId>javax.servlet.jsp</groupId>
|
164
|
+
<artifactId>jsp-api</artifactId>
|
165
|
+
<version>2.1</version>
|
166
|
+
<scope>provided</scope>
|
167
|
+
</dependency>
|
168
|
+
<dependency>
|
169
|
+
<groupId>javax.servlet</groupId>
|
170
|
+
<artifactId>jstl</artifactId>
|
171
|
+
<version>1.2</version>
|
172
|
+
</dependency>
|
173
|
+
|
174
|
+
<!-- Apache Tiles -->
|
175
|
+
<dependency>
|
176
|
+
<groupId>org.apache.tiles</groupId>
|
177
|
+
<artifactId>tiles-jsp</artifactId>
|
178
|
+
<version>2.2.2</version>
|
179
|
+
</dependency>
|
180
|
+
|
181
|
+
<!-- Hibernate JPA 2 Provider -->
|
182
|
+
<dependency>
|
183
|
+
<groupId>org.hibernate</groupId>
|
184
|
+
<artifactId>hibernate-entitymanager</artifactId>
|
185
|
+
<version>3.6.0.Final</version>
|
186
|
+
</dependency>
|
187
|
+
|
188
|
+
<!-- JSR 303 with Hibernate Validator -->
|
189
|
+
<dependency>
|
190
|
+
<groupId>javax.validation</groupId>
|
191
|
+
<artifactId>validation-api</artifactId>
|
192
|
+
<version>1.0.0.GA</version>
|
193
|
+
</dependency>
|
194
|
+
<dependency>
|
195
|
+
<groupId>org.hibernate</groupId>
|
196
|
+
<artifactId>hibernate-validator</artifactId>
|
197
|
+
<version>4.1.0.Final</version>
|
198
|
+
</dependency>
|
199
|
+
|
200
|
+
<!-- Joda Time -->
|
201
|
+
<dependency>
|
202
|
+
<groupId>joda-time</groupId>
|
203
|
+
<artifactId>joda-time</artifactId>
|
204
|
+
<version>1.6.2</version>
|
205
|
+
</dependency>
|
206
|
+
<dependency>
|
207
|
+
<groupId>joda-time</groupId>
|
208
|
+
<artifactId>joda-time-jsptags</artifactId>
|
209
|
+
<version>1.0.2</version>
|
210
|
+
<scope>runtime</scope>
|
211
|
+
</dependency>
|
212
|
+
|
213
|
+
<!-- Test -->
|
214
|
+
<dependency>
|
215
|
+
<groupId>org.easymock</groupId>
|
216
|
+
<artifactId>easymock</artifactId>
|
217
|
+
<version>2.5.2</version>
|
218
|
+
<scope>test</scope>
|
219
|
+
</dependency>
|
220
|
+
<dependency>
|
221
|
+
<groupId>junit</groupId>
|
222
|
+
<artifactId>junit</artifactId>
|
223
|
+
<version>4.7</version>
|
224
|
+
<scope>test</scope>
|
225
|
+
</dependency>
|
226
|
+
<dependency>
|
227
|
+
<groupId>org.springframework</groupId>
|
228
|
+
<artifactId>spring-test</artifactId>
|
229
|
+
<version>3.1.0.M2</version>
|
230
|
+
<scope>test</scope>
|
231
|
+
</dependency>
|
232
|
+
</dependencies>
|
233
|
+
<repositories>
|
234
|
+
<!-- For testing against latest Spring snapshots -->
|
235
|
+
<repository>
|
236
|
+
<id>org.springframework.maven.snapshot</id>
|
237
|
+
<name>Spring Maven Snapshot Repository</name>
|
238
|
+
<url>http://maven.springframework.org/snapshot</url>
|
239
|
+
<releases>
|
240
|
+
<enabled>false</enabled>
|
241
|
+
</releases>
|
242
|
+
<snapshots>
|
243
|
+
<enabled>true</enabled>
|
244
|
+
</snapshots>
|
245
|
+
</repository>
|
246
|
+
<!-- For developing against latest Spring milestones -->
|
247
|
+
<repository>
|
248
|
+
<id>org.springframework.maven.milestone</id>
|
249
|
+
<name>Spring Maven Milestone Repository</name>
|
250
|
+
<url>http://maven.springframework.org/milestone</url>
|
251
|
+
<snapshots>
|
252
|
+
<enabled>false</enabled>
|
253
|
+
</snapshots>
|
254
|
+
</repository>
|
255
|
+
<!-- For Roo -->
|
256
|
+
<repository>
|
257
|
+
<id>spring-roo-repository</id>
|
258
|
+
<name>Spring Roo Repository</name>
|
259
|
+
<url>http://spring-roo-repository.springsource.org/release</url>
|
260
|
+
</repository>
|
261
|
+
<!-- For Hibernate -->
|
262
|
+
<repository>
|
263
|
+
<id>org.jboss.repository.releases</id>
|
264
|
+
<name>JBoss Maven Release Repository</name>
|
265
|
+
<url>https://repository.jboss.org/nexus/content/repositories/releases</url>
|
266
|
+
<snapshots>
|
267
|
+
<enabled>false</enabled>
|
268
|
+
</snapshots>
|
269
|
+
</repository>
|
270
|
+
</repositories>
|
271
|
+
<build>
|
272
|
+
</build>
|
273
|
+
</project>
|