hammer_cli_foreman_puppet 0.0.6 → 0.1.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.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hammer_cli_foreman_puppet/associating_commands.rb +1 -1
  3. data/lib/hammer_cli_foreman_puppet/class.rb +1 -3
  4. data/lib/hammer_cli_foreman_puppet/combination.rb +0 -1
  5. data/lib/hammer_cli_foreman_puppet/command_extensions/combination.rb +3 -3
  6. data/lib/hammer_cli_foreman_puppet/commands.rb +3 -2
  7. data/lib/hammer_cli_foreman_puppet/host.rb +4 -5
  8. data/lib/hammer_cli_foreman_puppet/hostgroup.rb +7 -8
  9. data/lib/hammer_cli_foreman_puppet/i18n.rb +2 -2
  10. data/lib/hammer_cli_foreman_puppet/id_resolver.rb +5 -5
  11. data/lib/hammer_cli_foreman_puppet/option_sources/puppet_environment_params.rb +1 -2
  12. data/lib/hammer_cli_foreman_puppet/puppet_references.rb +0 -1
  13. data/lib/hammer_cli_foreman_puppet/smart_class_parameter.rb +6 -6
  14. data/lib/hammer_cli_foreman_puppet/smart_proxy.rb +2 -2
  15. data/lib/hammer_cli_foreman_puppet/version.rb +1 -1
  16. data/locale/cs_CZ/LC_MESSAGES/hammer-cli-foreman-puppet.mo +0 -0
  17. data/locale/cs_CZ/hammer-cli-foreman-puppet.po +282 -0
  18. data/locale/de/LC_MESSAGES/hammer-cli-foreman-puppet.mo +0 -0
  19. data/locale/de/hammer-cli-foreman-puppet.po +293 -0
  20. data/locale/en/LC_MESSAGES/hammer-cli-foreman-puppet.mo +0 -0
  21. data/locale/en/hammer-cli-foreman-puppet.po +276 -0
  22. data/locale/es/LC_MESSAGES/hammer-cli-foreman-puppet.mo +0 -0
  23. data/locale/es/hammer-cli-foreman-puppet.po +287 -0
  24. data/locale/fr/LC_MESSAGES/hammer-cli-foreman-puppet.mo +0 -0
  25. data/locale/fr/hammer-cli-foreman-puppet.po +285 -0
  26. data/locale/hammer-cli-foreman-puppet.pot +386 -0
  27. data/locale/ja/LC_MESSAGES/hammer-cli-foreman-puppet.mo +0 -0
  28. data/locale/ja/hammer-cli-foreman-puppet.po +283 -0
  29. data/locale/ka/LC_MESSAGES/hammer-cli-foreman-puppet.mo +0 -0
  30. data/locale/ka/hammer-cli-foreman-puppet.po +280 -0
  31. data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman-puppet.mo +0 -0
  32. data/locale/pt_BR/hammer-cli-foreman-puppet.po +288 -0
  33. data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman-puppet.mo +0 -0
  34. data/locale/zh_CN/hammer-cli-foreman-puppet.po +283 -0
  35. metadata +31 -57
  36. data/test/data/2.1/foreman_api.json +0 -1
  37. data/test/data/3.0/foreman_api.json +0 -1
  38. data/test/data/3.3/foreman_api.json +0 -1
  39. data/test/data/README.md +0 -27
  40. data/test/functional/config_group_test.rb +0 -28
  41. data/test/functional/host/create_test.rb +0 -195
  42. data/test/functional/host/update_test.rb +0 -126
  43. data/test/functional/hostgroup/create_test.rb +0 -178
  44. data/test/functional/hostgroup/update_test.rb +0 -126
  45. data/test/functional/proxy_test.rb +0 -86
  46. data/test/functional/smart_class_parameter_test.rb +0 -97
  47. data/test/functional/template_test.rb +0 -38
  48. data/test/functional/test_helper.rb +0 -7
  49. data/test/test_helper.rb +0 -29
  50. data/test/unit/apipie_resource_mock.rb +0 -186
  51. data/test/unit/config_group_test.rb +0 -73
  52. data/test/unit/helpers/command.rb +0 -163
  53. data/test/unit/helpers/fake_searchables.rb +0 -19
  54. data/test/unit/helpers/resource_disabled.rb +0 -24
  55. data/test/unit/puppet_class_test.rb +0 -72
  56. data/test/unit/puppet_environment_test.rb +0 -116
  57. data/test/unit/smart_class_parameter_test.rb +0 -114
  58. data/test/unit/test_helper.rb +0 -18
  59. data/test/unit/test_output_adapter.rb +0 -22
@@ -1,19 +0,0 @@
1
-
2
-
3
- class FakeSearchables
4
-
5
- def initialize(searchable_fields, editable_fields = [])
6
- @searchables = []
7
- @searchables += searchable_fields.collect do |name|
8
- HammerCLIForeman::Searchable.new(name, "Search by #{name}", :editable => false)
9
- end
10
- @searchables += editable_fields.collect do |name|
11
- HammerCLIForeman::Searchable.new(name, "Search by #{name}", :editable => true)
12
- end
13
- end
14
-
15
- def for(resource)
16
- @searchables
17
- end
18
-
19
- end
@@ -1,24 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../apipie_resource_mock')
2
-
3
- module ResourceDisabled
4
-
5
- def it_should_fail_when_disabled
6
- arguments = @with_params ? @with_params.dup : []
7
- context "resource disabled" do
8
-
9
- it "should return error" do
10
- cmd.class.resource.stubs(:call).raises(RestClient::ResourceNotFound)
11
- arguments = respond_to?(:with_params) ? with_params : []
12
- _(cmd.run(arguments)).must_equal HammerCLI::EX_UNAVAILABLE
13
- end
14
-
15
- it "should print error message" do
16
- cmd.class.resource.stubs(:call).raises(RestClient::ResourceNotFound)
17
- cmd.stubs(:context).returns(ctx.update(:adapter => :test))
18
-
19
- arguments = respond_to?(:with_params) ? with_params : []
20
- _(lambda { cmd.run(arguments) }).must_output "", /.*not support.*/
21
- end
22
- end
23
- end
24
- 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 HammerCLIForemanPuppet::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) { HammerCLIForemanPuppet::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
- HammerCLIForemanPuppet.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) { HammerCLIForemanPuppet::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) { HammerCLIForemanPuppet::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,116 +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 HammerCLIForemanPuppet::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) { HammerCLIForemanPuppet::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) { HammerCLIForemanPuppet::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) { HammerCLIForemanPuppet::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) { HammerCLIForemanPuppet::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) { HammerCLIForemanPuppet::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) { HammerCLIForemanPuppet::PuppetEnvironment::SCParamsCommand.new("", ctx) }
103
-
104
- context "parameters" do
105
- it_should_fail_with "environment", ["--environment=env"]
106
- it_should_accept "puppet environment", ["--puppet-environment=env"]
107
- it_should_fail_with "environment-id", ["--environment-id=1"]
108
- it_should_accept "puppet-environment-id", ["--puppet-environment-id=1"]
109
- it_should_accept "puppet-environment", ["--puppet-environment=env"]
110
- it_should_accept "puppet-environment-id", ["--puppet-environment-id=1"]
111
- # it_should_fail_with "name or id missing", [] # TODO: temporarily disabled, parameters are checked in the id resolver
112
- end
113
-
114
- end
115
-
116
- 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/smart_class_parameter'
5
-
6
- describe HammerCLIForemanPuppet::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) { HammerCLIForemanPuppet::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_fail_with "environment id", ["--environment-id=1"]
23
- it_should_accept "puppet environment id", ["--puppet-environment-id=1"]
24
- it_should_accept "puppet-class-id", ["--puppet-class-id=1"]
25
- it_should_accept_search_params
26
- end
27
-
28
- context "output" do
29
- let(:expected_record_count) { count_records(cmd.resource.call(:index)) }
30
-
31
- it_should_print_n_records
32
- it_should_print_column "Id"
33
- it_should_print_column "Class Id"
34
- it_should_print_column "Puppet class"
35
- it_should_print_column "Parameter"
36
- it_should_print_column "Default Value"
37
- it_should_print_column "Override"
38
- end
39
-
40
- end
41
-
42
-
43
- context "InfoCommand" do
44
-
45
- before :each do
46
- ResourceMocks.smart_class_parameters_show
47
- end
48
-
49
- let(:cmd) { HammerCLIForemanPuppet::SmartClassParameter::InfoCommand.new("", ctx) }
50
-
51
- context "parameters" do
52
- it_should_accept "id", ["--id=1"]
53
- it_should_accept "name, puppet-class", ["--name=par", "--puppet-class=ntp"]
54
- it_should_fail_with "name", ["--name=par"]
55
- # it_should_fail_with "no arguments"
56
- # TODO: temporarily disabled, parameters are checked in the id resolver
57
- end
58
-
59
- context "output" do
60
- with_params ["--id=1"] do
61
- it_should_print_n_records 1
62
- it_should_print_columns ["Description", "Type", "Omit", "Required"]
63
- end
64
- end
65
- end
66
-
67
-
68
- context "UpdateCommand" do
69
-
70
- let(:cmd) { HammerCLIForemanPuppet::SmartClassParameter::UpdateCommand.new("", ctx) }
71
-
72
- context "parameters" do
73
- it_should_accept "id", ["--id=1"]
74
- it_should_accept "name, puppet-class", ["--name=par", "--puppet-class=ntp"]
75
- it_should_fail_with "name", ["--name=par"]
76
- it_should_accept "override", ["--id=1","--override=true"]
77
- it_should_accept "description", ["--id=1","--description=descr"]
78
- it_should_accept "default-value", ["--id=1","--default-value=1"]
79
- it_should_accept "path ", ["--id=1","--path=path"]
80
- it_should_accept "validator-type", ["--id=1","--validator-type=list"]
81
- it_should_accept "validator-rule ", ["--id=1","--validator-rule=''"]
82
- it_should_accept "override-value-order", ["--id=1","--override-value-order=fqdn"]
83
- it_should_accept "parameter-type ", ["--id=1","--parameter-type=string"]
84
- it_should_accept "required", ["--id=1","--required=true"]
85
-
86
- # it_should_fail_with "no params", []
87
- # TODO: temporarily disabled, parameters are checked in the id resolver
88
- end
89
-
90
- end
91
-
92
- context "AddMatcherCommand" do
93
-
94
- let(:cmd) { HammerCLIForemanPuppet::SmartClassParameter::AddMatcherCommand.new("", ctx) }
95
-
96
- context "parameters" do
97
- it_should_accept "smart-class-parametr-id, match, value", ["--smart-class-parameter-id=1", "--match='domain=my.lan'", "--value=1"]
98
- it_should_accept "smart-class-parameter, puppet-class, match, value", ["--smart-class-parameter=par", "--puppet-class=ntp", "--match='domain=my.lan'", "--value=1"]
99
- it_should_fail_with "smart-class-parameter, match, value", ["--smart-class-parameter=par", "--match='domain=my.lan'", "--value=1"]
100
- end
101
- end
102
-
103
- context "RemoveMatcherCommand" do
104
-
105
- let(:cmd) { HammerCLIForemanPuppet::SmartClassParameter::RemoveMatcherCommand.new("", ctx) }
106
-
107
- context "parameters" do
108
- it_should_accept "smart-class-parametr-id, id", ["--smart-class-parameter-id=1", "--id=1"]
109
- it_should_accept "smart-class-parameter, puppet-class, id", ["--smart-class-parameter=par", "--puppet-class=ntp", "--id=1"]
110
- it_should_fail_with "smart-class-parameter, id", ["--smart-class-parameter=par", "--id=1"]
111
- end
112
- end
113
-
114
- end
@@ -1,18 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../test_helper')
2
-
3
- def ctx
4
- {
5
- :adapter => :silent,
6
- :username => 'admin',
7
- :password => 'admin',
8
- :interactive => false
9
- }
10
- end
11
-
12
-
13
- require File.join(File.dirname(__FILE__), 'test_output_adapter')
14
- require File.join(File.dirname(__FILE__), 'apipie_resource_mock')
15
- require File.join(File.dirname(__FILE__), 'helpers/command')
16
- require File.join(File.dirname(__FILE__), 'helpers/resource_disabled')
17
-
18
- HammerCLI::Settings.load({:_params => {:interactive => false}})
@@ -1,22 +0,0 @@
1
- require 'hammer_cli/output/adapter/abstract'
2
-
3
-
4
- class TestAdapter < HammerCLI::Output::Adapter::Abstract
5
-
6
- def print_record(fields, record)
7
- print_collection(fields, [record].flatten(1))
8
- end
9
-
10
-
11
- def print_collection(fields, data, _options = {})
12
- @separator = '#'
13
- puts @separator+fields.collect{|f| f.label.to_s}.join(@separator)+@separator
14
-
15
- data.collect do |d|
16
- puts @separator+fields.collect{ |f| data_for_field(f, d).to_s }.join(@separator)+@separator
17
- end
18
- end
19
-
20
- end
21
-
22
- HammerCLI::Output::Output.register_adapter(:test, TestAdapter)