epc 1.0.3 → 1.0.4
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/lib/epc.rb +25 -5
- data/lib/epc/client/json_client.rb +4 -4
- data/lib/epc/command/archive_command.rb +7 -6
- data/lib/epc/command/attachto_command.rb +13 -0
- data/lib/epc/command/base_command.rb +120 -29
- data/lib/epc/command/config/create_config_command.rb +7 -11
- data/lib/epc/command/config/delete_config_command.rb +5 -5
- data/lib/epc/command/config/list_configs_command.rb +5 -5
- data/lib/epc/command/config/update_config_command.rb +11 -10
- data/lib/epc/command/copy_command.rb +14 -0
- data/lib/epc/command/create_command.rb +9 -5
- data/lib/epc/command/delete_command.rb +9 -9
- data/lib/epc/command/{copy_deployment_command.rb → deployment/copy_deployment_command.rb} +6 -5
- data/lib/epc/command/deployment/create_deployment_command.rb +15 -15
- data/lib/epc/command/deployment/list_deployments_command.rb +2 -4
- data/lib/epc/command/deployment/show_deployment_command.rb +5 -7
- data/lib/epc/command/deployment/submit_deployment_command.rb +15 -0
- data/lib/epc/command/deployment/update_deployment_command.rb +5 -14
- data/lib/epc/command/deployment/vote_deployment_command.rb +23 -0
- data/lib/epc/command/deploymentstage/list_deploymentstages_command.rb +1 -1
- data/lib/epc/command/detachfrom_command.rb +13 -0
- data/lib/epc/command/group/create_group_command.rb +3 -3
- data/lib/epc/command/group/delete_group_command.rb +4 -5
- data/lib/epc/command/group/show_group_command.rb +2 -3
- data/lib/epc/command/group/update_group_command.rb +9 -7
- data/lib/epc/command/library/create_library_command.rb +1 -2
- data/lib/epc/command/library/delete_library_command.rb +4 -5
- data/lib/epc/command/library/list_libraries_command.rb +1 -1
- data/lib/epc/command/librarylanguage/create_librarylanguage_command.rb +1 -1
- data/lib/epc/command/librarylanguage/delete_librarylanguage_command.rb +3 -5
- data/lib/epc/command/librarylanguage/list_librarylanguages_command.rb +1 -1
- data/lib/epc/command/librarylanguage/update_librarylanguage_command.rb +4 -5
- data/lib/epc/command/libraryset/create_libraryset_command.rb +5 -4
- data/lib/epc/command/libraryset/delete_libraryset_command.rb +4 -6
- data/lib/epc/command/libraryset/list_librarysets_command.rb +2 -2
- data/lib/epc/command/libraryset/show_libraryset_command.rb +3 -3
- data/lib/epc/command/libraryset/update_libraryset_command.rb +4 -3
- data/lib/epc/command/list_command.rb +10 -14
- data/lib/epc/command/list_objecttypes_command.rb +1 -1
- data/lib/epc/command/objectrole/create_objectrole_command.rb +4 -5
- data/lib/epc/command/objectrole/list_objectroles_command.rb +3 -8
- data/lib/epc/command/objectrole/update_objectrole_command.rb +3 -1
- data/lib/epc/command/permission/list_permissions_command.rb +1 -1
- data/lib/epc/command/permissiongroup/list_permissiongroups_command.rb +1 -1
- data/lib/epc/command/plugin/create_plugin_command.rb +1 -2
- data/lib/epc/command/plugin/delete_plugin_command.rb +4 -6
- data/lib/epc/command/plugin/list_plugins_command.rb +1 -1
- data/lib/epc/command/plugin/show_plugin_command.rb +2 -5
- data/lib/epc/command/plugin/update_plugin_command.rb +2 -6
- data/lib/epc/command/project/archive_project_command.rb +3 -12
- data/lib/epc/command/project/attachto_project_command.rb +133 -0
- data/lib/epc/command/project/create_project_command.rb +6 -6
- data/lib/epc/command/project/delete_project_command.rb +3 -24
- data/lib/epc/command/project/detachfrom_project_command.rb +66 -0
- data/lib/epc/command/project/list_projects_command.rb +12 -7
- data/lib/epc/command/project/show_project_command.rb +26 -25
- data/lib/epc/command/project/show_project_snapshot_command.rb +41 -0
- data/lib/epc/command/project/unarchive_project_command.rb +3 -10
- data/lib/epc/command/project/update_project_command.rb +5 -18
- data/lib/epc/command/projecttype/create_projecttype_command.rb +37 -0
- data/lib/epc/command/projecttype/delete_projecttype_command.rb +24 -0
- data/lib/epc/command/projecttype/list_projecttypes_command.rb +1 -1
- data/lib/epc/command/projecttype/show_projecttype_command.rb +2 -4
- data/lib/epc/command/projecttype/update_projecttype_command.rb +61 -0
- data/lib/epc/command/push_command.rb +14 -8
- data/lib/epc/command/role/create_role_command.rb +26 -3
- data/lib/epc/command/role/delete_role_command.rb +3 -5
- data/lib/epc/command/role/list_roles_command.rb +7 -3
- data/lib/epc/command/role/show_role_command.rb +8 -5
- data/lib/epc/command/role/update_role_command.rb +14 -66
- data/lib/epc/command/runtime/create_runtime_command.rb +34 -0
- data/lib/epc/command/runtime/delete_runtime_command.rb +24 -0
- data/lib/epc/command/runtime/list_runtimes_command.rb +2 -2
- data/lib/epc/command/runtime/update_runtime_command.rb +49 -0
- data/lib/epc/command/runtimetype/list_runtimetypes_command.rb +17 -0
- data/lib/epc/command/servicedefinition/create_servicedefinition_command.rb +5 -6
- data/lib/epc/command/servicedefinition/delete_servicedefinition_command.rb +18 -0
- data/lib/epc/command/servicedefinition/list_servicedefinitions_command.rb +2 -2
- data/lib/epc/command/servicetype/list_servicetypes_command.rb +1 -1
- data/lib/epc/command/serviceversion/create_serviceversion_command.rb +8 -12
- data/lib/epc/command/serviceversion/delete_serviceversion_command.rb +3 -5
- data/lib/epc/command/serviceversion/list_serviceversions_command.rb +8 -1
- data/lib/epc/command/show_command.rb +8 -9
- data/lib/epc/command/show_metrics_command.rb +3 -3
- data/lib/epc/command/solution/archive_solution_command.rb +3 -10
- data/lib/epc/command/solution/create_solution_command.rb +2 -2
- data/lib/epc/command/solution/delete_solution_command.rb +3 -7
- data/lib/epc/command/solution/list_solutions_command.rb +11 -3
- data/lib/epc/command/solution/show_solution_command.rb +4 -6
- data/lib/epc/command/solution/unarchive_solution_command.rb +3 -8
- data/lib/epc/command/solution/update_solution_command.rb +4 -6
- data/lib/epc/command/submit_command.rb +16 -0
- data/lib/epc/command/unarchive_command.rb +7 -6
- data/lib/epc/command/update_command.rb +9 -8
- data/lib/epc/command/user/create_user_command.rb +2 -3
- data/lib/epc/command/user/delete_user_command.rb +3 -5
- data/lib/epc/command/user/list_users_command.rb +1 -1
- data/lib/epc/command/user/show_user_command.rb +2 -4
- data/lib/epc/command/user/update_user_command.rb +3 -14
- data/lib/epc/command/userproperty/list_user_properties_command.rb +23 -0
- data/lib/epc/command/vote_command.rb +16 -0
- data/lib/epc/config.rb +7 -1
- data/lib/epc/help.rb +51 -48
- data/lib/epc/modules/config.rb +39 -0
- data/lib/epc/modules/role.rb +133 -0
- data/lib/epc/runner.rb +23 -12
- data/lib/epc/version.rb +1 -1
- data/test/command/archive_project_command_test.rb +2 -13
- data/test/command/archive_solution_command_test.rb +4 -14
- data/test/command/copy_deployment_command_test.rb +4 -8
- data/test/command/create_config_command_test.rb +23 -23
- data/test/command/create_deployment_command_test.rb +33 -32
- data/test/command/create_group_command_test.rb +2 -2
- data/test/command/create_library_command_test.rb +6 -6
- data/test/command/create_librarylanguage_command_test.rb +3 -3
- data/test/command/create_libraryset_command_test.rb +6 -26
- data/test/command/create_objectrole_command_test.rb +4 -13
- data/test/command/create_project_command_test.rb +27 -13
- data/test/command/create_role_command_test.rb +3 -2
- data/test/command/create_runtime_command_test.rb +37 -0
- data/test/command/create_servicedefinition_command_test.rb +4 -17
- data/test/command/create_serviceversion_command_test.rb +8 -22
- data/test/command/create_solution_command_test.rb +5 -5
- data/test/command/create_user_command_test.rb +4 -4
- data/test/command/delete_config_command_test.rb +8 -15
- data/test/command/delete_library_command_test.rb +3 -4
- data/test/command/delete_librarylanguage_command_test.rb +3 -4
- data/test/command/delete_libraryset_command_test.rb +3 -4
- data/test/command/delete_plugin_command_test.rb +3 -4
- data/test/command/delete_project_command_test.rb +2 -10
- data/test/command/delete_projecttype_command_test.rb +31 -0
- data/test/command/delete_role_command_test.rb +5 -14
- data/test/command/delete_runtime_command_test.rb +31 -0
- data/test/command/delete_servicedefinition_command_test.rb +31 -0
- data/test/command/delete_serviceversion_command_test.rb +3 -2
- data/test/command/delete_solution_command_test.rb +3 -16
- data/test/command/delete_user_command_test.rb +3 -3
- data/test/command/list_config_command_test.rb +1 -0
- data/test/command/list_deployments_command_test.rb +11 -41
- data/test/command/list_objectroles_command_test.rb +4 -14
- data/test/command/list_projects_command_test.rb +0 -14
- data/test/command/list_roles_command_test.rb +3 -1
- data/test/command/list_runtimes_command_test.rb +2 -3
- data/test/command/list_runtimetypes_command_test.rb +29 -0
- data/test/command/list_userproperties_command_test.rb +33 -0
- data/test/command/push_command_test.rb +9 -1
- data/test/command/show_deployment_command_test.rb +36 -0
- data/test/command/show_group_command_test.rb +2 -1
- data/test/command/show_libraryset_command_test.rb +5 -3
- data/test/command/show_metrics_command_test.rb +4 -4
- data/test/command/show_plugin_command_test.rb +4 -4
- data/test/command/show_project_command_test.rb +5 -17
- data/test/command/show_project_snapshot_test.rb +33 -0
- data/test/command/show_projecttype_command_test.rb +5 -11
- data/test/command/show_role_command_test.rb +5 -12
- data/test/command/show_solution_command_test.rb +2 -15
- data/test/command/show_user_command_test.rb +4 -3
- data/test/command/submit_deployment_command_test.rb +4 -11
- data/test/command/unarchive_project_command_test.rb +2 -14
- data/test/command/unarchive_solution_command_test.rb +6 -16
- data/test/command/update_config_command_test.rb +14 -3
- data/test/command/update_deployment_command_test.rb +12 -26
- data/test/command/update_group_command_test.rb +2 -10
- data/test/command/update_librarylanguage_command_test.rb +5 -3
- data/test/command/update_libraryset_command_test.rb +4 -2
- data/test/command/update_plugin_command_test.rb +5 -4
- data/test/command/update_project_command_test.rb +6 -20
- data/test/command/update_role_command_test.rb +11 -8
- data/test/command/update_solution_command_test.rb +6 -12
- data/test/command/update_user_command_test.rb +3 -19
- data/test/command/vote_deployment_command_test.rb +2 -6
- metadata +66 -63
- data/lib/epc/command/attach_library_command.rb +0 -82
- data/lib/epc/command/attach_libraryset_command.rb +0 -31
- data/lib/epc/command/attach_runtime_command.rb +0 -26
- data/lib/epc/command/bind_service_command.rb +0 -35
- data/lib/epc/command/create_dependency_command.rb +0 -43
- data/lib/epc/command/dependency/delete_dependency_command.rb +0 -38
- data/lib/epc/command/detach_library_command.rb +0 -35
- data/lib/epc/command/detach_libraryset_command.rb +0 -8
- data/lib/epc/command/list_versions_command.rb +0 -38
- data/lib/epc/command/submit_deployment_command.rb +0 -19
- data/lib/epc/command/unbind_service_command.rb +0 -42
- data/lib/epc/command/undefine_service_command.rb +0 -33
- data/lib/epc/command/update_rolepermissions_command.rb +0 -83
- data/lib/epc/command/vote_deployment_command.rb +0 -29
- data/test/command/attach_library_command_test.rb +0 -124
- data/test/command/attach_libraryset_command_test.rb +0 -49
- data/test/command/attach_runtime_command_test.rb +0 -44
- data/test/command/bind_service_command_test.rb +0 -46
- data/test/command/create_dependency_command_test.rb +0 -55
- data/test/command/create_plugin_command_test.rb +0 -44
- data/test/command/delete_dependency_command_test.rb +0 -42
- data/test/command/detach_library_command_test.rb +0 -53
- data/test/command/unbind_service_command_test.rb +0 -48
- data/test/command/undefine_service_command_test.rb +0 -49
@@ -1,83 +0,0 @@
|
|
1
|
-
module EPC::Command
|
2
|
-
class UpdatePermissionCommand < UpdateCommand
|
3
|
-
def execute(role = nil, *args)
|
4
|
-
raise FatalError, "You have to specify a role" if role.blank?
|
5
|
-
|
6
|
-
|
7
|
-
if @options[:add_grant].present?
|
8
|
-
secured_type, action, secured_id = @options[:add_grant].split(":")
|
9
|
-
raise FatalError, "Grant incorrectly specified" if secured_type.blank? || action.blank?
|
10
|
-
|
11
|
-
params = {}
|
12
|
-
params[:grant_action] = action
|
13
|
-
params[:permitted_type] = "Role"
|
14
|
-
params[:permitted_id] = role.to_i
|
15
|
-
params[:secured_type] = secured_type
|
16
|
-
params[:secured_id] = secured_id if secured_id.present?
|
17
|
-
|
18
|
-
|
19
|
-
status, response, headers = client.post(EPC::Config::GRANTS_PATH, params)
|
20
|
-
|
21
|
-
if status.successful?
|
22
|
-
say("Role permission updated")
|
23
|
-
else
|
24
|
-
say("Request failed: [#{response[:message]}]")
|
25
|
-
end
|
26
|
-
|
27
|
-
return status
|
28
|
-
end
|
29
|
-
|
30
|
-
if @options[:remove_grant].present?
|
31
|
-
secured_type, action, secured_id = @options[:remove_grant].split(":")
|
32
|
-
status, response, headers = client.get(EPC::Config::ROLES_PATH + "/#{role}/grants")
|
33
|
-
|
34
|
-
if status.successful?
|
35
|
-
grant_id = response.detect do |g|
|
36
|
-
found = (g[:action] == action)
|
37
|
-
found = found && (g[:secured_type].to_s == secured_type)
|
38
|
-
if secured_id.blank?
|
39
|
-
found = found && g[:secured_id].blank?
|
40
|
-
else
|
41
|
-
found = found && (g[:secured_id].to_s == secured_id)
|
42
|
-
end
|
43
|
-
found
|
44
|
-
end[:id] rescue nil
|
45
|
-
|
46
|
-
raise FatalError, "Permission couldn't be determined" if grant_id.blank?
|
47
|
-
|
48
|
-
status, response, headers = client.delete(EPC::Config::GRANTS_PATH + "/#{grant_id}")
|
49
|
-
|
50
|
-
if status.successful?
|
51
|
-
say("Role permission deleted")
|
52
|
-
return 1
|
53
|
-
else
|
54
|
-
say("Request failed: [#{response[:message]}]")
|
55
|
-
return 0
|
56
|
-
end
|
57
|
-
else
|
58
|
-
say("Request failed: [#{response[:message]}]")
|
59
|
-
end
|
60
|
-
|
61
|
-
return status
|
62
|
-
end
|
63
|
-
|
64
|
-
if @options[:file].present?
|
65
|
-
grants = EPC::Config.read_content_as_json(@options[:file])
|
66
|
-
grants.each do |grant|
|
67
|
-
raise FatalError, "Incorrectly specified grant.Grants should have at least secured_type and grant_action specified" if grant["secured_type"].blank? || grant["grant_action"].blank?
|
68
|
-
grant["permitted_type"] = "Role"
|
69
|
-
grant["permitted_id"] = role.to_i
|
70
|
-
status, response, headers = client.post(EPC::Config::GRANTS_PATH, grant)
|
71
|
-
if status.successful?
|
72
|
-
say("Added grant [#{grant["secured_type"]}:#{grant["grant_action"]}:#{grant["secured_id"]}]")
|
73
|
-
else
|
74
|
-
say("Request failed: [#{response[:message]}]")
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
module EPC::Command
|
2
|
-
class VoteDeploymentCommand < BaseCommand
|
3
|
-
|
4
|
-
def execute(deployment_id = nil)
|
5
|
-
approved = false
|
6
|
-
command_usage = EPC::Help::COMMAND_USAGES[:deny_deployment]
|
7
|
-
|
8
|
-
if @options[:approval] == "approve"
|
9
|
-
approved = true
|
10
|
-
command_usage = EPC::Help::COMMAND_USAGES[:approve_deployment]
|
11
|
-
end
|
12
|
-
|
13
|
-
if deployment_id.nil?
|
14
|
-
say("You must specify a deployment id.")
|
15
|
-
say(command_usage)
|
16
|
-
return 1
|
17
|
-
end
|
18
|
-
|
19
|
-
status, response, headers = client.put(EPC::Config::DEPLOYMENTS_PATH + "/#{deployment_id}/vote", {:approved => approved})
|
20
|
-
if status.successful?
|
21
|
-
say("Deployment [#{deployment_id}] has been #{approved ? "approved" : "rejected"} by you.")
|
22
|
-
else
|
23
|
-
say("Request failed: [#{response[:message]}]")
|
24
|
-
end
|
25
|
-
return status
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
end
|
@@ -1,124 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class AttachLibraryCommandTest < Test::Unit::TestCase
|
4
|
-
should_require_login
|
5
|
-
|
6
|
-
context "checks" do
|
7
|
-
setup do
|
8
|
-
@mock_client = mock("Client")
|
9
|
-
@command = EPC::Command::AttachLibraryCommand.new(@mock_client)
|
10
|
-
end
|
11
|
-
|
12
|
-
should "fail if library not specified" do
|
13
|
-
assert_raise EPC::Error::FatalError do
|
14
|
-
assert_equal(@command.execute, 1)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
should "fail if project cannot be determined" do
|
19
|
-
assert_raise EPC::Error::FatalError do
|
20
|
-
@command.expects(:infer_project_context).returns(nil)
|
21
|
-
assert_equal(@command.execute("libmath"), 1)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
should "fail if library id cannot be determined" do
|
26
|
-
assert_raise EPC::Error::InputError do
|
27
|
-
@command.expects(:infer_project_context).returns([1, "FirstSolution"])
|
28
|
-
@command.expects(:retrieve_libraries).returns(nil)
|
29
|
-
|
30
|
-
assert_equal(@command.execute("libmath"), 1)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
context "attaching from json" do
|
36
|
-
setup do
|
37
|
-
@mock_client = mock("Client")
|
38
|
-
@command = EPC::Command::AttachLibraryCommand.new(@mock_client)
|
39
|
-
@command.expects(:infer_project_context).returns([1, "FirstProject"])
|
40
|
-
@command.options[:file] = "path/to/json/file"
|
41
|
-
end
|
42
|
-
|
43
|
-
should "read data and retrieve ids" do
|
44
|
-
EPC::Config.expects(:read_content_as_json).returns([{"id" => 1, "name" => "libmath", "library_version" => "1.0", "group" => "math_libs"}])
|
45
|
-
@command.expects(:retrieve_libraries).returns([1])
|
46
|
-
@mock_client.expects(:post).returns([200, {}, {}])
|
47
|
-
@command.expects(:say).with("Library [1] attached to project.")
|
48
|
-
assert_equal 200, @command.execute
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
context "attaching" do
|
54
|
-
setup do
|
55
|
-
@mock_client = mock("Client")
|
56
|
-
@command = EPC::Command::AttachLibraryCommand.new(@mock_client)
|
57
|
-
@command.expects(:infer_project_context).returns([1, "FirstProject"])
|
58
|
-
end
|
59
|
-
|
60
|
-
should "retrieve libraries by parsing a pom file" do
|
61
|
-
@command.options[:pom] = "path/to/pom/file"
|
62
|
-
@command.expects(:parse_pom).returns([1])
|
63
|
-
@mock_client.expects(:post).returns([200, {}, {}])
|
64
|
-
@command.expects(:say).with("Library [1] attached to project.")
|
65
|
-
assert_equal 200, @command.execute
|
66
|
-
end
|
67
|
-
|
68
|
-
should "fail if status is not 200" do
|
69
|
-
@mock_client.expects(:post).with(EPC::Config::PROJECTS_PATH + "/1/attach_library/1").
|
70
|
-
returns([404, {:message => "Not Found"}, {}])
|
71
|
-
@command.expects(:say).with("Failed to attach library [1]: [Not Found]")
|
72
|
-
|
73
|
-
assert_equal(@command.execute(1), 404)
|
74
|
-
end
|
75
|
-
|
76
|
-
should "attach the library to the project" do
|
77
|
-
@mock_client.expects(:post).with(EPC::Config::PROJECTS_PATH + "/1/attach_library/1").
|
78
|
-
returns([201, {}, {}])
|
79
|
-
@command.expects(:say).with("Library [1] attached to project.")
|
80
|
-
|
81
|
-
assert_equal(@command.execute(1), 201)
|
82
|
-
end
|
83
|
-
|
84
|
-
should "attach library by name, version and group" do
|
85
|
-
@command.expects(:retrieve_libraries).returns([1])
|
86
|
-
@mock_client.expects(:post).with(EPC::Config::PROJECTS_PATH + "/1/attach_library/1").
|
87
|
-
returns([201, {}, {}])
|
88
|
-
@command.expects(:say).with("Library [1] attached to project.")
|
89
|
-
|
90
|
-
assert_equal(@command.execute("math.lib", "2.0.1", "math-libs"), 201)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
context "parse pom" do
|
95
|
-
setup do
|
96
|
-
@mock_client = mock("Client")
|
97
|
-
@command = EPC::Command::AttachLibraryCommand.new(@mock_client)
|
98
|
-
@file = File.new(File.join(File.expand_path("."), "path_to_pom"), "w+")
|
99
|
-
end
|
100
|
-
|
101
|
-
teardown do
|
102
|
-
File.delete(@file) if FileTest.exist?(@file)
|
103
|
-
end
|
104
|
-
|
105
|
-
should "throw exception if can't read the file" do
|
106
|
-
assert_raise EPC::Error::FatalError do
|
107
|
-
@command.send(:parse_pom, "path/to/pom")
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
should "throw exception if it encounters a malformed/invalid xml file" do
|
112
|
-
assert_raise EPC::Error::FatalError do
|
113
|
-
File.expects(:read).with(File.expand_path("path_to_pom")).returns(@file)
|
114
|
-
REXML::Document.expects(:new).with(@file).raises(REXML::ParseException)
|
115
|
-
@command.send(:parse_pom, "path_to_pom")
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
should "parse and retrieve library ids" do
|
120
|
-
@command.expects(:retrieve_libraries).returns([1,2,3])
|
121
|
-
assert_equal @command.send(:parse_pom, "test/test_files/pom.xml"), [1,2,3]
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class AttachLibrarysetCommandTest < 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::AttachLibrarysetCommand.new(@mock_client)
|
10
|
-
end
|
11
|
-
|
12
|
-
should "fail if can't determine project context" do
|
13
|
-
assert_raise EPC::Error::InputError do
|
14
|
-
@command.expects(:infer_solution_context).returns([1, "FirstSolution"])
|
15
|
-
@command.expects(:infer_project_context).returns(nil)
|
16
|
-
assert_equal(@command.execute(1), 1)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
context "attaching/detaching" do
|
22
|
-
setup do
|
23
|
-
@mock_client = mock("Client")
|
24
|
-
@command = EPC::Command::AttachLibrarysetCommand.new(@mock_client)
|
25
|
-
@command.expects(:infer_solution_context).returns([1, "FirstSolution"])
|
26
|
-
@command.expects(:infer_project_context).returns([1, "FirstProject"])
|
27
|
-
end
|
28
|
-
|
29
|
-
should "issue the request to the server" do
|
30
|
-
@mock_client.expects(:post).with(EPC::Config::PROJECTS_PATH + "/1/attach_set/1").returns([201, {}, {}])
|
31
|
-
@command.expects(:say).with("Library set attached")
|
32
|
-
assert_equal(@command.execute(1), 201)
|
33
|
-
end
|
34
|
-
|
35
|
-
should "issue a detach request when detach option is true" do
|
36
|
-
@command.options[:detach] = true
|
37
|
-
@mock_client.expects(:delete).with(EPC::Config::PROJECTS_PATH + "/1/detach_set/1").returns([201, {}, {}])
|
38
|
-
@command.expects(:say).with("Library set detached")
|
39
|
-
assert_equal(@command.execute(1), 201)
|
40
|
-
end
|
41
|
-
|
42
|
-
should "fail if status is not successful" do
|
43
|
-
@mock_client.expects(:post).with(EPC::Config::PROJECTS_PATH + "/1/attach_set/1").returns([404, {:message => "Not Found"}, {}])
|
44
|
-
@command.expects(:say).with("Request failed: [Not Found]")
|
45
|
-
assert_equal(@command.execute(1), 404)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class AttachRuntimeCommandTest < Test::Unit::TestCase
|
4
|
-
should_require_login
|
5
|
-
|
6
|
-
context "attaching" do
|
7
|
-
setup do
|
8
|
-
@mock_client = mock("Client")
|
9
|
-
@command = EPC::Command::AttachRuntimeCommand.new(@mock_client)
|
10
|
-
end
|
11
|
-
|
12
|
-
|
13
|
-
should "fail if no project id specified or could not be determined" do
|
14
|
-
@command.options[:stage] = "development"
|
15
|
-
@command.expects(:infer_project_context).returns(nil)
|
16
|
-
|
17
|
-
assert_raise EPC::Error::InputError do
|
18
|
-
assert_equal(@command.execute(1), 1)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
should "fail if status is not 200" do
|
23
|
-
@command.options[:stage] = "development"
|
24
|
-
@command.expects(:infer_project_context).returns([1, "FirstProject"])
|
25
|
-
@mock_client.expects(:put).with(EPC::Config::PROJECTS_PATH + "/1/set_runtime_env",
|
26
|
-
{:runtime_env_id => 1, :stage_name => 'development'}).
|
27
|
-
returns([404, {:message => "Not Found"}, {}])
|
28
|
-
@command.expects(:say).with("Request failed: [Not Found]")
|
29
|
-
|
30
|
-
assert_equal(@command.execute(1), 404)
|
31
|
-
end
|
32
|
-
|
33
|
-
should "attach the runtime from the project" do
|
34
|
-
@command.options[:stage] = "development"
|
35
|
-
@command.expects(:infer_project_context).returns([1, "FirstProject"])
|
36
|
-
@mock_client.expects(:put).with(EPC::Config::PROJECTS_PATH + "/1/set_runtime_env",
|
37
|
-
{:runtime_env_id => 1, :stage_name => 'development'}).
|
38
|
-
returns([201, {}, {}])
|
39
|
-
@command.expects(:say).with("Runtime attached")
|
40
|
-
|
41
|
-
assert_equal(@command.execute(1), 201)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class BindServiceCommandTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
should_require_login
|
6
|
-
|
7
|
-
context "binding" do
|
8
|
-
setup do
|
9
|
-
@mock_client = mock("Client")
|
10
|
-
@command = EPC::Command::BindServiceCommand.new(@mock_client)
|
11
|
-
end
|
12
|
-
|
13
|
-
should "fail if service version not specified" do
|
14
|
-
assert_raise EPC::Error::FatalError do
|
15
|
-
assert_equal(@command.execute, 1)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
should "fail if service version id or project 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
|
-
assert_raise EPC::Error::FatalError do
|
24
|
-
assert_equal(@command.execute("main_db"), 1)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
should "fail if status is not 201" do
|
29
|
-
@command.expects(:infer_project_context).returns([1, "FirstProject"])
|
30
|
-
@mock_client.expects(:post).with(EPC::Config::PROJECTS_PATH + "/1/add_service_version", {:version_id => 1}).
|
31
|
-
returns([404, {:message => "Not Found"}, {}])
|
32
|
-
@command.expects(:say).with("Request failed: [Not Found]")
|
33
|
-
|
34
|
-
assert_equal(@command.execute(1), 404)
|
35
|
-
end
|
36
|
-
|
37
|
-
should "bind the service to the project" do
|
38
|
-
@command.expects(:infer_project_context).returns([1, "FirstProject"])
|
39
|
-
@mock_client.expects(:post).with(EPC::Config::PROJECTS_PATH + "/1/add_service_version", {:version_id => 1}).
|
40
|
-
returns([201, {}, {}])
|
41
|
-
@command.expects(:say).with("Service bound.")
|
42
|
-
|
43
|
-
assert_equal(@command.execute(1), 201)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class CreateDependencyCommandTest < Test::Unit::TestCase
|
4
|
-
should_require_login
|
5
|
-
|
6
|
-
context "execute" do
|
7
|
-
|
8
|
-
setup do
|
9
|
-
@mock_client = mock("Client")
|
10
|
-
@command = EPC::Command::CreateDependencyCommand.new(@mock_client)
|
11
|
-
end
|
12
|
-
|
13
|
-
should "fail if project id can't be determined (no solution)" do
|
14
|
-
@command.expects(:infer_solution_context).returns([ nil, nil ])
|
15
|
-
@command.expects(:infer_project_context).returns([ nil, nil ])
|
16
|
-
@command.expects(:say).with("Project/solution could not be inferred")
|
17
|
-
@command.expects(:say).with(EPC::Help::COMMAND_USAGES[:create_dependency])
|
18
|
-
assert_equal(@command.execute, 1)
|
19
|
-
end
|
20
|
-
|
21
|
-
should "fail if project id can't be determined" do
|
22
|
-
@command.expects(:infer_solution_context).returns([ 1, "FirstSolution" ])
|
23
|
-
@command.expects(:infer_project_context).returns([ 1, "FirstProject" ])
|
24
|
-
@command.expects(:get_resource_id).returns(nil)
|
25
|
-
@command.expects(:say).with("Dependency could not be inferred")
|
26
|
-
@command.expects(:say).with(EPC::Help::COMMAND_USAGES[:create_dependency])
|
27
|
-
assert_equal(@command.execute, 1)
|
28
|
-
end
|
29
|
-
|
30
|
-
should "show a message if status is not 201" do
|
31
|
-
@command.options[:dependency] = "dependency_name"
|
32
|
-
@command.expects(:infer_project_context).returns([1, "FirstProject"])
|
33
|
-
@command.expects(:infer_solution_context).returns([1, "FirstSolution"])
|
34
|
-
@command.expects(:get_resource_id).returns(2)
|
35
|
-
@mock_client.expects(:post).with(EPC::Config::PROJECTS_PATH + "/1/add_dependency", {:dependency_id => 2, :dependency_kind => 1}).
|
36
|
-
returns([400, {:message => "Not Found"}, {}])
|
37
|
-
@command.expects(:say).with("Request failed: [Not Found]")
|
38
|
-
|
39
|
-
assert_equal(@command.execute, 400)
|
40
|
-
end
|
41
|
-
|
42
|
-
should "do a POST request to core" do
|
43
|
-
@command.options[:dependency_type] = 2
|
44
|
-
@command.options[:dependency] = 2
|
45
|
-
@command.expects(:infer_project_context).returns([1, "FirstProject"])
|
46
|
-
@command.expects(:infer_solution_context).returns([1, "FirstSolution"])
|
47
|
-
|
48
|
-
@mock_client.expects(:post).with(EPC::Config::PROJECTS_PATH + "/1/add_dependency", {:dependency_id => 2, :dependency_kind => 2}).returns([201, {}, {}])
|
49
|
-
@command.expects(:say).with("Dependency defined")
|
50
|
-
|
51
|
-
assert_equal(@command.execute, 201)
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
55
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class CreatePluginCommandTest < Test::Unit::TestCase
|
4
|
-
should_require_login
|
5
|
-
|
6
|
-
context "execute" do
|
7
|
-
setup do
|
8
|
-
@mock_client = mock("Client")
|
9
|
-
@command = EPC::Command::CreatePluginCommand.new(@mock_client)
|
10
|
-
end
|
11
|
-
|
12
|
-
should "fail if mandatory attributes not specified" do
|
13
|
-
assert_raise EPC::Error::FatalError do
|
14
|
-
@command.execute("")
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
should "request creation of the plugin" do
|
19
|
-
@mock_client.expects(:post).with(EPC::Config::PLUGINS_PATH, {:name => "plugin_name", :plugin_version => "plugin_version", :group => "group", :extensions => false, :inherited => false}).returns([200, {}, {}])
|
20
|
-
@command.expects(:say).with("Plugin [plugin_name] created.")
|
21
|
-
@command.execute("", "plugin_name", "plugin_version", "group")
|
22
|
-
end
|
23
|
-
|
24
|
-
should "report reason for request failure" do
|
25
|
-
@mock_client.expects(:post).with(EPC::Config::PLUGINS_PATH, {:name => "plugin_name", :plugin_version => "plugin_version", :group => "group", :extensions => false, :inherited => false}).returns([500, {:message => "System Exception"}, {}])
|
26
|
-
@command.expects(:say).with("Request failed: [System Exception]")
|
27
|
-
@command.execute("", "plugin_name", "plugin_version", "group")
|
28
|
-
end
|
29
|
-
|
30
|
-
context "parse_plugin_opt" do
|
31
|
-
should "should retrieve contents of file when option begins with 'file:'" do
|
32
|
-
@command.expects(:read_file).with("path_to_file").returns("contents of file")
|
33
|
-
assert_equal @command.send(:parse_plugin_opt, "file:path_to_file"), "contents of file"
|
34
|
-
end
|
35
|
-
|
36
|
-
should "should return the content of the option when no file specified" do
|
37
|
-
assert_equal @command.send(:parse_plugin_opt, "option"), "option"
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
|
44
|
-
end
|