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
@@ -0,0 +1,133 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
module Role
|
3
|
+
def self.included(base)
|
4
|
+
base.send :include, InstanceMethods
|
5
|
+
end
|
6
|
+
|
7
|
+
module InstanceMethods
|
8
|
+
|
9
|
+
def batch_add(role_id, data)
|
10
|
+
users = data["users"] rescue []
|
11
|
+
users.each do |user|
|
12
|
+
add_user(role_id, user["id"])
|
13
|
+
end
|
14
|
+
|
15
|
+
groups = data["user_groups"] rescue []
|
16
|
+
groups.each do |group|
|
17
|
+
add_group(role_id, group["id"])
|
18
|
+
end
|
19
|
+
|
20
|
+
grants = data["grants"] rescue []
|
21
|
+
grants.each do |grant|
|
22
|
+
add_grant(role_id, [grant["secured_type"], grant["action"], grant["secured_id"]].join(":"))
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def add_user(role_id, user)
|
28
|
+
user_id = retrieve_identifier_for("User", user)
|
29
|
+
params = []
|
30
|
+
params << {:member_id => user_id.to_i, :member_type => "User"}
|
31
|
+
|
32
|
+
status, response, headers = client.put(EPC::Config::ROLES_PATH + "/#{role_id}/assign_members", {:role_memberships => params})
|
33
|
+
if status.successful?
|
34
|
+
say("User [#{user}] added to role")
|
35
|
+
else
|
36
|
+
say("Failed to add [#{user}]: [#{response[:message]}]")
|
37
|
+
end
|
38
|
+
return status
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
def remove_user(role_id, user)
|
43
|
+
user_id = retrieve_identifier_for("User", user)
|
44
|
+
status, response, headers = client.delete(EPC::Config::ROLES_PATH + "/#{role_id}/remove_member", {:member_id => @options[:remove_user], :member_type => "User"})
|
45
|
+
|
46
|
+
if status.successful?
|
47
|
+
say("User [#{user}] removed from role")
|
48
|
+
else
|
49
|
+
say("Failed to remove [#{user}]: [#{response[:message]}]")
|
50
|
+
end
|
51
|
+
|
52
|
+
return status
|
53
|
+
end
|
54
|
+
|
55
|
+
def add_group(role_id, group)
|
56
|
+
group_id = retrieve_identifier_for("UserGroup", group)
|
57
|
+
params = []
|
58
|
+
params << {:member_id => group_id.to_i, :member_type => "UserGroup"}
|
59
|
+
|
60
|
+
status, response, headers = client.put(EPC::Config::ROLES_PATH + "/#{role_id}/assign_members", {:role_memberships => params})
|
61
|
+
if status.successful?
|
62
|
+
say("Group [#{group}] added to role")
|
63
|
+
else
|
64
|
+
say("Failed to add [#{group}]: [#{response[:message]}]")
|
65
|
+
end
|
66
|
+
|
67
|
+
return status
|
68
|
+
end
|
69
|
+
|
70
|
+
def remove_group(role_id, group)
|
71
|
+
group_id = retrieve_identifier_for("UserGroup", group)
|
72
|
+
status, response, headers = client.delete(EPC::Config::ROLES_PATH + "/#{role_id}/remove_member", {:member_id => group_id, :member_type => "UserGroup"})
|
73
|
+
if status.successful?
|
74
|
+
say("Group [#{group}] removed from role")
|
75
|
+
else
|
76
|
+
say("Failed to remove [#{group}]: [#{response[:message]}]")
|
77
|
+
end
|
78
|
+
|
79
|
+
return status
|
80
|
+
end
|
81
|
+
|
82
|
+
def add_grant(role_id, grant)
|
83
|
+
secured_type, action, secured_id = grant.split(":")
|
84
|
+
raise FatalError, "Grant incorrectly specified" if secured_type.blank? || action.blank?
|
85
|
+
|
86
|
+
params = {}
|
87
|
+
params[:grant_action] = action
|
88
|
+
params[:permitted_type] = "Role"
|
89
|
+
params[:permitted_id] = role_id.to_i
|
90
|
+
params[:secured_type] = secured_type
|
91
|
+
params[:secured_id] = secured_id if secured_id.present?
|
92
|
+
|
93
|
+
status, response, headers = client.post(EPC::Config::GRANTS_PATH, params)
|
94
|
+
|
95
|
+
if status.successful?
|
96
|
+
say("Role permission updated")
|
97
|
+
else
|
98
|
+
say("Request failed: [#{response[:message]}]")
|
99
|
+
end
|
100
|
+
return status
|
101
|
+
end
|
102
|
+
|
103
|
+
def remove_grant(role_id, grant)
|
104
|
+
secured_type, action, secured_id = grant.split(":")
|
105
|
+
status, response, headers = client.get(EPC::Config::ROLES_PATH + "/#{role_id}/grants")
|
106
|
+
|
107
|
+
if status.successful?
|
108
|
+
grant_id = response.detect do |g|
|
109
|
+
found = (g[:action] == action)
|
110
|
+
found = found && (g[:secured_type].to_s == secured_type)
|
111
|
+
if secured_id.blank?
|
112
|
+
found = found && g[:secured_id].blank?
|
113
|
+
else
|
114
|
+
found = found && (g[:secured_id].to_s == secured_id)
|
115
|
+
end
|
116
|
+
found
|
117
|
+
end[:id] rescue nil
|
118
|
+
|
119
|
+
raise FatalError, "Permission couldn't be determined" if grant_id.blank?
|
120
|
+
|
121
|
+
status, response, headers = client.delete(EPC::Config::GRANTS_PATH + "/#{grant_id}")
|
122
|
+
|
123
|
+
if status.successful?
|
124
|
+
say("Role permission deleted")
|
125
|
+
else
|
126
|
+
say("Request failed: [#{response[:message]}]")
|
127
|
+
end
|
128
|
+
end
|
129
|
+
return status
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
data/lib/epc/runner.rb
CHANGED
@@ -13,7 +13,7 @@ class EPC::Runner
|
|
13
13
|
def initialize(args = [])
|
14
14
|
@args = args
|
15
15
|
@options = Hash.new
|
16
|
-
@parent_commands = %w(
|
16
|
+
@parent_commands = %w(define undefine refresh approve deny bind unbind attach detach request)
|
17
17
|
end
|
18
18
|
|
19
19
|
def run
|
@@ -35,14 +35,17 @@ class EPC::Runner
|
|
35
35
|
say(ex.to_s)
|
36
36
|
exit 1
|
37
37
|
rescue FatalError => ex
|
38
|
-
command_name = EPC::Config.underscore(command_klass.
|
39
|
-
|
38
|
+
command_name = EPC::Config.underscore(command_klass.klass_name.to_s.split("::").last)
|
39
|
+
say("USAGE: " + EPC::Help::COMMAND_USAGES[command_name.split("_")[0...-1].join("_").to_sym])
|
40
40
|
say(ex.to_s)
|
41
41
|
exit 1
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
42
|
+
rescue ArgumentError => ex
|
43
|
+
command_name = EPC::Config.underscore(command_klass.klass_name.to_s.split("::").last)
|
44
|
+
say("Wrong number of attributes for #{command_name}")
|
45
|
+
say("USAGE: " + EPC::Help::COMMAND_USAGES[command_name.split("_")[0...-1].join("_").to_sym])
|
46
|
+
exit 1
|
47
|
+
rescue NameError => ex
|
48
|
+
say "No such command"
|
46
49
|
exit 1
|
47
50
|
rescue BaseClient::HTTPException => ex
|
48
51
|
say(ex.to_s)
|
@@ -78,7 +81,7 @@ class EPC::Runner
|
|
78
81
|
opts.on('--down-script FILE') { |file| @options[:down_script] = file}
|
79
82
|
opts.on('--required') { |required| @options[:required] = true }
|
80
83
|
opts.on('--f FILE') { |file| @options[:file] = file }
|
81
|
-
opts.on('--file FILE')
|
84
|
+
opts.on('--file FILE') { |file| @options[:file] = file }
|
82
85
|
opts.on('--force') { |force| @options[:force] = true }
|
83
86
|
opts.on('-s NAME') { |name| @options[:solution_name] = name}
|
84
87
|
opts.on('-S NAME') { |name| @options[:stage_name] = name}
|
@@ -129,8 +132,15 @@ class EPC::Runner
|
|
129
132
|
opts.on('--timeout TIMEOUT') { |timeout| @options[:timeout] = timeout}
|
130
133
|
opts.on('--extensions') { |ext| @options[:extensions] = true}
|
131
134
|
opts.on('--inherited') { |inherited| @options[:inherited] = true}
|
135
|
+
opts.on('--archived') { |archived| @options[:archived] = true}
|
136
|
+
opts.on('--memory') { |memory| @options[:memory] = memory}
|
132
137
|
opts.on('--configuration CONFIGURATION') { |configuration| @options[:configuration] = configuration}
|
133
|
-
opts.on('--
|
138
|
+
opts.on('--agility-topology ID') { |id| @options[:agility_topology] = id}
|
139
|
+
opts.on('--agility-environment ID') { |id| @options[:agility_environment] = id}
|
140
|
+
opts.on('--executions executions') { |executions| @options[:executions] = executions}
|
141
|
+
opts.on('--backwards-compatible') { |val| @options[:backwards_compatible] = true}
|
142
|
+
opts.on('--reversible') { |val| @options[:reversible] = true}
|
143
|
+
opts.on('--direct-deploy FILE') { |file| @options[:direct_deploy] = file}
|
134
144
|
|
135
145
|
opts.on('-p NAME') do |name|
|
136
146
|
if @options[:project_name].nil?
|
@@ -161,16 +171,17 @@ class EPC::Runner
|
|
161
171
|
exit 0
|
162
172
|
else
|
163
173
|
if command_name == "approve" || command_name == "deny"
|
164
|
-
|
165
|
-
klass_name = "EPC::Command::VoteDeploymentCommand"
|
174
|
+
klass_name = "EPC::Command::VoteCommand"
|
166
175
|
@options[:approval] = command_name
|
167
176
|
elsif @parent_commands.include?(command_name)
|
168
177
|
subcommand_name = @args.shift.gsub("-", "")
|
169
178
|
klass_name = "EPC::Command::#{command_name.to_s.capitalize}#{subcommand_name.to_s.capitalize}Command"
|
179
|
+
elsif command_name == "snapshot"
|
180
|
+
klass_name = "EPC::Command::ShowProjectSnapshotCommand"
|
170
181
|
else
|
171
182
|
klass_name = "EPC::Command::#{command_name.to_s.capitalize}Command"
|
172
183
|
end
|
173
|
-
command_klass = eval(klass_name).new(client, @options)
|
184
|
+
command_klass = eval(klass_name.gsub("-", "")).new(client, @options)
|
174
185
|
end
|
175
186
|
rescue NameError => ex
|
176
187
|
say("No such command: #{command_name} #{subcommand_name}")
|
data/lib/epc/version.rb
CHANGED
@@ -1,24 +1,13 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class ArchiveProjectCommandTest < Test::Unit::TestCase
|
4
|
-
context "checks" do
|
5
|
-
setup do
|
6
|
-
@mock_client = mock("Client")
|
7
|
-
@command = EPC::Command::ArchiveProjectCommand.new(@mock_client)
|
8
|
-
end
|
9
4
|
|
10
|
-
should "fail if no project id specified" do
|
11
|
-
assert_raise EPC::Error::FatalError do
|
12
|
-
assert_equal 1, @command.execute
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
5
|
context "archiving" do
|
17
6
|
setup do
|
18
7
|
@mock_client = mock("Client")
|
19
8
|
@command = EPC::Command::ArchiveProjectCommand.new(@mock_client)
|
20
|
-
@command.
|
21
|
-
@command.
|
9
|
+
@command.object_type = "Project"
|
10
|
+
@command.object_id = 1
|
22
11
|
end
|
23
12
|
|
24
13
|
should "fail if status is not 201" do
|
@@ -1,27 +1,17 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class ArchiveSolutionCommandTest < Test::Unit::TestCase
|
4
|
-
context "checks" do
|
5
|
-
setup do
|
6
|
-
@mock_client = mock("Client")
|
7
|
-
@command = EPC::Command::ArchiveSolutionCommand.new(@mock_client)
|
8
|
-
end
|
9
4
|
|
10
|
-
should "fail if no solution specified" do
|
11
|
-
assert_raise EPC::Error::FatalError do
|
12
|
-
assert_equal 1, @command.execute
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
5
|
context "archiving" do
|
17
6
|
setup do
|
18
7
|
@mock_client = mock("Client")
|
19
8
|
@command = EPC::Command::ArchiveSolutionCommand.new(@mock_client)
|
20
|
-
@command.
|
9
|
+
@command.object_id = 1
|
10
|
+
@command.object_type = "Solution"
|
21
11
|
end
|
22
12
|
|
23
13
|
should "fail if status is not 201" do
|
24
|
-
@mock_client.expects(:put).with(EPC::Config::SOLUTIONS_PATH + "/1", {:archived => true
|
14
|
+
@mock_client.expects(:put).with(EPC::Config::SOLUTIONS_PATH + "/1", {:archived => true}).
|
25
15
|
returns([404, {:message => "Not Found"}, {}])
|
26
16
|
|
27
17
|
@command.expects(:say).with("Solution could not be archived. Request failed with: [Not Found]")
|
@@ -29,7 +19,7 @@ class ArchiveSolutionCommandTest < Test::Unit::TestCase
|
|
29
19
|
end
|
30
20
|
|
31
21
|
should "archive the solution" do
|
32
|
-
@mock_client.expects(:put).with(EPC::Config::SOLUTIONS_PATH + "/1", {:archived => true
|
22
|
+
@mock_client.expects(:put).with(EPC::Config::SOLUTIONS_PATH + "/1", {:archived => true}).
|
33
23
|
returns([200, {}, {}])
|
34
24
|
|
35
25
|
@command.expects(:say).with("Solution has been archived.")
|
@@ -8,12 +8,8 @@ class CopyDeploymentCommandTest < Test::Unit::TestCase
|
|
8
8
|
setup do
|
9
9
|
@mock_client = mock("Client")
|
10
10
|
@command = EPC::Command::CopyDeploymentCommand.new(@mock_client)
|
11
|
-
|
12
|
-
|
13
|
-
should "fail if no deployment id specified" do
|
14
|
-
assert_raise EPC::Error::FatalError do
|
15
|
-
assert_equal(@command.execute, 1)
|
16
|
-
end
|
11
|
+
@command.object_id = 1
|
12
|
+
@command.object_type = "Deployment"
|
17
13
|
end
|
18
14
|
|
19
15
|
should "fail if status is not 201" do
|
@@ -21,7 +17,7 @@ class CopyDeploymentCommandTest < Test::Unit::TestCase
|
|
21
17
|
returns([404, {:message => "Not Found"}, {}])
|
22
18
|
|
23
19
|
@command.expects(:say).with("Request failed: [Not Found]")
|
24
|
-
assert_equal(@command.execute(
|
20
|
+
assert_equal(@command.execute(["development"]), 404)
|
25
21
|
end
|
26
22
|
|
27
23
|
should "report the succesfull creation of new deployment" do
|
@@ -29,7 +25,7 @@ class CopyDeploymentCommandTest < Test::Unit::TestCase
|
|
29
25
|
returns([201, {:id => 2}, {}])
|
30
26
|
|
31
27
|
@command.expects(:say).with("Copied new deployment to the development stage. ID: 2")
|
32
|
-
assert_equal(@command.execute(
|
28
|
+
assert_equal(@command.execute(["development"]), 201)
|
33
29
|
|
34
30
|
end
|
35
31
|
|
@@ -7,13 +7,13 @@ class CreateConfigCommandTest < Test::Unit::TestCase
|
|
7
7
|
context "adding" do
|
8
8
|
setup do
|
9
9
|
@mock_client = mock("Client")
|
10
|
+
EPC::Command::CreateConfigCommand.send :include, EPC::Command::Config
|
10
11
|
@command = EPC::Command::CreateConfigCommand.new(@mock_client)
|
11
|
-
|
12
12
|
end
|
13
13
|
|
14
14
|
should "fail if no key specified" do
|
15
15
|
assert_raise EPC::Error::FatalError do
|
16
|
-
@command.execute
|
16
|
+
@command.execute
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -28,22 +28,21 @@ class CreateConfigCommandTest < Test::Unit::TestCase
|
|
28
28
|
).returns([400, {:message => "Not Found"}, {}])
|
29
29
|
|
30
30
|
@command.expects("say").with("Request failed with message [Not Found]")
|
31
|
-
assert_equal(@command.execute("
|
32
|
-
|
31
|
+
assert_equal(@command.execute(["key1=value1"]), 400)
|
33
32
|
end
|
34
33
|
|
35
34
|
|
36
35
|
should "add to specified configuration level when option is specified" do
|
37
|
-
command
|
36
|
+
@command.options[:user] = 2
|
38
37
|
|
39
|
-
command.expects(:extract_configuration_level).returns(["User", 2])
|
38
|
+
@command.expects(:extract_configuration_level).returns(["User", 2])
|
40
39
|
|
41
40
|
@mock_client.expects(:post).with(EPC::Config::CONFIGURATIONS_PATH,
|
42
41
|
{:config_values => [{:name => "key1", :value => "value1", :value_type => "text", :configurable_id => 2, :configurable_type => "User", :required => false, :no_override => nil}]}
|
43
42
|
).returns([201, {:id => 1}, {}])
|
44
43
|
|
45
|
-
command.expects(:say).with("Configuration values saved.")
|
46
|
-
assert_equal(command.execute("
|
44
|
+
@command.expects(:say).with("Configuration values saved.")
|
45
|
+
assert_equal(@command.execute(["key1=value1"]), 201)
|
47
46
|
|
48
47
|
end
|
49
48
|
|
@@ -55,46 +54,47 @@ class CreateConfigCommandTest < Test::Unit::TestCase
|
|
55
54
|
).returns([201, {:id => 1}, {}])
|
56
55
|
|
57
56
|
@command.expects(:say).with("Configuration values saved.")
|
58
|
-
assert_equal(@command.execute("
|
57
|
+
assert_equal(@command.execute(["key1=value1"]), 201)
|
59
58
|
end
|
60
59
|
|
61
60
|
should "add required key when --required flag is supplied" do
|
62
|
-
command
|
61
|
+
@command.options[:required] = true
|
63
62
|
|
64
|
-
command.expects(:extract_configuration_level).returns(["Project", 1])
|
63
|
+
@command.expects(:extract_configuration_level).returns(["Project", 1])
|
65
64
|
|
66
65
|
@mock_client.expects(:post).with(EPC::Config::CONFIGURATIONS_PATH,
|
67
66
|
{:config_values => [{:name => "key1", :value => "value1", :value_type => "text", :configurable_id => 1, :configurable_type => "Project", :required => true, :no_override => nil}]}
|
68
67
|
).returns([201, {:id => 1}, {}])
|
69
68
|
|
70
|
-
command.expects(:say).with("Configuration values saved.")
|
71
|
-
assert_equal(command.execute("
|
69
|
+
@command.expects(:say).with("Configuration values saved.")
|
70
|
+
assert_equal(@command.execute(["key1=value1"]), 201)
|
72
71
|
end
|
73
72
|
|
74
73
|
should "should accept value-type parameter" do
|
75
|
-
command
|
74
|
+
@command.options[:value_type] = "URL"
|
76
75
|
|
77
|
-
command.expects(:extract_configuration_level).returns(["Project", 1])
|
76
|
+
@command.expects(:extract_configuration_level).returns(["Project", 1])
|
78
77
|
|
79
78
|
@mock_client.expects(:post).with(EPC::Config::CONFIGURATIONS_PATH,
|
80
79
|
{:config_values => [{:name => "key1", :value => "value1", :value_type => "URL", :configurable_id => 1, :configurable_type => "Project", :required => false, :no_override => nil}]}
|
81
80
|
).returns([201, {:id => 1}, {}])
|
82
81
|
|
83
|
-
command.expects(:say).with("Configuration values saved.")
|
84
|
-
assert_equal(command.execute("
|
82
|
+
@command.expects(:say).with("Configuration values saved.")
|
83
|
+
assert_equal(@command.execute(["key1=value1"]), 201)
|
85
84
|
end
|
86
85
|
|
87
86
|
should "should add the stage name parameter" do
|
88
|
-
command
|
87
|
+
@command.options[:value_type] = "URL"
|
88
|
+
@command.options[:stage] = "Development"
|
89
89
|
|
90
|
-
command.expects(:extract_configuration_level).returns(["Project", 1])
|
90
|
+
@command.expects(:extract_configuration_level).returns(["Project", 1])
|
91
91
|
|
92
92
|
@mock_client.expects(:post).with(EPC::Config::CONFIGURATIONS_PATH,
|
93
93
|
{:config_values => [{:name => "key1", :value => "value1", :value_type => "URL", :configurable_id => 1, :configurable_type => "Project", :required => false, :no_override => nil, :stage_name => "Development"}]}
|
94
94
|
).returns([201, {:id => 1}, {}])
|
95
95
|
|
96
|
-
command.expects(:say).with("Configuration values saved.")
|
97
|
-
assert_equal(command.execute("
|
96
|
+
@command.expects(:say).with("Configuration values saved.")
|
97
|
+
assert_equal(@command.execute(["key1=value1"]), 201)
|
98
98
|
end
|
99
99
|
|
100
100
|
should "read data from external file when prompted to" do
|
@@ -106,7 +106,7 @@ class CreateConfigCommandTest < Test::Unit::TestCase
|
|
106
106
|
).returns([201, {:id => 1}, {}])
|
107
107
|
|
108
108
|
@command.expects(:say).with("Configuration values saved.")
|
109
|
-
assert_equal(@command.execute("
|
109
|
+
assert_equal(@command.execute(["key1=value1"]), 201)
|
110
110
|
end
|
111
111
|
|
112
112
|
should "fail if no config values were supplied" do
|
@@ -114,7 +114,7 @@ class CreateConfigCommandTest < Test::Unit::TestCase
|
|
114
114
|
@command.options[:file] = "path_to_file"
|
115
115
|
EPC::Config.expects(:read_content_as_json).returns([])
|
116
116
|
@command.expects(:extract_configuration_level).returns(["Project", 1])
|
117
|
-
@command.execute
|
117
|
+
@command.execute
|
118
118
|
end
|
119
119
|
|
120
120
|
end
|
@@ -42,7 +42,7 @@ class CreateDeploymentCommandTest < Test::Unit::TestCase
|
|
42
42
|
@command.expects(:ask_yn).returns("Y")
|
43
43
|
@command.expects(:say).with("Deployment creation failed [Not Found]. Aborting.")
|
44
44
|
|
45
|
-
assert_equal(@command.execute("
|
45
|
+
assert_equal(@command.execute(["Development"]), 404)
|
46
46
|
end
|
47
47
|
|
48
48
|
should "report failure if it catches an exception" do
|
@@ -53,38 +53,39 @@ class CreateDeploymentCommandTest < Test::Unit::TestCase
|
|
53
53
|
@command.expects(:ask_yn).returns("Y")
|
54
54
|
@command.expects(:say).with("Create deployment failed [Exception Caught (StandardError): failed].")
|
55
55
|
|
56
|
-
assert_equal(@command.execute("
|
56
|
+
assert_equal(@command.execute(["Development"]), 1)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
context "deployment replacement" do
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
60
|
+
# context "deployment replacement" do
|
61
|
+
# setup do
|
62
|
+
# @mock_client = mock("Client")
|
63
|
+
# @command = EPC::Command::CreateDeploymentCommand.new(@mock_client, {:solution_name => "FirstSolution"})
|
64
|
+
# @command.target_id = "FirstSolution"
|
65
|
+
# @command.expects(:infer_solution_context).returns([1, "FirstSolution"])
|
66
|
+
# @command.expects(:ask_yn).returns("Y")
|
67
|
+
# @command.options[:replaces] = 1
|
68
|
+
# @command.expects(:create_deployment).returns([200, 2])
|
69
|
+
# end
|
70
|
+
|
71
|
+
# should "issue a replacement request to core" do
|
72
|
+
# @mock_client.expects(:put).with(EPC::Config::DEPLOYMENTS_PATH + "/2", :stage_name => "no_change", :replaces_id => 1, :versions => "no_change").
|
73
|
+
# returns([200, {}, {}])
|
74
|
+
# @command.expects(:say).with("Replacement request successful")
|
75
|
+
|
76
|
+
# @command.execute()
|
77
|
+
# end
|
78
|
+
|
79
|
+
# should "notify if replacement request fails" do
|
80
|
+
# @mock_client.expects(:put).with(EPC::Config::DEPLOYMENTS_PATH + "/2", :stage_name => "no_change", :replaces_id => 1, :versions => "no_change").
|
81
|
+
# returns([500, {:message => "System exception"}, {}])
|
82
|
+
# @command.expects(:say).with("Replacement request failed: [System exception]")
|
83
|
+
|
84
|
+
# @command.execute
|
85
|
+
# end
|
86
|
+
#
|
87
|
+
|
88
|
+
# end
|
88
89
|
|
89
90
|
context "create_deployment" do
|
90
91
|
setup do
|
@@ -125,12 +126,12 @@ class CreateDeploymentCommandTest < Test::Unit::TestCase
|
|
125
126
|
end
|
126
127
|
|
127
128
|
should "return blank results when passed blank data" do
|
128
|
-
assert_equal(@command.send(:parse_projects, []), [[], []])
|
129
|
+
assert_equal(@command.send(:parse_projects, []), [[], [], []])
|
129
130
|
end
|
130
131
|
|
131
132
|
|
132
133
|
should "parse projects" do
|
133
|
-
assert_equal(@command.send(:parse_projects, "1:2:3"), [[{:project_id => "1", :version => "2"}], [{:project_id => "1", :instances => "3"}]])
|
134
|
+
assert_equal(@command.send(:parse_projects, "1:2:3:4"), [[{:project_id => "1", :version => "2"}], [{:project_id => "1", :instances => "3"}],[{:project_id => "1", :runtime_memory => "4"}]])
|
134
135
|
end
|
135
136
|
end
|
136
137
|
end
|