hammer_cli_foreman 2.3.2 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes.md +33 -3
  3. data/lib/hammer_cli_foreman.rb +3 -21
  4. data/lib/hammer_cli_foreman/associating_commands.rb +0 -24
  5. data/lib/hammer_cli_foreman/bookmark.rb +1 -1
  6. data/lib/hammer_cli_foreman/combination.rb +3 -13
  7. data/lib/hammer_cli_foreman/command_extensions.rb +1 -2
  8. data/lib/hammer_cli_foreman/command_extensions/ping.rb +21 -2
  9. data/lib/hammer_cli_foreman/command_extensions/status.rb +1 -1
  10. data/lib/hammer_cli_foreman/command_extensions/update_common.rb +14 -0
  11. data/lib/hammer_cli_foreman/commands.rb +16 -9
  12. data/lib/hammer_cli_foreman/compute_resource.rb +22 -0
  13. data/lib/hammer_cli_foreman/compute_resource/ovirt.rb +2 -1
  14. data/lib/hammer_cli_foreman/config_report.rb +2 -0
  15. data/lib/hammer_cli_foreman/filter.rb +2 -2
  16. data/lib/hammer_cli_foreman/host.rb +1 -47
  17. data/lib/hammer_cli_foreman/hostgroup.rb +2 -53
  18. data/lib/hammer_cli_foreman/hosts/common_update_options.rb +7 -28
  19. data/lib/hammer_cli_foreman/id_resolver.rb +0 -61
  20. data/lib/hammer_cli_foreman/location.rb +0 -6
  21. data/lib/hammer_cli_foreman/operating_system.rb +2 -1
  22. data/lib/hammer_cli_foreman/option_builders.rb +6 -5
  23. data/lib/hammer_cli_foreman/option_sources.rb +0 -1
  24. data/lib/hammer_cli_foreman/option_sources/id_params.rb +27 -10
  25. data/lib/hammer_cli_foreman/option_sources/ids_params.rb +25 -6
  26. data/lib/hammer_cli_foreman/organization.rb +0 -6
  27. data/lib/hammer_cli_foreman/ping.rb +6 -1
  28. data/lib/hammer_cli_foreman/references.rb +0 -16
  29. data/lib/hammer_cli_foreman/registration.rb +18 -0
  30. data/lib/hammer_cli_foreman/smart_proxy.rb +0 -52
  31. data/lib/hammer_cli_foreman/version.rb +1 -1
  32. data/lib/minitest/coverage_reporter.rb +1 -1
  33. data/locale/ca/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  34. data/locale/de/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  35. data/locale/en/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  36. data/locale/en_GB/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  37. data/locale/es/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  38. data/locale/fr/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  39. data/locale/it/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  40. data/locale/ja/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  41. data/locale/ko/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  42. data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  43. data/locale/ru/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  44. data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  45. data/locale/zh_TW/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  46. data/test/data/2.4/foreman_api.json +1 -0
  47. data/test/data/2.5/foreman_api.json +1 -0
  48. data/test/functional/architecture_test.rb +81 -0
  49. data/test/functional/bookmark_test.rb +24 -1
  50. data/test/functional/compute_profile_test.rb +56 -0
  51. data/test/functional/compute_resource_test.rb +37 -0
  52. data/test/functional/filter_test.rb +115 -47
  53. data/test/functional/host_test.rb +94 -13
  54. data/test/functional/hostgroup/create_test.rb +0 -117
  55. data/test/functional/hostgroup/update_test.rb +0 -79
  56. data/test/functional/http_proxy_test.rb +12 -0
  57. data/test/functional/location_test.rb +13 -3
  58. data/test/functional/mail_notification_test.rb +22 -0
  59. data/test/functional/media_test.rb +11 -0
  60. data/test/functional/model_test.rb +52 -0
  61. data/test/functional/operating_system_test.rb +53 -0
  62. data/test/functional/ping_test.rb +33 -0
  63. data/test/functional/realm_test.rb +11 -0
  64. data/test/functional/registration_test.rb +8 -0
  65. data/test/functional/report_template_test.rb +11 -0
  66. data/test/functional/settings_test.rb +21 -0
  67. data/test/functional/status_test.rb +79 -13
  68. data/test/functional/template_test.rb +16 -37
  69. data/test/functional/user_test.rb +11 -0
  70. data/test/functional/usergroup_test.rb +53 -0
  71. data/test/test_helper.rb +1 -1
  72. data/test/unit/apipie_resource_mock.rb +22 -39
  73. data/test/unit/architecture_test.rb +10 -1
  74. data/test/unit/bookmark_test.rb +95 -0
  75. data/test/unit/compute_profile_test.rb +87 -0
  76. data/test/unit/config_report_test.rb +1 -0
  77. data/test/unit/helpers/command.rb +0 -8
  78. data/test/unit/host_test.rb +14 -61
  79. data/test/unit/hostgroup_test.rb +7 -26
  80. data/test/unit/id_resolver_test.rb +0 -28
  81. data/test/unit/mail_notification_test.rb +53 -0
  82. data/test/unit/model_test.rb +47 -37
  83. data/test/unit/operating_system_test.rb +10 -3
  84. data/test/unit/option_sources/id_params_test.rb +9 -0
  85. data/test/unit/option_sources/ids_params_test.rb +9 -0
  86. data/test/unit/settings_test.rb +4 -0
  87. data/test/unit/smart_proxy_test.rb +0 -12
  88. data/test/unit/usergroup_test.rb +10 -0
  89. metadata +76 -73
  90. data/lib/hammer_cli_foreman/command_extensions/puppet_environment.rb +0 -29
  91. data/lib/hammer_cli_foreman/command_extensions/puppet_environments.rb +0 -29
  92. data/lib/hammer_cli_foreman/config_group.rb +0 -45
  93. data/lib/hammer_cli_foreman/option_sources/puppet_environment_params.rb +0 -59
  94. data/lib/hammer_cli_foreman/puppet_class.rb +0 -61
  95. data/lib/hammer_cli_foreman/puppet_environment.rb +0 -65
  96. data/lib/hammer_cli_foreman/smart_class_parameter.rb +0 -189
  97. data/test/functional/proxy_test.rb +0 -86
  98. data/test/functional/smart_class_parameter_test.rb +0 -97
  99. data/test/unit/config_group_test.rb +0 -72
  100. data/test/unit/puppet_class_test.rb +0 -72
  101. data/test/unit/puppet_environment_test.rb +0 -114
  102. data/test/unit/smart_class_parameter_test.rb +0 -113
@@ -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,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/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
- end
20
-
21
- context "output" do
22
- let(:expected_record_count) { cmd.resource.call(:index).length }
23
- it_should_print_n_records
24
- it_should_print_columns ["ID", "Name"]
25
- end
26
- end
27
-
28
- context "InfoCommand" do
29
- let(:cmd) { HammerCLIForeman::ConfigGroup::InfoCommand.new("", ctx) }
30
-
31
- context "parameters" do
32
- it_should_accept "id", ["--id=1"]
33
- it_should_accept "name", ["--name=group_x"]
34
- end
35
-
36
- context "output" do
37
- with_params ["--id=1"] do
38
- it_should_print_n_records 1
39
- it_should_print_column "Name"
40
- it_should_print_column "ID"
41
- it_should_print_column "Puppetclasses"
42
- end
43
- end
44
- end
45
-
46
- context "CreateCommand" do
47
- let(:cmd) { HammerCLIForeman::ConfigGroup::CreateCommand.new("", ctx) }
48
-
49
- context "parameters" do
50
- it_should_accept "name, puppetclass ids", ["--name=first_group", "--puppet-class-ids=1,2"]
51
- end
52
- end
53
-
54
- context "DeleteCommand" do
55
- let(:cmd) { HammerCLIForeman::ConfigGroup::DeleteCommand.new("", ctx) }
56
-
57
- context "parameters" do
58
- it_should_accept "name", ["--name=group_x"]
59
- it_should_accept "id", ["--id=1"]
60
- end
61
- end
62
-
63
- context "UpdateCommand" do
64
-
65
- let(:cmd) { HammerCLIForeman::ConfigGroup::UpdateCommand.new("", ctx) }
66
-
67
- context "parameters" do
68
- it_should_accept "name", ["--name=group_x"]
69
- it_should_accept "id", ["--id=1"]
70
- end
71
- end
72
- 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
@@ -1,113 +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/smart_class_parameter'
5
-
6
- describe HammerCLIForeman::SmartClassParameter do
7
-
8
- include CommandTestHelper
9
-
10
- context "ListCommand" do
11
-
12
- before :each do
13
- ResourceMocks.smart_class_parameters_index
14
- end
15
-
16
- let(:cmd) { HammerCLIForeman::SmartClassParameter::ListCommand.new("", ctx) }
17
-
18
- context "parameters" do
19
- it_should_accept "no arguments"
20
- it_should_accept "hostgroup id", ["--hostgroup-id=1"]
21
- it_should_accept "host id", ["--host-id=1"]
22
- it_should_accept "environment id", ["--environment-id=1"]
23
- it_should_accept "puppet-class-id", ["--puppet-class-id=1"]
24
- it_should_accept_search_params
25
- end
26
-
27
- context "output" do
28
- let(:expected_record_count) { count_records(cmd.resource.call(:index)) }
29
-
30
- it_should_print_n_records
31
- it_should_print_column "Id"
32
- it_should_print_column "Class Id"
33
- it_should_print_column "Puppet class"
34
- it_should_print_column "Parameter"
35
- it_should_print_column "Default Value"
36
- it_should_print_column "Override"
37
- end
38
-
39
- end
40
-
41
-
42
- context "InfoCommand" do
43
-
44
- before :each do
45
- ResourceMocks.smart_class_parameters_show
46
- end
47
-
48
- let(:cmd) { HammerCLIForeman::SmartClassParameter::InfoCommand.new("", ctx) }
49
-
50
- context "parameters" do
51
- it_should_accept "id", ["--id=1"]
52
- it_should_accept "name, puppet-class", ["--name=par", "--puppet-class=ntp"]
53
- it_should_fail_with "name", ["--name=par"]
54
- # it_should_fail_with "no arguments"
55
- # TODO: temporarily disabled, parameters are checked in the id resolver
56
- end
57
-
58
- context "output" do
59
- with_params ["--id=1"] do
60
- it_should_print_n_records 1
61
- it_should_print_columns ["Description", "Type", "Omit", "Required"]
62
- end
63
- end
64
- end
65
-
66
-
67
- context "UpdateCommand" do
68
-
69
- let(:cmd) { HammerCLIForeman::SmartClassParameter::UpdateCommand.new("", ctx) }
70
-
71
- context "parameters" do
72
- it_should_accept "id", ["--id=1"]
73
- it_should_accept "name, puppet-class", ["--name=par", "--puppet-class=ntp"]
74
- it_should_fail_with "name", ["--name=par"]
75
- it_should_accept "override", ["--id=1","--override=true"]
76
- it_should_accept "description", ["--id=1","--description=descr"]
77
- it_should_accept "default-value", ["--id=1","--default-value=1"]
78
- it_should_accept "path ", ["--id=1","--path=path"]
79
- it_should_accept "validator-type", ["--id=1","--validator-type=list"]
80
- it_should_accept "validator-rule ", ["--id=1","--validator-rule=''"]
81
- it_should_accept "override-value-order", ["--id=1","--override-value-order=fqdn"]
82
- it_should_accept "parameter-type ", ["--id=1","--parameter-type=string"]
83
- it_should_accept "required", ["--id=1","--required=true"]
84
-
85
- # it_should_fail_with "no params", []
86
- # TODO: temporarily disabled, parameters are checked in the id resolver
87
- end
88
-
89
- end
90
-
91
- context "AddMatcherCommand" do
92
-
93
- let(:cmd) { HammerCLIForeman::SmartClassParameter::AddMatcherCommand.new("", ctx) }
94
-
95
- context "parameters" do
96
- it_should_accept "smart-class-parametr-id, match, value", ["--smart-class-parameter-id=1", "--match='domain=my.lan'", "--value=1"]
97
- it_should_accept "smart-class-parameter, puppet-class, match, value", ["--smart-class-parameter=par", "--puppet-class=ntp", "--match='domain=my.lan'", "--value=1"]
98
- it_should_fail_with "smart-class-parameter, match, value", ["--smart-class-parameter=par", "--match='domain=my.lan'", "--value=1"]
99
- end
100
- end
101
-
102
- context "RemoveMatcherCommand" do
103
-
104
- let(:cmd) { HammerCLIForeman::SmartClassParameter::RemoveMatcherCommand.new("", ctx) }
105
-
106
- context "parameters" do
107
- it_should_accept "smart-class-parametr-id, id", ["--smart-class-parameter-id=1", "--id=1"]
108
- it_should_accept "smart-class-parameter, puppet-class, id", ["--smart-class-parameter=par", "--puppet-class=ntp", "--id=1"]
109
- it_should_fail_with "smart-class-parameter, id", ["--smart-class-parameter=par", "--id=1"]
110
- end
111
- end
112
-
113
- end