hammer_cli_foreman 2.4.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes.md +40 -0
  3. data/lib/hammer_cli_foreman/architecture.rb +5 -5
  4. data/lib/hammer_cli_foreman/associating_commands.rb +0 -24
  5. data/lib/hammer_cli_foreman/bookmark.rb +5 -5
  6. data/lib/hammer_cli_foreman/combination.rb +3 -13
  7. data/lib/hammer_cli_foreman/command_extensions/ping.rb +21 -2
  8. data/lib/hammer_cli_foreman/command_extensions/subnet.rb +25 -10
  9. data/lib/hammer_cli_foreman/command_extensions/update_common.rb +14 -0
  10. data/lib/hammer_cli_foreman/command_extensions/user.rb +9 -5
  11. data/lib/hammer_cli_foreman/command_extensions.rb +1 -2
  12. data/lib/hammer_cli_foreman/commands.rb +17 -11
  13. data/lib/hammer_cli_foreman/compute_attribute.rb +1 -1
  14. data/lib/hammer_cli_foreman/compute_profile.rb +5 -5
  15. data/lib/hammer_cli_foreman/compute_resource/ovirt.rb +2 -1
  16. data/lib/hammer_cli_foreman/compute_resource.rb +23 -0
  17. data/lib/hammer_cli_foreman/config_report.rb +2 -0
  18. data/lib/hammer_cli_foreman/filter.rb +2 -2
  19. data/lib/hammer_cli_foreman/host.rb +1 -47
  20. data/lib/hammer_cli_foreman/hostgroup.rb +14 -58
  21. data/lib/hammer_cli_foreman/hosts/common_update_options.rb +10 -31
  22. data/lib/hammer_cli_foreman/id_resolver.rb +7 -68
  23. data/lib/hammer_cli_foreman/location.rb +0 -6
  24. data/lib/hammer_cli_foreman/mail_notification.rb +2 -2
  25. data/lib/hammer_cli_foreman/model.rb +5 -5
  26. data/lib/hammer_cli_foreman/operating_system.rb +10 -10
  27. data/lib/hammer_cli_foreman/option_builders.rb +84 -52
  28. data/lib/hammer_cli_foreman/option_sources/id_params.rb +41 -11
  29. data/lib/hammer_cli_foreman/option_sources/ids_params.rb +39 -7
  30. data/lib/hammer_cli_foreman/option_sources.rb +0 -1
  31. data/lib/hammer_cli_foreman/organization.rb +0 -6
  32. data/lib/hammer_cli_foreman/ping.rb +6 -1
  33. data/lib/hammer_cli_foreman/references.rb +0 -16
  34. data/lib/hammer_cli_foreman/registration.rb +18 -0
  35. data/lib/hammer_cli_foreman/settings.rb +3 -3
  36. data/lib/hammer_cli_foreman/smart_proxy.rb +7 -57
  37. data/lib/hammer_cli_foreman/template.rb +3 -15
  38. data/lib/hammer_cli_foreman/user.rb +4 -4
  39. data/lib/hammer_cli_foreman/usergroup.rb +5 -5
  40. data/lib/hammer_cli_foreman/version.rb +1 -1
  41. data/lib/hammer_cli_foreman.rb +3 -21
  42. data/lib/minitest/coverage_reporter.rb +1 -1
  43. data/locale/ca/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  44. data/locale/de/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  45. data/locale/en/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  46. data/locale/en_GB/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  47. data/locale/es/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  48. data/locale/fr/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  49. data/locale/it/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  50. data/locale/ja/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  51. data/locale/ko/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  52. data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  53. data/locale/ru/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  54. data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  55. data/locale/zh_TW/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  56. data/test/data/2.4/foreman_api.json +1 -0
  57. data/test/data/2.5/foreman_api.json +1 -0
  58. data/test/data/3.1/foreman_api.json +1 -0
  59. data/test/functional/architecture_test.rb +37 -5
  60. data/test/functional/bookmark_test.rb +5 -2
  61. data/test/functional/compute_attribute_test.rb +20 -20
  62. data/test/functional/compute_profile_test.rb +14 -1
  63. data/test/functional/compute_resource_test.rb +37 -0
  64. data/test/functional/filter_test.rb +2 -1
  65. data/test/functional/host_test.rb +65 -11
  66. data/test/functional/hostgroup/create_test.rb +11 -117
  67. data/test/functional/hostgroup/update_test.rb +11 -79
  68. data/test/functional/http_proxy_test.rb +12 -0
  69. data/test/functional/location_test.rb +13 -3
  70. data/test/functional/mail_notification_test.rb +3 -1
  71. data/test/functional/media_test.rb +11 -0
  72. data/test/functional/model_test.rb +3 -1
  73. data/test/functional/operating_system_test.rb +3 -1
  74. data/test/functional/personal_access_token_test.rb +4 -4
  75. data/test/functional/ping_test.rb +33 -0
  76. data/test/functional/realm_test.rb +11 -0
  77. data/test/functional/registration_test.rb +8 -0
  78. data/test/functional/report_template_test.rb +11 -0
  79. data/test/functional/settings_test.rb +4 -4
  80. data/test/functional/template_test.rb +87 -48
  81. data/test/functional/user_mail_notification_test.rb +3 -3
  82. data/test/functional/user_test.rb +11 -0
  83. data/test/functional/usergroup_test.rb +3 -1
  84. data/test/test_helper.rb +1 -1
  85. data/test/unit/apipie_resource_mock.rb +1 -39
  86. data/test/unit/architecture_test.rb +10 -10
  87. data/test/unit/bookmark_test.rb +10 -14
  88. data/test/unit/commands_test.rb +1 -2
  89. data/test/unit/compute_profile_test.rb +10 -10
  90. data/test/unit/config_report_test.rb +1 -0
  91. data/test/unit/helpers/command.rb +0 -8
  92. data/test/unit/host_test.rb +14 -61
  93. data/test/unit/hostgroup_test.rb +7 -26
  94. data/test/unit/id_resolver_test.rb +0 -28
  95. data/test/unit/mail_notification_test.rb +4 -4
  96. data/test/unit/model_test.rb +47 -47
  97. data/test/unit/operating_system_test.rb +10 -16
  98. data/test/unit/option_builders_test.rb +88 -83
  99. data/test/unit/settings_test.rb +4 -4
  100. data/test/unit/smart_proxy_test.rb +0 -12
  101. data/test/unit/usergroup_test.rb +10 -10
  102. metadata +115 -128
  103. data/lib/hammer_cli_foreman/command_extensions/puppet_environment.rb +0 -29
  104. data/lib/hammer_cli_foreman/command_extensions/puppet_environments.rb +0 -29
  105. data/lib/hammer_cli_foreman/config_group.rb +0 -45
  106. data/lib/hammer_cli_foreman/option_sources/puppet_environment_params.rb +0 -59
  107. data/lib/hammer_cli_foreman/puppet_class.rb +0 -61
  108. data/lib/hammer_cli_foreman/puppet_environment.rb +0 -65
  109. data/lib/hammer_cli_foreman/smart_class_parameter.rb +0 -189
  110. data/test/functional/config_group_test.rb +0 -50
  111. data/test/functional/proxy_test.rb +0 -86
  112. data/test/functional/smart_class_parameter_test.rb +0 -97
  113. data/test/reports/TEST-Minitest-Result.xml +0 -4344
  114. data/test/unit/config_group_test.rb +0 -82
  115. data/test/unit/puppet_class_test.rb +0 -72
  116. data/test/unit/puppet_environment_test.rb +0 -114
  117. data/test/unit/smart_class_parameter_test.rb +0 -113
@@ -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
@@ -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