epc 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/epc.rb +71 -54
- data/lib/epc/command/archive_command.rb +12 -0
- data/lib/epc/command/attach_libraryset_command.rb +1 -2
- data/lib/epc/command/attach_runtime_command.rb +0 -1
- data/lib/epc/command/base_command.rb +52 -63
- data/lib/epc/command/config/delete_config_command.rb +57 -0
- data/lib/epc/command/{list_config_command.rb → config/list_configs_command.rb} +1 -1
- data/lib/epc/command/config/update_config_command.rb +56 -0
- data/lib/epc/command/create_command.rb +0 -1
- data/lib/epc/command/delete_command.rb +16 -0
- data/lib/epc/command/{delete_dependency_command.rb → dependency/delete_dependency_command.rb} +14 -16
- data/lib/epc/command/deploy_command.rb +1 -2
- data/lib/epc/command/deployment/list_deployments_command.rb +49 -0
- data/lib/epc/command/deployment/show_deployment_command.rb +61 -0
- data/lib/epc/command/{update_deploymentproject_command.rb → deployment/update_deployment_command.rb} +3 -3
- data/lib/epc/command/{list_stages_command.rb → deploymentstage/list_deploymentstages_command.rb} +1 -1
- data/lib/epc/command/group/delete_group_command.rb +25 -0
- data/lib/epc/command/{list_groups_command.rb → group/list_groups_command.rb} +1 -1
- data/lib/epc/command/{show_group_command.rb → group/show_group_command.rb} +2 -9
- data/lib/epc/command/{update_group_command.rb → group/update_group_command.rb} +3 -20
- data/lib/epc/command/library/create_library_command.rb +2 -5
- data/lib/epc/command/library/delete_library_command.rb +23 -0
- data/lib/epc/command/{list_libraries_command.rb → library/list_libraries_command.rb} +1 -1
- data/lib/epc/command/librarylanguage/delete_librarylanguage_command.rb +24 -0
- data/lib/epc/command/{list_librarylanguages_command.rb → librarylanguage/list_librarylanguages_command.rb} +1 -1
- data/lib/epc/command/{update_librarylanguage_command.rb → librarylanguage/update_librarylanguage_command.rb} +6 -10
- data/lib/epc/command/libraryset/create_libraryset_command.rb +1 -6
- data/lib/epc/command/{delete_libraryset_command.rb → libraryset/delete_libraryset_command.rb} +2 -18
- data/lib/epc/command/{list_librarysets_command.rb → libraryset/list_librarysets_command.rb} +1 -1
- data/lib/epc/command/{show_libraryset_command.rb → libraryset/show_libraryset_command.rb} +2 -17
- data/lib/epc/command/{update_libraryset_command.rb → libraryset/update_libraryset_command.rb} +4 -16
- data/lib/epc/command/list_command.rb +22 -0
- data/lib/epc/command/list_metrics_command.rb +25 -0
- data/lib/epc/command/list_objecttypes_command.rb +2 -4
- data/lib/epc/command/list_versions_command.rb +0 -1
- data/lib/epc/command/{list_objectroles_command.rb → objectrole/list_objectroles_command.rb} +3 -3
- data/lib/epc/command/objectrole/update_objectrole_command.rb +14 -0
- data/lib/epc/command/{list_rolepermissions_command.rb → permission/list_permissions_command.rb} +2 -2
- data/lib/epc/command/{list_permissiongroups_command.rb → permissiongroup/list_permissiongroups_command.rb} +1 -1
- data/lib/epc/command/plugin/create_plugin_command.rb +42 -0
- data/lib/epc/command/plugin/delete_plugin_command.rb +26 -0
- data/lib/epc/command/plugin/list_plugins_command.rb +19 -0
- data/lib/epc/command/plugin/show_plugin_command.rb +29 -0
- data/lib/epc/command/plugin/update_plugin_command.rb +53 -0
- data/lib/epc/command/{archive_project_command.rb → project/archive_project_command.rb} +4 -3
- data/lib/epc/command/{delete_project_command.rb → project/delete_project_command.rb} +11 -7
- data/lib/epc/command/{list_projects_command.rb → project/list_projects_command.rb} +8 -9
- data/lib/epc/command/{show_project_command.rb → project/show_project_command.rb} +64 -29
- data/lib/epc/command/{unarchive_project_command.rb → project/unarchive_project_command.rb} +5 -4
- data/lib/epc/command/{update_project_command.rb → project/update_project_command.rb} +11 -5
- data/lib/epc/command/{list_projecttypes_command.rb → projecttype/list_projecttypes_command.rb} +1 -1
- data/lib/epc/command/{show_projecttype_command.rb → projecttype/show_projecttype_command.rb} +4 -3
- data/lib/epc/command/pull_command.rb +33 -35
- data/lib/epc/command/{delete_role_command.rb → role/delete_role_command.rb} +3 -4
- data/lib/epc/command/{list_roles_command.rb → role/list_roles_command.rb} +4 -3
- data/lib/epc/command/{show_role_command.rb → role/show_role_command.rb} +18 -10
- data/lib/epc/command/role/update_role_command.rb +95 -0
- data/lib/epc/command/{list_runtimes_command.rb → runtime/list_runtimes_command.rb} +0 -0
- data/lib/epc/command/servicedefinition/create_servicedefinition_command.rb +23 -0
- data/lib/epc/command/{list_servicedefinitions_command.rb → servicedefinition/list_servicedefinitions_command.rb} +1 -0
- data/lib/epc/command/{list_service_types_command.rb → servicetype/list_servicetypes_command.rb} +0 -0
- data/lib/epc/command/serviceversion/delete_serviceversion_command.rb +24 -0
- data/lib/epc/command/{list_serviceversions_command.rb → serviceversion/list_serviceversions_command.rb} +1 -1
- data/lib/epc/command/show_command.rb +27 -0
- data/lib/epc/command/show_instances_command.rb +33 -0
- data/lib/epc/command/show_metrics_command.rb +55 -0
- data/lib/epc/command/{archive_solution_command.rb → solution/archive_solution_command.rb} +2 -1
- data/lib/epc/command/solution/create_solution_command.rb +0 -1
- data/lib/epc/command/{delete_solution_command.rb → solution/delete_solution_command.rb} +5 -10
- data/lib/epc/command/solution/list_solutions_command.rb +1 -1
- data/lib/epc/command/{show_solution_command.rb → solution/show_solution_command.rb} +12 -7
- data/lib/epc/command/{unarchive_solution_command.rb → solution/unarchive_solution_command.rb} +1 -1
- data/lib/epc/command/solution/update_solution_command.rb +2 -1
- data/lib/epc/command/unarchive_command.rb +12 -0
- data/lib/epc/command/update_command.rb +15 -0
- data/lib/epc/command/update_rolepermissions_command.rb +2 -2
- data/lib/epc/command/{delete_user_command.rb → user/delete_user_command.rb} +4 -12
- data/lib/epc/command/{list_users_command.rb → user/list_users_command.rb} +1 -1
- data/lib/epc/command/{show_user_command.rb → user/show_user_command.rb} +3 -17
- data/lib/epc/command/{update_user_command.rb → user/update_user_command.rb} +2 -4
- data/lib/epc/config.rb +4 -1
- data/lib/epc/help.rb +50 -35
- data/lib/epc/runner.rb +16 -5
- data/lib/epc/version.rb +1 -1
- data/lib/epc/vertical_bar.rb +40 -0
- data/test/command/create_library_command_test.rb +5 -2
- data/test/command/create_libraryset_command_test.rb +1 -1
- data/test/command/create_plugin_command_test.rb +44 -0
- data/test/command/create_servicedefinition_command_test.rb +43 -0
- data/test/command/delete_config_command_test.rb +0 -11
- data/test/command/delete_dependency_command_test.rb +3 -11
- data/test/command/delete_library_command_test.rb +2 -15
- data/test/command/delete_librarylanguage_command_test.rb +2 -24
- data/test/command/delete_libraryset_command_test.rb +2 -24
- data/test/command/delete_plugin_command_test.rb +32 -0
- data/test/command/delete_project_command_test.rb +0 -6
- data/test/command/delete_role_command_test.rb +1 -1
- data/test/command/delete_serviceversion_command_test.rb +0 -22
- data/test/command/delete_solution_command_test.rb +4 -4
- data/test/command/delete_user_command_test.rb +2 -24
- data/test/command/list_config_command_test.rb +3 -3
- data/test/command/list_deployments_command_test.rb +17 -20
- data/test/command/list_deploymentstages_command_test.rb +2 -2
- data/test/command/list_metrics_command_test.rb +40 -0
- data/test/command/{list_rolepermissions_command_test.rb → list_permissions_command_test.rb} +2 -2
- data/test/command/list_plugins_command_test.rb +27 -0
- data/test/command/list_projects_command_test.rb +3 -5
- data/test/command/list_roles_command_test.rb +2 -3
- data/test/command/pull_command_test.rb +13 -9
- data/test/command/show_group_command_test.rb +1 -23
- data/test/command/show_instances_command_test.rb +33 -0
- data/test/command/show_libraryset_command_test.rb +0 -11
- data/test/command/show_metrics_command_test.rb +51 -0
- data/test/command/show_plugin_command_test.rb +28 -0
- data/test/command/show_project_command_test.rb +1 -1
- data/test/command/show_projecttype_command_test.rb +0 -5
- data/test/command/show_role_command_test.rb +1 -1
- data/test/command/show_solution_command_test.rb +1 -1
- data/test/command/show_user_command_test.rb +2 -22
- data/test/command/update_config_command_test.rb +3 -9
- data/test/command/{update_deploymentproject_command_test.rb → update_deployment_command_test.rb} +6 -11
- data/test/command/update_group_command_test.rb +1 -20
- data/test/command/update_librarylanguage_command_test.rb +0 -15
- data/test/command/update_libraryset_command_test.rb +0 -13
- data/test/command/update_plugin_command_test.rb +41 -0
- data/test/command/update_project_command_test.rb +3 -3
- data/test/command/update_role_command_test.rb +2 -1
- data/test/command/update_solution_command_test.rb +3 -9
- data/test/command/update_user_command_test.rb +0 -6
- metadata +177 -165
- data/lib/epc/command/define_service_command.rb +0 -37
- data/lib/epc/command/delete_config_command.rb +0 -63
- data/lib/epc/command/delete_group_command.rb +0 -40
- data/lib/epc/command/delete_library_command.rb +0 -30
- data/lib/epc/command/delete_librarylanguage_command.rb +0 -40
- data/lib/epc/command/delete_serviceversion_command.rb +0 -52
- data/lib/epc/command/list_approvals_command.rb +0 -27
- data/lib/epc/command/list_attachedlibraries_command.rb +0 -42
- data/lib/epc/command/list_boundservices_command.rb +0 -40
- data/lib/epc/command/list_dependencies_command.rb +0 -43
- data/lib/epc/command/list_deployments_command.rb +0 -68
- data/lib/epc/command/list_solutions_command.rb +0 -25
- data/lib/epc/command/show_deployment_command.rb +0 -57
- data/lib/epc/command/update_config_command.rb +0 -62
- data/lib/epc/command/update_role_command.rb +0 -47
- data/lib/epc/command/update_solution_command.rb +0 -45
- data/test/command/define_service_command_test.rb +0 -55
- data/test/command/delete_group_command_test.rb +0 -56
- data/test/command/list_approvals_command_test.rb +0 -41
- data/test/command/list_boundservices_command_test.rb +0 -46
- data/test/command/list_dependencies_command_test.rb +0 -46
- data/test/command/update_rolepermissions_command_test.rb +0 -54
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'time'
|
2
|
-
module EPC::Command
|
3
|
-
class ListSolutionsCommand < BaseCommand
|
4
|
-
|
5
|
-
def execute(*args)
|
6
|
-
status, response, headers = client.get(EPC::Config::SOLUTIONS_PATH)
|
7
|
-
|
8
|
-
if status.failure?
|
9
|
-
say("Solutions retrieval failed with [#{response[:message]}]")
|
10
|
-
elsif response.empty?
|
11
|
-
say("You have no solutions created. You can create them with epc create solution.")
|
12
|
-
else
|
13
|
-
response.each do |resp|
|
14
|
-
resp[:created_at] = Time.parse(resp[:created_at]).strftime("%m/%d/%Y %I:%M%p")
|
15
|
-
resp[:creator_id] = resp[:created_by][:id] rescue nil
|
16
|
-
resp[:creator_name] = resp[:created_by][:name] rescue nil
|
17
|
-
end
|
18
|
-
solutions_table = EPC::TabularOutputter.new(response, [:id, :name, :build_status, :created_at, :creator_id, :creator_name])
|
19
|
-
say(solutions_table.print)
|
20
|
-
end
|
21
|
-
return status
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'time'
|
2
|
-
module EPC::Command
|
3
|
-
class ShowDeploymentCommand < BaseCommand
|
4
|
-
|
5
|
-
def execute(deployment_id = nil)
|
6
|
-
if deployment_id.nil?
|
7
|
-
say("You must specifiy a deployment id")
|
8
|
-
say(EPC::Help::COMMAND_USAGES[:show_deployment])
|
9
|
-
return 1
|
10
|
-
end
|
11
|
-
|
12
|
-
status, response, headers = client.get(EPC::Config::DEPLOYMENTS_PATH + "/#{deployment_id}?include=solution,deployment_stage,approvals,deployer,submitter")
|
13
|
-
if status.failure?
|
14
|
-
say("Request failed: [#{response[:message]}]")
|
15
|
-
return status
|
16
|
-
end
|
17
|
-
|
18
|
-
response[:created_at] = Time.parse(response[:created_at]).strftime("%m/%d/%Y %I:%M%p") unless response[:created_at].nil?
|
19
|
-
response[:updated_at] = Time.parse(response[:updated_at]).strftime("%m/%d/%Y %I:%M%p") unless response[:updated_at].nil?
|
20
|
-
response[:stage] = response[:deployment_stage][:name]
|
21
|
-
response[:solution_id] = response[:solution][:id]
|
22
|
-
response[:solution_name] = response[:solution][:name]
|
23
|
-
response[:submitter] = response[:submitter][:name] rescue nil
|
24
|
-
response[:deployer] = response[:deployer][:name] rescue nil
|
25
|
-
deployments_table = EPC::TabularOutputter.new([response], [:id, :status, :stage, :solution_name, :submitter, :deployer, :updated_at, :note, :replaces])
|
26
|
-
say(deployments_table.print)
|
27
|
-
|
28
|
-
|
29
|
-
approvals = response[:approvals]
|
30
|
-
unless approvals.nil? || approvals.empty?
|
31
|
-
say("\nApprovals:")
|
32
|
-
approvals_table = EPC::TabularOutputter.new(approvals, [:id, :name, :approved, :approver_id, :approver_name])
|
33
|
-
say(approvals_table.print)
|
34
|
-
end
|
35
|
-
|
36
|
-
projects = response[:solution][:projects]
|
37
|
-
unless projects.nil? || projects.empty?
|
38
|
-
say("\n\nProjects details:")
|
39
|
-
projects.each do |project|
|
40
|
-
say("\n## #{project[:name]}")
|
41
|
-
project[:uri] = project[:uris].first unless project[:uris].nil?
|
42
|
-
projects_table = EPC::TabularOutputter.new([project], [:id, :name, :version, :status, :uri, :instances])
|
43
|
-
say(projects_table.print)
|
44
|
-
|
45
|
-
config_values = project[:config_values]
|
46
|
-
unless config_values.nil? || config_values.empty?
|
47
|
-
say("\nConfig values: ")
|
48
|
-
config_values_table = EPC::TabularOutputter.new(config_values, [:name, :value])
|
49
|
-
say(config_values_table.print)
|
50
|
-
end
|
51
|
-
say("\n\n")
|
52
|
-
end
|
53
|
-
end
|
54
|
-
return status
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
module EPC::Command
|
2
|
-
class UpdateConfigCommand < BaseCommand
|
3
|
-
|
4
|
-
|
5
|
-
def execute(*args)
|
6
|
-
if args.empty?
|
7
|
-
say("You have to specify a key and its value.")
|
8
|
-
return 1
|
9
|
-
end
|
10
|
-
|
11
|
-
path = "."
|
12
|
-
path = File.expand_path(path)
|
13
|
-
|
14
|
-
@options[:required] = false if @options[:required].nil?
|
15
|
-
|
16
|
-
config_type, config_id = extract_configuration_level(path, @options)
|
17
|
-
request_path = EPC::Config::CONFIGURATIONS_PATH+"/#{config_type}/#{config_id}"
|
18
|
-
|
19
|
-
if ["solution", "project"].include?(config_type.downcase) && !@options[:stage].nil?
|
20
|
-
request_path += "/#{@options[:stage]}"
|
21
|
-
end
|
22
|
-
|
23
|
-
status, response, headers = client.get(request_path)
|
24
|
-
|
25
|
-
if status.failure?
|
26
|
-
say("Configuration retrieval failed with [#{response[:message]}]")
|
27
|
-
return status
|
28
|
-
end
|
29
|
-
|
30
|
-
keys = response
|
31
|
-
|
32
|
-
args.each do |arg|
|
33
|
-
name, value = arg.split("=")
|
34
|
-
|
35
|
-
key_id = keys.detect{|k| k[:name] == name}[:id] rescue nil
|
36
|
-
|
37
|
-
if key_id.nil?
|
38
|
-
say("Key does not exist.")
|
39
|
-
return 1
|
40
|
-
end
|
41
|
-
|
42
|
-
params = {
|
43
|
-
:name => name,
|
44
|
-
}
|
45
|
-
params[:value] = value unless value.nil?
|
46
|
-
params[:required] = @options[:required]
|
47
|
-
params[:no_override] = @options[:no_override] unless @options[:no_override].nil?
|
48
|
-
|
49
|
-
status, response, headers = client.put(EPC::Config::CONFIGURATIONS_PATH + "/#{key_id}", params)
|
50
|
-
|
51
|
-
if status.successful?
|
52
|
-
unless response[:id].nil?
|
53
|
-
say("#{name} saved.")
|
54
|
-
end
|
55
|
-
else
|
56
|
-
say("Request failed with message [#{response[:message]}]")
|
57
|
-
end
|
58
|
-
return status
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
module EPC::Command
|
2
|
-
class UpdateRoleCommand < BaseCommand
|
3
|
-
|
4
|
-
required_arguments_count 1, :message => "You must specify the role id/name"
|
5
|
-
required_options :add_user, :remove_user, :add_group, :remove_group, :mode => :any?, :message => "You must specify a user to added or removed"
|
6
|
-
|
7
|
-
def execute(role = nil)
|
8
|
-
role_id = retrieve_system_role_identifier(role)
|
9
|
-
|
10
|
-
|
11
|
-
if @options[:add_user].present?
|
12
|
-
user_id = retrieve_user_identifier(@options[:add_user])
|
13
|
-
params = []
|
14
|
-
params << {:member_id => user_id.to_i, :member_type => "User"}
|
15
|
-
|
16
|
-
status, response, headers = client.put(EPC::Config::ROLES_PATH + "/#{role_id}/assign_members", {:role_memberships => params})
|
17
|
-
say("User added to role") if status.successful?
|
18
|
-
end
|
19
|
-
|
20
|
-
|
21
|
-
if @options[:remove_user].present?
|
22
|
-
user_id = retrieve_user_identifier(@options[:remove_user])
|
23
|
-
status, response, headers = client.delete(EPC::Config::ROLES_PATH + "/#{role_id}/remove_member", {:member_id => @options[:remove_user], :member_type => "User"})
|
24
|
-
say("User removed from role") if status.successful?
|
25
|
-
end
|
26
|
-
|
27
|
-
if @options[:add_group].present?
|
28
|
-
group_id = retrieve_user_group_identifier(@options[:add_group])
|
29
|
-
params = []
|
30
|
-
params << {:member_id => group_id.to_i, :member_type => "UserGroup"}
|
31
|
-
|
32
|
-
status, response, headers = client.put(EPC::Config::ROLES_PATH + "/#{role_id}/assign_members", {:role_memberships => params})
|
33
|
-
say("UserGroup added to role") if status.successful?
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
if @options[:remove_group].present?
|
38
|
-
group_id = retrieve_user_group_identifier(@options[:remove_group])
|
39
|
-
status, response, headers = client.delete(EPC::Config::ROLES_PATH + "/#{role_id}/remove_member", {:member_id => group_id, :member_type => "UserGroup"})
|
40
|
-
say("UserGroup removed from role") if status.successful?
|
41
|
-
end
|
42
|
-
|
43
|
-
say("Request failed: [#{response[:message]}]") unless status.successful?
|
44
|
-
return status
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
module EPC::Command
|
2
|
-
class UpdateSolutionCommand < BaseCommand
|
3
|
-
UPDATABLE_ATTRIBUTES = ["name"]
|
4
|
-
|
5
|
-
def execute(*args)
|
6
|
-
path = "."
|
7
|
-
path = File.expand_path(path)
|
8
|
-
path = project_solution_path(path)
|
9
|
-
|
10
|
-
|
11
|
-
solution_id, solution_name = infer_solution_context(@options[:solution_name], path)
|
12
|
-
|
13
|
-
raise FatalError, "Solution could not be determined" if solution_id.nil?
|
14
|
-
|
15
|
-
args_hash = {}
|
16
|
-
args.each do |arg|
|
17
|
-
key, val = arg.split("=")
|
18
|
-
args_hash[key] = val
|
19
|
-
end
|
20
|
-
|
21
|
-
unless @options[:file].nil?
|
22
|
-
args_hash = EPC::Config.read_content_as_json(@options[:file]).merge(args_hash)
|
23
|
-
end
|
24
|
-
|
25
|
-
args_hash.each do |attr, val|
|
26
|
-
if !UPDATABLE_ATTRIBUTES.include?(attr)
|
27
|
-
args_hash.delete(attr)
|
28
|
-
say("Cannot update #{attr}. Updatable attributes are: #{UPDATABLE_ATTRIBUTES.join(',')}")
|
29
|
-
next
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
unless args_hash.empty?
|
35
|
-
status, response, message = client.put(EPC::Config::SOLUTIONS_PATH + "/#{solution_id}", args_hash)
|
36
|
-
if status.failure?
|
37
|
-
say("Update failed with: [#{response['message']}]")
|
38
|
-
else
|
39
|
-
say("Update succesful")
|
40
|
-
end
|
41
|
-
return status
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require File.expand_path "../../../lib/epc", __FILE__
|
2
|
-
require "test/unit"
|
3
|
-
require 'shoulda'
|
4
|
-
require 'mocha'
|
5
|
-
|
6
|
-
class DefineServiceCommandTest < Test::Unit::TestCase
|
7
|
-
should_require_login
|
8
|
-
|
9
|
-
context "execution" do
|
10
|
-
setup do
|
11
|
-
@mock_client = mock('Client')
|
12
|
-
end
|
13
|
-
|
14
|
-
should "require the user to specify the service_name" do
|
15
|
-
@command = EPC::Command::DefineServiceCommand.new(@mock_client)
|
16
|
-
@command.expects(:say).with("You must specify a name for the service")
|
17
|
-
@command.expects(:say).with(EPC::Help::COMMAND_USAGES[:define_service])
|
18
|
-
@command.execute
|
19
|
-
end
|
20
|
-
|
21
|
-
should "require the user to specify a service_type identifier" do
|
22
|
-
@command = EPC::Command::DefineServiceCommand.new(@mock_client, {:service_type => nil})
|
23
|
-
@command.expects(:say).with("You must specify a service type with -t option.")
|
24
|
-
@command.execute("service")
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
context "service definition" do
|
29
|
-
setup do
|
30
|
-
@mock_client = stub('Client')
|
31
|
-
@command = EPC::Command::DefineServiceCommand.new(@mock_client, {:service_type => "MySQL"})
|
32
|
-
end
|
33
|
-
|
34
|
-
should "query core for service_type_id if service type name was specified" do
|
35
|
-
@command.expects(:get_resource_id).returns(0)
|
36
|
-
@command.expects(:say).with("MySQL service type could not be found.")
|
37
|
-
@command.execute("service")
|
38
|
-
end
|
39
|
-
|
40
|
-
should "fail if status is not 201" do
|
41
|
-
@command.expects(:get_resource_id).returns(1)
|
42
|
-
@mock_client.expects(:post).with(EPC::Config::SERVICE_DEFINITIONS_PATH, {:name => "service", :type_id => 1}).returns([400, {'message' => 'Not Found'}])
|
43
|
-
@command.expects(:say).with("Service definition failed with: [Not Found]")
|
44
|
-
@command.execute("service")
|
45
|
-
end
|
46
|
-
|
47
|
-
should "define a service" do
|
48
|
-
@command.expects(:get_resource_id).returns(1)
|
49
|
-
@mock_client.expects(:post).with(EPC::Config::SERVICE_DEFINITIONS_PATH, {:name => "service", :type_id => 1}).returns([201, {'id' => 1}])
|
50
|
-
@command.expects(:say).with("service has been defined.")
|
51
|
-
@command.execute("service")
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class DeleteGroupCommandTest < Test::Unit::TestCase
|
4
|
-
should_require_login
|
5
|
-
|
6
|
-
context "execute" do
|
7
|
-
setup do
|
8
|
-
@mock_client = mock("Client")
|
9
|
-
@command = EPC::Command::DeleteGroupCommand.new(@mock_client)
|
10
|
-
end
|
11
|
-
|
12
|
-
should "fail if no names are specified" do
|
13
|
-
@command.expects(:say).with("You need to specify a group id/name")
|
14
|
-
@command.expects(:say).with(EPC::Help::COMMAND_USAGES[:delete_group])
|
15
|
-
assert_equal(@command.execute, 1)
|
16
|
-
end
|
17
|
-
|
18
|
-
should "fail if group id can't be determined" do
|
19
|
-
@command.expects(:ask_yn).returns("Y")
|
20
|
-
@command.expects(:get_resource_id).with(EPC::Config::GROUPS_PATH, :name, "admins").returns(nil)
|
21
|
-
@command.expects(:say).with("Group could not be determined")
|
22
|
-
|
23
|
-
assert_equal(@command.execute("admins"), 1)
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
|
-
should "fail if status is not 200" do
|
28
|
-
@command.expects(:ask_yn).returns("Y")
|
29
|
-
@mock_client.expects(:delete).with(EPC::Config::GROUPS_PATH + "/1").
|
30
|
-
returns([404, {:message => "Not Found"}, {}])
|
31
|
-
@command.expects(:say).with("Request failed: [Not Found]")
|
32
|
-
assert_equal(@command.execute(1), 404)
|
33
|
-
end
|
34
|
-
|
35
|
-
|
36
|
-
should "delete a group specified by id" do
|
37
|
-
@command.expects(:ask_yn).returns("Y")
|
38
|
-
@mock_client.expects(:delete).with(EPC::Config::GROUPS_PATH + "/1").
|
39
|
-
returns([200, {}, {}])
|
40
|
-
@command.expects(:say).with("Group deleted")
|
41
|
-
|
42
|
-
assert_equal(@command.execute(1), 200)
|
43
|
-
end
|
44
|
-
|
45
|
-
|
46
|
-
should "delete a group specified by name" do
|
47
|
-
@command.expects(:ask_yn).returns("Y")
|
48
|
-
@command.expects(:get_resource_id).with(EPC::Config::GROUPS_PATH, :name, "admins").returns(1)
|
49
|
-
@mock_client.expects(:delete).with(EPC::Config::GROUPS_PATH + "/1").
|
50
|
-
returns([200, {}, {}])
|
51
|
-
@command.expects(:say).with("Group deleted")
|
52
|
-
|
53
|
-
assert_equal(@command.execute("admins"), 200)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class ListApprovalsCommandTest < Test::Unit::TestCase
|
4
|
-
should_require_login
|
5
|
-
|
6
|
-
context "execute" do
|
7
|
-
setup do
|
8
|
-
@mock_client = mock("Client")
|
9
|
-
@command = EPC::Command::ListApprovalsCommand.new(@mock_client)
|
10
|
-
end
|
11
|
-
|
12
|
-
should "fail if deployment_id can't be determined" do
|
13
|
-
|
14
|
-
@command.expects(:say).with("You must specify a deployment id")
|
15
|
-
@command.expects(:say).with(EPC::Help::COMMAND_USAGES[:list_approvals])
|
16
|
-
assert_equal(@command.execute, 1)
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
should "show a message if status is not 200" do
|
21
|
-
@mock_client.expects(:get).with(EPC::Config::DEPLOYMENTS_PATH + "/1/approvals").returns([400, {:message => "Not Found"}, {}])
|
22
|
-
@command.expects(:say).with("Request failed: [Not Found]")
|
23
|
-
assert_equal(@command.execute(1), 400)
|
24
|
-
end
|
25
|
-
|
26
|
-
should "show a message if no approvals are found" do
|
27
|
-
@mock_client.expects(:get).with(EPC::Config::DEPLOYMENTS_PATH + "/1/approvals").returns([200, {}, {}])
|
28
|
-
@command.expects(:say).with("No approvals have been defined")
|
29
|
-
assert_equal(@command.execute(1), 200)
|
30
|
-
end
|
31
|
-
|
32
|
-
should "request and show approvals" do
|
33
|
-
@mock_client.expects(:get).with(EPC::Config::DEPLOYMENTS_PATH + "/1/approvals").
|
34
|
-
returns([200, [{:id => 1, :name => "admin approval", :approved => true, :user_id => 1}], {}])
|
35
|
-
|
36
|
-
@command.expects(:say)
|
37
|
-
assert_equal(@command.execute(1), 200)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class ListBoundservicesCommandTest < Test::Unit::TestCase
|
4
|
-
should_require_login
|
5
|
-
|
6
|
-
context "execute" do
|
7
|
-
setup do
|
8
|
-
@mock_client = mock("Client")
|
9
|
-
@command = EPC::Command::ListBoundservicesCommand.new(@mock_client)
|
10
|
-
end
|
11
|
-
|
12
|
-
should "fail if library not specified" do
|
13
|
-
@command.expects(:say).with(EPC::Help::COMMAND_USAGES[:list_boundservices])
|
14
|
-
|
15
|
-
assert_equal(@command.execute, 1)
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
should "fail if status is not 200" do
|
20
|
-
@mock_client.expects(:get).with(EPC::Config::PROJECTS_PATH + "/1/service_versions").
|
21
|
-
returns([404, {:message => "Not Found"}, {}])
|
22
|
-
@command.expects(:say).with("Request failed: [Not Found]")
|
23
|
-
|
24
|
-
assert_equal(@command.execute(1), 404)
|
25
|
-
end
|
26
|
-
|
27
|
-
should "list bound-services" do
|
28
|
-
@mock_client.expects(:get).with(EPC::Config::PROJECTS_PATH + "/1/service_versions").
|
29
|
-
returns([200, [{
|
30
|
-
:id => 100,
|
31
|
-
:current => false,
|
32
|
-
:service_version => {
|
33
|
-
:label => "Label",
|
34
|
-
:id => 133,
|
35
|
-
:label => "Version 20",
|
36
|
-
:service_definition => {
|
37
|
-
:id => 133,
|
38
|
-
:name => "Service Definition 20"
|
39
|
-
}
|
40
|
-
}
|
41
|
-
}], {}])
|
42
|
-
@command.expects(:say).twice
|
43
|
-
assert_equal(@command.execute(1), 200)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class ListDependenciesCommandTest < Test::Unit::TestCase
|
4
|
-
should_require_login
|
5
|
-
|
6
|
-
context "execute" do
|
7
|
-
setup do
|
8
|
-
@mock_client = mock("Client")
|
9
|
-
@command = EPC::Command::ListDependenciesCommand.new(@mock_client)
|
10
|
-
end
|
11
|
-
|
12
|
-
should "fail if project_id can't be determined" do
|
13
|
-
@command.expects(:infer_project_context).returns([nil, nil])
|
14
|
-
@command.expects(:say).with("Project could not be inferred")
|
15
|
-
@command.expects(:say).with(EPC::Help::COMMAND_USAGES[:list_dependencies])
|
16
|
-
|
17
|
-
assert_equal(@command.execute, 1)
|
18
|
-
end
|
19
|
-
|
20
|
-
should "show a message if status is not 200" do
|
21
|
-
@command.expects(:infer_project_context).returns([1, "FirstProject"])
|
22
|
-
@mock_client.expects(:get).with(EPC::Config::PROJECTS_PATH + "/1/list_dependencies").returns([400, {:message => "Not Found"}, {}])
|
23
|
-
@command.expects(:say).with("Request failed: [Not Found]")
|
24
|
-
|
25
|
-
assert_equal(@command.execute, 400)
|
26
|
-
end
|
27
|
-
|
28
|
-
should "show a message if no dependencies are found" do
|
29
|
-
@command.expects(:infer_project_context).returns([1, "FirstProject"])
|
30
|
-
@mock_client.expects(:get).with(EPC::Config::PROJECTS_PATH + "/1/list_dependencies").returns([200, [], {}])
|
31
|
-
|
32
|
-
@command.expects(:say).with("Project [FirstProject] has no dependencies")
|
33
|
-
|
34
|
-
assert_equal(@command.execute, 200)
|
35
|
-
end
|
36
|
-
|
37
|
-
should "request and show dependencies" do
|
38
|
-
@command.expects(:infer_project_context).returns([1, "FirstProject"])
|
39
|
-
@mock_client.expects(:get).with(EPC::Config::PROJECTS_PATH + "/1/list_dependencies").
|
40
|
-
returns([200, [{:id => 1, :parent_id => 1, :dependency_id => 2, :dependency_kind => 1}]])
|
41
|
-
@command.expects(:say)
|
42
|
-
assert_equal(@command.execute, 200)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|