hammer_cli_foreman 2.5.2 → 3.0.0
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.
- checksums.yaml +4 -4
- data/doc/release_notes.md +10 -4
- data/lib/hammer_cli_foreman/architecture.rb +5 -5
- data/lib/hammer_cli_foreman/associating_commands.rb +0 -24
- data/lib/hammer_cli_foreman/bookmark.rb +5 -5
- data/lib/hammer_cli_foreman/combination.rb +3 -13
- data/lib/hammer_cli_foreman/command_extensions.rb +0 -2
- data/lib/hammer_cli_foreman/commands.rb +2 -9
- data/lib/hammer_cli_foreman/compute_profile.rb +5 -5
- data/lib/hammer_cli_foreman/host.rb +0 -35
- data/lib/hammer_cli_foreman/hostgroup.rb +2 -53
- data/lib/hammer_cli_foreman/hosts/common_update_options.rb +1 -23
- data/lib/hammer_cli_foreman/id_resolver.rb +0 -61
- data/lib/hammer_cli_foreman/location.rb +0 -6
- data/lib/hammer_cli_foreman/mail_notification.rb +2 -2
- data/lib/hammer_cli_foreman/model.rb +5 -5
- data/lib/hammer_cli_foreman/operating_system.rb +10 -10
- data/lib/hammer_cli_foreman/option_sources/id_params.rb +27 -10
- data/lib/hammer_cli_foreman/option_sources/ids_params.rb +25 -6
- data/lib/hammer_cli_foreman/option_sources.rb +0 -1
- data/lib/hammer_cli_foreman/organization.rb +0 -6
- data/lib/hammer_cli_foreman/references.rb +0 -16
- data/lib/hammer_cli_foreman/settings.rb +3 -3
- data/lib/hammer_cli_foreman/smart_proxy.rb +0 -52
- data/lib/hammer_cli_foreman/usergroup.rb +5 -5
- data/lib/hammer_cli_foreman/version.rb +1 -1
- data/lib/hammer_cli_foreman.rb +0 -21
- data/lib/minitest/coverage_reporter.rb +1 -1
- data/locale/ca/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/de/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/en/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/en_GB/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/es/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/fr/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/it/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ja/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ko/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ru/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/zh_TW/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/test/functional/architecture_test.rb +6 -4
- data/test/functional/bookmark_test.rb +3 -1
- data/test/functional/compute_profile_test.rb +3 -1
- data/test/functional/host_test.rb +0 -1
- data/test/functional/hostgroup/create_test.rb +0 -117
- data/test/functional/hostgroup/update_test.rb +0 -79
- data/test/functional/location_test.rb +0 -3
- data/test/functional/mail_notification_test.rb +3 -1
- data/test/functional/model_test.rb +3 -1
- data/test/functional/operating_system_test.rb +3 -1
- data/test/functional/settings_test.rb +4 -4
- data/test/functional/template_test.rb +4 -37
- data/test/functional/usergroup_test.rb +3 -1
- data/test/unit/apipie_resource_mock.rb +1 -39
- data/test/unit/architecture_test.rb +10 -10
- data/test/unit/bookmark_test.rb +10 -14
- data/test/unit/compute_profile_test.rb +10 -10
- data/test/unit/helpers/command.rb +0 -8
- data/test/unit/host_test.rb +14 -61
- data/test/unit/hostgroup_test.rb +7 -26
- data/test/unit/id_resolver_test.rb +0 -28
- data/test/unit/mail_notification_test.rb +4 -4
- data/test/unit/model_test.rb +47 -47
- data/test/unit/operating_system_test.rb +10 -16
- data/test/unit/option_sources/id_params_test.rb +9 -0
- data/test/unit/option_sources/ids_params_test.rb +9 -0
- data/test/unit/settings_test.rb +4 -4
- data/test/unit/smart_proxy_test.rb +0 -12
- data/test/unit/usergroup_test.rb +10 -10
- metadata +27 -48
- data/lib/hammer_cli_foreman/command_extensions/puppet_environment.rb +0 -29
- data/lib/hammer_cli_foreman/command_extensions/puppet_environments.rb +0 -29
- data/lib/hammer_cli_foreman/config_group.rb +0 -45
- data/lib/hammer_cli_foreman/option_sources/puppet_environment_params.rb +0 -59
- data/lib/hammer_cli_foreman/puppet_class.rb +0 -61
- data/lib/hammer_cli_foreman/puppet_environment.rb +0 -65
- data/lib/hammer_cli_foreman/smart_class_parameter.rb +0 -189
- data/test/functional/config_group_test.rb +0 -50
- data/test/functional/proxy_test.rb +0 -86
- data/test/functional/smart_class_parameter_test.rb +0 -97
- data/test/unit/config_group_test.rb +0 -82
- data/test/unit/puppet_class_test.rb +0 -72
- data/test/unit/puppet_environment_test.rb +0 -114
- data/test/unit/smart_class_parameter_test.rb +0 -113
@@ -1,189 +0,0 @@
|
|
1
|
-
module HammerCLIForeman
|
2
|
-
|
3
|
-
class SmartClassParametersBriefList < HammerCLIForeman::ListCommand
|
4
|
-
resource :smart_class_parameters, :index
|
5
|
-
command_name 'sc-params'
|
6
|
-
|
7
|
-
output do
|
8
|
-
field :id, _("Id")
|
9
|
-
|
10
|
-
field :parameter, _("Parameter")
|
11
|
-
field :default_value, _("Default Value")
|
12
|
-
field :override, _("Override")
|
13
|
-
end
|
14
|
-
|
15
|
-
def send_request
|
16
|
-
res = super
|
17
|
-
# FIXME: API returns doubled records, probably just if filtered by puppetclasses
|
18
|
-
# it seems group by environment is missing
|
19
|
-
# having the uniq to fix that
|
20
|
-
HammerCLI::Output::RecordCollection.new(res.uniq, :meta => res.meta)
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.build_options_for(resource)
|
24
|
-
options = {}
|
25
|
-
options[:without] = [:host_id, :puppetclass_id, :environment_id, :hostgroup_id]
|
26
|
-
options[:expand] = {}
|
27
|
-
options[:expand][:except] = ([:hosts, :puppetclasses, :environments, :hostgroups] - [resource])
|
28
|
-
build_options(options)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
class SmartClassParametersList < SmartClassParametersBriefList
|
33
|
-
|
34
|
-
output do
|
35
|
-
field :puppetclass_name, _("Puppet class")
|
36
|
-
field :puppetclass_id, _("Class Id"), Fields::Id
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
class SmartClassParameter < HammerCLIForeman::Command
|
41
|
-
|
42
|
-
resource :smart_class_parameters
|
43
|
-
|
44
|
-
class ListCommand < HammerCLIForeman::ListCommand
|
45
|
-
|
46
|
-
output SmartClassParametersList.output_definition
|
47
|
-
|
48
|
-
def extend_data(res)
|
49
|
-
res['parameter_type'] ||= 'string'
|
50
|
-
res
|
51
|
-
end
|
52
|
-
|
53
|
-
build_options
|
54
|
-
|
55
|
-
extend_with(HammerCLIForeman::CommandExtensions::PuppetEnvironment.new)
|
56
|
-
end
|
57
|
-
|
58
|
-
class InfoCommand < HammerCLIForeman::InfoCommand
|
59
|
-
|
60
|
-
output ListCommand.output_definition do
|
61
|
-
field :description, _("Description")
|
62
|
-
field :parameter_type, _("Type")
|
63
|
-
field :hidden_value?, _("Hidden Value?")
|
64
|
-
field :omit, _("Omit"), Fields::Boolean
|
65
|
-
field :required, _("Required")
|
66
|
-
|
67
|
-
label _("Validator") do
|
68
|
-
field :validator_type, _("Type")
|
69
|
-
field :validator_rule, _("Rule")
|
70
|
-
end
|
71
|
-
label _("Override values") do
|
72
|
-
field :merge_overrides, _("Merge overrides"), Fields::Boolean
|
73
|
-
field :merge_default, _("Merge default value"), Fields::Boolean
|
74
|
-
field :avoid_duplicates, _("Avoid duplicates"), Fields::Boolean
|
75
|
-
field :override_value_order, _("Order"), Fields::LongText
|
76
|
-
|
77
|
-
collection :override_values, _("Values") do
|
78
|
-
field :id, _('Id')
|
79
|
-
field :match, _('Match')
|
80
|
-
field :value, _('Value')
|
81
|
-
field :omit, _('Omit'), Fields::Boolean
|
82
|
-
end
|
83
|
-
end
|
84
|
-
HammerCLIForeman::References.environments(self)
|
85
|
-
HammerCLIForeman::References.timestamps(self)
|
86
|
-
end
|
87
|
-
|
88
|
-
def extend_data(res)
|
89
|
-
res['parameter_type'] ||= 'string'
|
90
|
-
res['omit'] ||= false
|
91
|
-
res
|
92
|
-
end
|
93
|
-
|
94
|
-
build_options do |options|
|
95
|
-
options.expand.including(:puppetclasses)
|
96
|
-
end
|
97
|
-
|
98
|
-
validate_options do
|
99
|
-
if option(:option_name).exist?
|
100
|
-
any(:option_puppetclass_name, :option_puppetclass_id).required
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
class UpdateCommand < HammerCLIForeman::UpdateCommand
|
106
|
-
|
107
|
-
success_message _("Parameter updated.")
|
108
|
-
failure_message _("Could not update the parameter")
|
109
|
-
|
110
|
-
option '--default-value', 'VALUE', _('Value to use when there is no match')
|
111
|
-
|
112
|
-
build_options do |options|
|
113
|
-
options.expand.including(:puppetclasses)
|
114
|
-
options.without(:parameter_type, :validator_type, :override, :required, :override_value_order)
|
115
|
-
end
|
116
|
-
|
117
|
-
option "--override", "OVERRIDE", _("Override this parameter"),
|
118
|
-
:format => HammerCLI::Options::Normalizers::Bool.new
|
119
|
-
option "--required", "REQUIRED", _("This parameter is required"),
|
120
|
-
:format => HammerCLI::Options::Normalizers::Bool.new
|
121
|
-
option "--parameter-type", "PARAMETER_TYPE", _("Type of the parameter"),
|
122
|
-
:format => HammerCLI::Options::Normalizers::Enum.new(
|
123
|
-
['string', 'boolean', 'integer', 'real', 'array', 'hash', 'yaml', 'json'])
|
124
|
-
option "--validator-type", "VALIDATOR_TYPE", _("Type of the validator"),
|
125
|
-
:format => HammerCLI::Options::Normalizers::Enum.new(['regexp', 'list', ''])
|
126
|
-
option "--override-value-order", "OVERRIDE_VALUE_ORDER", _("The order in which values are resolved"),
|
127
|
-
:format => HammerCLI::Options::Normalizers::List.new
|
128
|
-
|
129
|
-
validate_options do
|
130
|
-
if option(:option_name).exist?
|
131
|
-
any(:option_puppetclass_name, :option_puppetclass_id).required
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
def request_params
|
136
|
-
params = super
|
137
|
-
override_order = params['smart_class_parameter']['override_value_order']
|
138
|
-
params['smart_class_parameter']['override_value_order'] = override_order.join("\n") if override_order.is_a?(Array)
|
139
|
-
params
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
class AddMatcherCommand < HammerCLIForeman::CreateCommand
|
144
|
-
resource :override_values
|
145
|
-
command_name 'add-matcher'
|
146
|
-
|
147
|
-
option '--value', 'VALUE', _('Override value, required if omit is false')
|
148
|
-
|
149
|
-
success_message _("Override value created.")
|
150
|
-
failure_message _("Could not create the override value")
|
151
|
-
|
152
|
-
build_options do |options|
|
153
|
-
options.expand.including(:puppetclasses)
|
154
|
-
end
|
155
|
-
|
156
|
-
validate_options do
|
157
|
-
if option(:option_omit).value
|
158
|
-
option(:option_value).rejected(:msg => _('Cannot use --value when --omit is true.'))
|
159
|
-
end
|
160
|
-
|
161
|
-
if option(:option_smart_class_parameter_name).exist?
|
162
|
-
any(:option_puppetclass_name, :option_puppetclass_id).required
|
163
|
-
end
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
class RemoveMatcherCommand < HammerCLIForeman::DeleteCommand
|
168
|
-
resource :override_values
|
169
|
-
command_name 'remove-matcher'
|
170
|
-
|
171
|
-
success_message _("Override value deleted.")
|
172
|
-
failure_message _("Could not delete the override value")
|
173
|
-
|
174
|
-
build_options do |options|
|
175
|
-
options.expand.including(:puppetclasses)
|
176
|
-
end
|
177
|
-
|
178
|
-
validate_options do
|
179
|
-
if option(:option_smart_class_parameter_name).exist?
|
180
|
-
any(:option_puppetclass_name, :option_puppetclass_id).required
|
181
|
-
end
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
autoload_subcommands
|
186
|
-
|
187
|
-
end
|
188
|
-
|
189
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require File.join(File.dirname(__FILE__), 'test_helper')
|
4
|
-
|
5
|
-
describe 'config_group' do
|
6
|
-
describe 'list' do
|
7
|
-
before do
|
8
|
-
@cmd = %w[config-group list]
|
9
|
-
@config_groups = [{
|
10
|
-
id: 1,
|
11
|
-
name: 'config-group-test',
|
12
|
-
}]
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should return a list of config groups' do
|
16
|
-
api_expects(:config_groups, :index, 'List config groups').returns(@config_groups)
|
17
|
-
|
18
|
-
output = IndexMatcher.new([
|
19
|
-
%w[ID NAME],
|
20
|
-
%w[1 config-group-test]
|
21
|
-
])
|
22
|
-
expected_result = success_result(output)
|
23
|
-
|
24
|
-
result = run_cmd(@cmd)
|
25
|
-
assert_cmd(expected_result, result)
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'should run list command with defaults' do
|
29
|
-
providers = { 'foreman' => HammerCLIForeman::Defaults.new(api_connection({}, '2.1')) }
|
30
|
-
defaults = HammerCLI::Defaults.new(
|
31
|
-
{
|
32
|
-
organization_id: {
|
33
|
-
provider: 'foreman'
|
34
|
-
},
|
35
|
-
location_id: {
|
36
|
-
provider: 'foreman'
|
37
|
-
}
|
38
|
-
}
|
39
|
-
)
|
40
|
-
defaults.stubs(:write_to_file).returns(true)
|
41
|
-
defaults.stubs(:providers).returns(providers)
|
42
|
-
api_expects(:config_groups, :index, 'List config groups').returns(@config_groups)
|
43
|
-
|
44
|
-
result = run_cmd(@cmd, { use_defaults: true, defaults: defaults })
|
45
|
-
_(result.exit_code).must_equal HammerCLI::EX_OK
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
|
@@ -1,86 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
-
|
3
|
-
describe 'proxy' do
|
4
|
-
describe 'import-classes' do
|
5
|
-
let(:cmd) { ['proxy', 'import-classes'] }
|
6
|
-
let(:params) { ['--id=83'] }
|
7
|
-
let(:report) do
|
8
|
-
{
|
9
|
-
'message' => 'Successfully updated environment and puppetclasses from the on-disk puppet installation',
|
10
|
-
'environments_with_new_puppetclasses' => 2,
|
11
|
-
'environments_updated_puppetclasses' => 0,
|
12
|
-
'environments_obsolete' => 0,
|
13
|
-
'environments_ignored' => 0,
|
14
|
-
'results' => [{
|
15
|
-
'name' => 'development',
|
16
|
-
'actions' => [ 'new', 'update' ],
|
17
|
-
'new_puppetclasses' => [
|
18
|
-
'motd',
|
19
|
-
'hammer'
|
20
|
-
],
|
21
|
-
'updated_puppetclasses' => [
|
22
|
-
'stdlib',
|
23
|
-
'vim'
|
24
|
-
]
|
25
|
-
},{
|
26
|
-
'name' => 'production',
|
27
|
-
'actions' => [ 'obsolete', 'ignore' ],
|
28
|
-
'obsolete_puppetclasses' => [
|
29
|
-
'apache'
|
30
|
-
],
|
31
|
-
'ignored_puppetclasses' => [
|
32
|
-
'hammer'
|
33
|
-
]
|
34
|
-
}]
|
35
|
-
}
|
36
|
-
end
|
37
|
-
let(:no_change_report) do
|
38
|
-
{
|
39
|
-
'message' => 'No changes to your environments detected'
|
40
|
-
}
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'prints detailed report' do
|
44
|
-
api_expects(:smart_proxies, :import_puppetclasses, 'Import classes')
|
45
|
-
.with_params('id' => '83')
|
46
|
-
.returns(report)
|
47
|
-
|
48
|
-
output = OutputMatcher.new([
|
49
|
-
'Result:',
|
50
|
-
' Successfully updated environment and puppetclasses from the on-disk puppet installation',
|
51
|
-
'Changed environments:',
|
52
|
-
' 1) development',
|
53
|
-
' New classes:',
|
54
|
-
' motd',
|
55
|
-
' hammer',
|
56
|
-
' Updated classes:',
|
57
|
-
' stdlib',
|
58
|
-
' vim',
|
59
|
-
' 2) production',
|
60
|
-
' Removed classes:',
|
61
|
-
' apache',
|
62
|
-
' Ignored classes:',
|
63
|
-
' hammer'
|
64
|
-
])
|
65
|
-
expected_result = success_result(output)
|
66
|
-
|
67
|
-
result = run_cmd(cmd + params)
|
68
|
-
assert_cmd(expected_result, result)
|
69
|
-
end
|
70
|
-
|
71
|
-
it 'prints a message when nothig has changed' do
|
72
|
-
api_expects(:smart_proxies, :import_puppetclasses, 'Import classes')
|
73
|
-
.with_params('id' => '83')
|
74
|
-
.returns(no_change_report)
|
75
|
-
|
76
|
-
output = OutputMatcher.new([
|
77
|
-
'Result:',
|
78
|
-
' No changes to your environments detected'
|
79
|
-
])
|
80
|
-
expected_result = success_result(output)
|
81
|
-
|
82
|
-
result = run_cmd(cmd + params)
|
83
|
-
assert_cmd(expected_result, result)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
@@ -1,97 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
-
|
3
|
-
|
4
|
-
describe 'sc-params update' do
|
5
|
-
let(:cmd) { %w(sc-param update) }
|
6
|
-
|
7
|
-
it 'does not allow to update parameter name' do
|
8
|
-
params = ['--id=1', '--new-name=name2']
|
9
|
-
|
10
|
-
expected_result = usage_error_result(
|
11
|
-
cmd,
|
12
|
-
"Unrecognised option '--new-name'.",
|
13
|
-
"Could not update the parameter"
|
14
|
-
)
|
15
|
-
|
16
|
-
api_expects_no_call
|
17
|
-
result = run_cmd(cmd + params)
|
18
|
-
assert_cmd(expected_result, result)
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
describe 'sc-params add-matcher' do
|
24
|
-
let(:cmd) { %w(sc-param add-matcher) }
|
25
|
-
let(:override_value) { 'something' }
|
26
|
-
let(:match) { 'domain = example.com' }
|
27
|
-
let(:puppet_class) { { 'name' => 'motd', 'id' => '1' } }
|
28
|
-
let(:parameter) { { 'name' => 'content', 'id' => '2' } }
|
29
|
-
let(:base) { [
|
30
|
-
'--puppet-class', puppet_class['name'],
|
31
|
-
'--smart-class-parameter', parameter['name'],
|
32
|
-
'--match', match
|
33
|
-
] }
|
34
|
-
|
35
|
-
def api_expects_parameter_search(puppet_class, parameter)
|
36
|
-
api_expects(:puppetclasses, :index, 'Find puppet class') do |par|
|
37
|
-
par[:search] == %Q(name = "#{puppet_class['name']}")
|
38
|
-
end.returns(index_response('motd' => [puppet_class]))
|
39
|
-
|
40
|
-
api_expects(:smart_class_parameters, :index, 'Find smart parameter') do |par|
|
41
|
-
par[:search] == %Q(key = "#{parameter['name']}") &&
|
42
|
-
par[:puppetclass_id] == puppet_class['id']
|
43
|
-
end.returns(index_response([parameter]))
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'allows to set value' do
|
47
|
-
params = ['--value', override_value]
|
48
|
-
expected_result = success_result("Override value created.\n")
|
49
|
-
|
50
|
-
api_expects_parameter_search(puppet_class, parameter)
|
51
|
-
|
52
|
-
api_expects(:override_values, :create, 'Create override value').with_params(
|
53
|
-
:smart_class_parameter_id => parameter['id'],
|
54
|
-
:override_value => {
|
55
|
-
:match => match,
|
56
|
-
:value => override_value
|
57
|
-
}
|
58
|
-
)
|
59
|
-
|
60
|
-
result = run_cmd(cmd + base + params)
|
61
|
-
assert_cmd(expected_result, result)
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'allows to set value with disabled puppet default' do
|
65
|
-
params = ['--value', override_value, '--omit', false]
|
66
|
-
expected_result = success_result("Override value created.\n")
|
67
|
-
|
68
|
-
api_expects_parameter_search(puppet_class, parameter)
|
69
|
-
|
70
|
-
api_expects(:override_values, :create, 'Create override value').with_params(
|
71
|
-
:smart_class_parameter_id => parameter['id'],
|
72
|
-
:override_value => {
|
73
|
-
:match => match,
|
74
|
-
:value => override_value,
|
75
|
-
:omit => false
|
76
|
-
}
|
77
|
-
)
|
78
|
-
|
79
|
-
result = run_cmd(cmd + base + params)
|
80
|
-
assert_cmd(expected_result, result)
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'does not allow to use puppet default and value at the same time' do
|
84
|
-
params = ['--value', 'something', '--omit', true]
|
85
|
-
|
86
|
-
expected_result = usage_error_result(
|
87
|
-
cmd,
|
88
|
-
"Cannot use --value when --omit is true.",
|
89
|
-
'Could not create the override value'
|
90
|
-
)
|
91
|
-
|
92
|
-
api_expects_parameter_search(puppet_class, parameter)
|
93
|
-
|
94
|
-
result = run_cmd(cmd + base + params)
|
95
|
-
assert_cmd(expected_result, result)
|
96
|
-
end
|
97
|
-
end
|
@@ -1,82 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
-
require File.join(File.dirname(__FILE__), 'apipie_resource_mock')
|
3
|
-
|
4
|
-
require 'hammer_cli_foreman/config_group'
|
5
|
-
|
6
|
-
describe HammerCLIForeman::ConfigGroup do
|
7
|
-
include CommandTestHelper
|
8
|
-
|
9
|
-
context "ListCommand" do
|
10
|
-
let(:cmd) { HammerCLIForeman::ConfigGroup::ListCommand.new("", ctx) }
|
11
|
-
|
12
|
-
before :each do
|
13
|
-
ResourceMocks.config_groups_index
|
14
|
-
end
|
15
|
-
|
16
|
-
context "parameters" do
|
17
|
-
it_should_accept "no arguments"
|
18
|
-
it_should_accept_search_params
|
19
|
-
it_should_fail_with 'organization param', ['--organization-id=1']
|
20
|
-
it_should_fail_with 'location param', ['--location-id=1']
|
21
|
-
end
|
22
|
-
|
23
|
-
context "output" do
|
24
|
-
let(:expected_record_count) { cmd.resource.call(:index).length }
|
25
|
-
it_should_print_n_records
|
26
|
-
it_should_print_columns ["ID", "Name"]
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
context "InfoCommand" do
|
31
|
-
let(:cmd) { HammerCLIForeman::ConfigGroup::InfoCommand.new("", ctx) }
|
32
|
-
|
33
|
-
context "parameters" do
|
34
|
-
it_should_accept "id", ["--id=1"]
|
35
|
-
it_should_accept "name", ["--name=group_x"]
|
36
|
-
it_should_fail_with 'organization param', ['--organization-id=1']
|
37
|
-
it_should_fail_with 'location param', ['--location-id=1']
|
38
|
-
end
|
39
|
-
|
40
|
-
context "output" do
|
41
|
-
with_params ["--id=1"] do
|
42
|
-
it_should_print_n_records 1
|
43
|
-
it_should_print_column "Name"
|
44
|
-
it_should_print_column "ID"
|
45
|
-
it_should_print_column "Puppetclasses"
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context "CreateCommand" do
|
51
|
-
let(:cmd) { HammerCLIForeman::ConfigGroup::CreateCommand.new("", ctx) }
|
52
|
-
|
53
|
-
context "parameters" do
|
54
|
-
it_should_accept "name, puppetclass ids", ["--name=first_group", "--puppet-class-ids=1,2"]
|
55
|
-
it_should_fail_with 'organization param', ['--organization-id=1']
|
56
|
-
it_should_fail_with 'location param', ['--location-id=1']
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
context "DeleteCommand" do
|
61
|
-
let(:cmd) { HammerCLIForeman::ConfigGroup::DeleteCommand.new("", ctx) }
|
62
|
-
|
63
|
-
context "parameters" do
|
64
|
-
it_should_accept "name", ["--name=group_x"]
|
65
|
-
it_should_accept "id", ["--id=1"]
|
66
|
-
it_should_fail_with 'organization param', ['--organization-id=1']
|
67
|
-
it_should_fail_with 'location param', ['--location-id=1']
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
context "UpdateCommand" do
|
72
|
-
|
73
|
-
let(:cmd) { HammerCLIForeman::ConfigGroup::UpdateCommand.new("", ctx) }
|
74
|
-
|
75
|
-
context "parameters" do
|
76
|
-
it_should_accept "name", ["--name=group_x"]
|
77
|
-
it_should_accept "id", ["--id=1"]
|
78
|
-
it_should_fail_with 'organization param', ['--organization-id=1']
|
79
|
-
it_should_fail_with 'location param', ['--location-id=1']
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
-
require File.join(File.dirname(__FILE__), 'apipie_resource_mock')
|
3
|
-
|
4
|
-
require 'hammer_cli_foreman/puppet_class'
|
5
|
-
|
6
|
-
describe HammerCLIForeman::PuppetClass do
|
7
|
-
|
8
|
-
include CommandTestHelper
|
9
|
-
|
10
|
-
context "ListCommand" do
|
11
|
-
before do
|
12
|
-
ResourceMocks.mock_action_call(:puppetclasses, :index, {})
|
13
|
-
end
|
14
|
-
|
15
|
-
let(:cmd) { HammerCLIForeman::PuppetClass::ListCommand.new("", ctx) }
|
16
|
-
|
17
|
-
context "parameters" do
|
18
|
-
it_should_accept "no arguments"
|
19
|
-
# FIXME: the command should accept search parameters in future
|
20
|
-
# it_should_accept_search_params
|
21
|
-
end
|
22
|
-
|
23
|
-
context "output" do
|
24
|
-
let(:expected_record_count) do
|
25
|
-
# data are retuned in specific format
|
26
|
-
HammerCLIForeman.collection_to_common_format(cmd.resource.call(:index)).first.keys.count
|
27
|
-
end
|
28
|
-
|
29
|
-
it_should_print_n_records
|
30
|
-
it_should_print_column "Id"
|
31
|
-
it_should_print_column "Name"
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
context "InfoCommand" do
|
38
|
-
|
39
|
-
let(:cmd) { HammerCLIForeman::PuppetClass::InfoCommand.new("", ctx) }
|
40
|
-
|
41
|
-
context "parameters" do
|
42
|
-
it_should_accept "id", ["--id=1"]
|
43
|
-
# it_should_fail_with "no arguments" # TODO: temporarily disabled, parameters are checked in the id resolver
|
44
|
-
end
|
45
|
-
|
46
|
-
context "output" do
|
47
|
-
with_params ["--id=1"] do
|
48
|
-
it_should_print_n_records 1
|
49
|
-
it_should_print_column "Id"
|
50
|
-
it_should_print_column "Name"
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
55
|
-
|
56
|
-
context "SCParamsCommand" do
|
57
|
-
|
58
|
-
before :each do
|
59
|
-
ResourceMocks.smart_class_parameters_index
|
60
|
-
end
|
61
|
-
|
62
|
-
let(:cmd) { HammerCLIForeman::PuppetClass::SCParamsCommand.new("", ctx) }
|
63
|
-
|
64
|
-
context "parameters" do
|
65
|
-
it_should_accept "puppet-class", ["--puppet-class=cls"]
|
66
|
-
it_should_accept "puppet-class-id", ["--puppet-class-id=1"]
|
67
|
-
# it_should_fail_with "name or id missing", [] # TODO: temporarily disabled, parameters are checked in the id resolver
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|
@@ -1,114 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
-
require File.join(File.dirname(__FILE__), 'apipie_resource_mock')
|
3
|
-
|
4
|
-
require 'hammer_cli_foreman/puppet_environment'
|
5
|
-
|
6
|
-
describe HammerCLIForeman::PuppetEnvironment do
|
7
|
-
|
8
|
-
include CommandTestHelper
|
9
|
-
|
10
|
-
context "ListCommand" do
|
11
|
-
before do
|
12
|
-
ResourceMocks.mock_action_call(:environments, :index, [])
|
13
|
-
end
|
14
|
-
|
15
|
-
let(:cmd) { HammerCLIForeman::PuppetEnvironment::ListCommand.new("", ctx) }
|
16
|
-
|
17
|
-
context "parameters" do
|
18
|
-
it_should_accept "no arguments"
|
19
|
-
it_should_accept_search_params
|
20
|
-
end
|
21
|
-
|
22
|
-
context "output" do
|
23
|
-
let(:expected_record_count) { count_records(cmd.resource.call(:index)) }
|
24
|
-
|
25
|
-
it_should_print_n_records
|
26
|
-
it_should_print_column "Name"
|
27
|
-
it_should_print_column "Id"
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
|
33
|
-
context "InfoCommand" do
|
34
|
-
|
35
|
-
let(:cmd) { HammerCLIForeman::PuppetEnvironment::InfoCommand.new("", ctx) }
|
36
|
-
|
37
|
-
context "parameters" do
|
38
|
-
it_should_accept "id", ["--id=1"]
|
39
|
-
it_should_accept "name", ["--name=env"]
|
40
|
-
# it_should_fail_with "no arguments"
|
41
|
-
# TODO: temporarily disabled, parameters are checked in the id resolver
|
42
|
-
end
|
43
|
-
|
44
|
-
context "output" do
|
45
|
-
with_params ["--id=1"] do
|
46
|
-
it_should_print_n_records 1
|
47
|
-
it_should_print_column "Name"
|
48
|
-
it_should_print_column "Id"
|
49
|
-
it_should_print_column "Created at"
|
50
|
-
it_should_print_column "Updated at"
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
55
|
-
|
56
|
-
|
57
|
-
context "CreateCommand" do
|
58
|
-
|
59
|
-
let(:cmd) { HammerCLIForeman::PuppetEnvironment::CreateCommand.new("", ctx) }
|
60
|
-
|
61
|
-
context "parameters" do
|
62
|
-
it_should_accept "name", ["--name=env"]
|
63
|
-
# it_should_fail_with "name missing", []
|
64
|
-
# TODO: temporarily disabled, parameters are checked by the api
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|
68
|
-
|
69
|
-
|
70
|
-
context "DeleteCommand" do
|
71
|
-
|
72
|
-
let(:cmd) { HammerCLIForeman::PuppetEnvironment::DeleteCommand.new("", ctx) }
|
73
|
-
|
74
|
-
context "parameters" do
|
75
|
-
it_should_accept "name", ["--name=env"]
|
76
|
-
it_should_accept "id", ["--id=1"]
|
77
|
-
# it_should_fail_with "name or id missing", [] # TODO: temporarily disabled, parameters are checked in the id resolver
|
78
|
-
end
|
79
|
-
|
80
|
-
end
|
81
|
-
|
82
|
-
|
83
|
-
context "UpdateCommand" do
|
84
|
-
|
85
|
-
let(:cmd) { HammerCLIForeman::PuppetEnvironment::UpdateCommand.new("", ctx) }
|
86
|
-
|
87
|
-
context "parameters" do
|
88
|
-
it_should_accept "name", ["--name=env", "--new-name=env2"]
|
89
|
-
it_should_accept "id", ["--id=1", "--new-name=env2"]
|
90
|
-
# it_should_fail_with "no params", [] # TODO: temporarily disabled, parameters are checked in the id resolver
|
91
|
-
# it_should_fail_with "name or id missing", ["--new-name=env2"] # TODO: temporarily disabled, parameters are checked in the id resolver
|
92
|
-
end
|
93
|
-
|
94
|
-
end
|
95
|
-
|
96
|
-
context "SCParamsCommand" do
|
97
|
-
|
98
|
-
before :each do
|
99
|
-
ResourceMocks.smart_class_parameters_index
|
100
|
-
end
|
101
|
-
|
102
|
-
let(:cmd) { HammerCLIForeman::PuppetEnvironment::SCParamsCommand.new("", ctx) }
|
103
|
-
|
104
|
-
context "parameters" do
|
105
|
-
it_should_accept "environment", ["--environment=env"]
|
106
|
-
it_should_accept "environment-id", ["--environment-id=1"]
|
107
|
-
it_should_accept "puppet-environment", ["--puppet-environment=env"]
|
108
|
-
it_should_accept "puppet-environment-id", ["--puppet-environment-id=1"]
|
109
|
-
# it_should_fail_with "name or id missing", [] # TODO: temporarily disabled, parameters are checked in the id resolver
|
110
|
-
end
|
111
|
-
|
112
|
-
end
|
113
|
-
|
114
|
-
end
|