hammer_cli_foreman 2.2.0 → 2.3.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 (44) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes.md +18 -0
  3. data/lib/hammer_cli_foreman.rb +0 -4
  4. data/lib/hammer_cli_foreman/associating_commands.rb +2 -2
  5. data/lib/hammer_cli_foreman/auth.rb +4 -4
  6. data/lib/hammer_cli_foreman/command_extensions/ping.rb +10 -1
  7. data/lib/hammer_cli_foreman/commands.rb +3 -1
  8. data/lib/hammer_cli_foreman/compute_resource/ovirt.rb +1 -0
  9. data/lib/hammer_cli_foreman/hosts/common_update_options.rb +16 -9
  10. data/lib/hammer_cli_foreman/location.rb +2 -0
  11. data/lib/hammer_cli_foreman/organization.rb +2 -0
  12. data/lib/hammer_cli_foreman/ping.rb +20 -11
  13. data/lib/hammer_cli_foreman/references.rb +16 -0
  14. data/lib/hammer_cli_foreman/settings.rb +14 -0
  15. data/lib/hammer_cli_foreman/version.rb +1 -1
  16. data/locale/ca/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  17. data/locale/de/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  18. data/locale/en/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  19. data/locale/en_GB/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  20. data/locale/es/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  21. data/locale/fr/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  22. data/locale/it/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  23. data/locale/ja/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  24. data/locale/ko/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  25. data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  26. data/locale/ru/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  27. data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  28. data/locale/zh_TW/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  29. data/test/functional/audit_test.rb +86 -63
  30. data/test/functional/compute_profile_test.rb +4 -2
  31. data/test/functional/host_test.rb +26 -15
  32. data/test/functional/location_test.rb +134 -0
  33. data/test/functional/media_test.rb +130 -0
  34. data/test/functional/organization_test.rb +52 -0
  35. data/test/functional/realm_test.rb +1 -2
  36. data/test/functional/role_test.rb +9 -12
  37. data/test/functional/settings_test.rb +57 -1
  38. data/test/functional/user_test.rb +39 -0
  39. data/test/unit/media_test.rb +1 -1
  40. data/test/unit/partition_table_test.rb +2 -2
  41. data/test/unit/role_test.rb +2 -2
  42. metadata +6 -7
  43. data/lib/hammer_cli_foreman/trend.rb +0 -47
  44. data/test/functional/trend_test.rb +0 -83
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), '..', 'test_helper')
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
2
 
3
3
  describe 'Settings' do
4
4
  let(:setting) do
@@ -33,5 +33,61 @@ describe 'Settings' do
33
33
 
34
34
  end
35
35
 
36
+ describe 'info' do
37
+ before do
38
+ @cmd = ['setting', 'info']
39
+ @setting = {
40
+ description: 'Fix DB cache on next Foreman restart',
41
+ category: 'Setting::General',
42
+ settings_type: 'boolean',
43
+ default: false,
44
+ created_at: "2020-05-24 09:02:11 UTC",
45
+ updated_at: "2020-07-01 07:42:14 UTC",
46
+ id: 1,
47
+ name: "fix_db_cache",
48
+ full_name: "Fix DB cache",
49
+ value: false,
50
+ category_name: "General"
51
+ }
52
+ end
53
+
54
+ it 'should return a setting' do
55
+ params = ['--id=1']
56
+ api_expects(:settings, :show, 'Show a setting').returns(@setting)
57
+
58
+ output = OutputMatcher.new([
59
+ 'Id: 1',
60
+ 'Name: fix_db_cache',
61
+ 'Description: Fix DB cache on next Foreman restart',
62
+ 'Category: General',
63
+ 'Settings type: boolean',
64
+ 'Value: false'
65
+ ])
66
+
67
+ expected_result = success_result(output)
68
+
69
+ result = run_cmd(@cmd + params)
70
+ assert_cmd(expected_result, result)
71
+ end
72
+ end
73
+
74
+ describe 'update' do
75
+ before do
76
+ @cmd = ['setting', 'set']
77
+ end
78
+
79
+ it 'should update a setting' do
80
+ params = ['--id=1', '--value=true']
81
+
82
+ api_expects(:settings, :update, 'Update a setting') do |params|
83
+ (params['setting']['id'] == '1')
84
+ (params['setting']['value'] == 'true')
85
+ end
86
+
87
+ result = run_cmd(@cmd + params)
88
+ assert_cmd(success_result("Setting [%{name}] updated to [%{value}].\n"), result)
89
+ end
90
+ end
91
+
36
92
  end
37
93
 
@@ -162,4 +162,43 @@ describe "user" do
162
162
  end
163
163
  end
164
164
  end
165
+
166
+ describe 'list' do
167
+ let(:cmd) { ['user', 'list'] }
168
+ let(:users) do
169
+ [{
170
+ id: 1,
171
+ login: 'admin',
172
+ full_name: 'Admin User',
173
+ mail: 'root@localadmin.net',
174
+ admin: true,
175
+ disabled: false
176
+ }] end
177
+
178
+ it "should show index list" do
179
+ api_expects(:users, :index).returns(users)
180
+
181
+ output = IndexMatcher.new([
182
+ ['ID', 'LOGIN', 'NAME', 'EMAIL', 'ADMIN', 'DISABLED', 'AUTHORIZED BY'],
183
+ ['1', 'admin', 'Admin User', 'root@localadmin.net', 'yes', 'no', ''],
184
+ ])
185
+
186
+ result = run_cmd(cmd)
187
+ assert_cmd(success_result(output), result)
188
+ end
189
+ end
190
+
191
+ describe 'delete' do
192
+ let(:cmd) { ['user', 'delete'] }
193
+
194
+ it 'deletes a user' do
195
+ params = ['--id', user['id']]
196
+ api_expects(:users, :destroy).returns(user)
197
+
198
+ expected_result = success_result("User [#{user['login']}] deleted.\n")
199
+
200
+ result = run_cmd(cmd + params)
201
+ assert_cmd(expected_result, result)
202
+ end
203
+ end
165
204
  end
@@ -95,7 +95,7 @@ describe HammerCLIForeman::Medium do
95
95
  end
96
96
 
97
97
  with_params ["--id=1", "--new-name=medium_x", "--path=http://some.path/", "--operatingsystem-ids=1,2"] do
98
- it_should_call_action :update, {'id' => '1', 'name' => 'medium_x', 'medium' => {'name' => 'medium_x', 'path' => 'http://some.path/', 'operatingsystem_ids' => ['1','2']}}
98
+ it_should_call_action :update, {'id' => '1', 'medium' => {'name' => 'medium_x', 'path' => 'http://some.path/', 'operatingsystem_ids' => ['1','2']}}
99
99
  end
100
100
 
101
101
  end
@@ -119,8 +119,8 @@ describe HammerCLIForeman::PartitionTable do
119
119
  # TODO: temporarily disabled, parameters are checked in the id resolver
120
120
  end
121
121
 
122
- with_params ["--id=83", "--new-name=ptable","--file=~/table.sh", "--os-family=RedHat"] do
123
- it_should_call_action :update, {'id' => '83', 'name' => 'ptable', 'ptable' => {'name' => 'ptable', 'layout' => 'FILE_CONTENT', 'os_family' => 'RedHat'}}
122
+ with_params ['--id=83', '--new-name=ptable', '--file=~/table.sh', '--os-family=RedHat'] do
123
+ it_should_call_action :update, { 'id' => '83', 'ptable' => { 'name' => 'ptable', 'layout' => 'FILE_CONTENT', 'os_family' => 'RedHat' } }
124
124
  end
125
125
 
126
126
  end
@@ -77,8 +77,8 @@ describe HammerCLIForeman::Role do
77
77
  it_should_accept "name and new name", ["--name=role", "--new-name=role2"]
78
78
  end
79
79
 
80
- with_params ["--id=1", "--new-name=role2"] do
81
- it_should_call_action :update, {'id' => '1', 'name' => 'role2', 'role' => {'name' => 'role2'}}
80
+ with_params ['--id=1', '--new-name=role2'] do
81
+ it_should_call_action :update, { 'id' => '1', 'role' => { 'name' => 'role2' } }
82
82
  end
83
83
 
84
84
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hammer_cli_foreman
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomáš Strachota
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-08-11 00:00:00.000000000 Z
12
+ date: 2020-11-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hammer_cli
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 2.1.0
20
+ version: 2.3.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: 2.1.0
27
+ version: 2.3.0
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: apipie-bindings
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -211,7 +211,6 @@ files:
211
211
  - lib/hammer_cli_foreman/task_helper.rb
212
212
  - lib/hammer_cli_foreman/template.rb
213
213
  - lib/hammer_cli_foreman/testing/api_expectations.rb
214
- - lib/hammer_cli_foreman/trend.rb
215
214
  - lib/hammer_cli_foreman/user.rb
216
215
  - lib/hammer_cli_foreman/user_mail_notification.rb
217
216
  - lib/hammer_cli_foreman/usergroup.rb
@@ -262,6 +261,7 @@ files:
262
261
  - test/functional/http_proxy_test.rb
263
262
  - test/functional/location_test.rb
264
263
  - test/functional/mail_notification_test.rb
264
+ - test/functional/media_test.rb
265
265
  - test/functional/organization_test.rb
266
266
  - test/functional/personal_access_token_test.rb
267
267
  - test/functional/ping_test.rb
@@ -277,7 +277,6 @@ files:
277
277
  - test/functional/subnet/update_test.rb
278
278
  - test/functional/template_test.rb
279
279
  - test/functional/test_helper.rb
280
- - test/functional/trend_test.rb
281
280
  - test/functional/user_mail_notification_test.rb
282
281
  - test/functional/user_test.rb
283
282
  - test/functional/virtual_machine_test.rb
@@ -447,6 +446,7 @@ test_files:
447
446
  - test/functional/mail_notification_test.rb
448
447
  - test/functional/ping_test.rb
449
448
  - test/functional/smart_class_parameter_test.rb
449
+ - test/functional/media_test.rb
450
450
  - test/functional/role_test.rb
451
451
  - test/functional/location_test.rb
452
452
  - test/functional/hostgroup/create_test.rb
@@ -460,7 +460,6 @@ test_files:
460
460
  - test/functional/compute_resource_test.rb
461
461
  - test/functional/compute_attribute_test.rb
462
462
  - test/functional/filter_test.rb
463
- - test/functional/trend_test.rb
464
463
  - test/functional/report_template_test.rb
465
464
  - test/functional/compute_profile_test.rb
466
465
  - test/functional/host_test.rb
@@ -1,47 +0,0 @@
1
- module HammerCLIForeman
2
-
3
- class Trend < HammerCLIForeman::Command
4
-
5
- resource :trends
6
-
7
- class ListCommand < HammerCLIForeman::ListCommand
8
- output do
9
- field :id, _("Id")
10
- field :name, _("Name")
11
- field :label, _("Label")
12
- end
13
-
14
- build_options
15
- end
16
-
17
- class CreateCommand < HammerCLIForeman::CreateCommand
18
- success_message _("Trend for %<trendable_type>s created.")
19
- failure_message _("Could not create the trend")
20
-
21
- build_options
22
- end
23
-
24
- class DeleteCommand < HammerCLIForeman::DeleteCommand
25
- success_message _("Trend for %<trendable_type>s deleted.")
26
- failure_message _("Could not delete the trend")
27
-
28
- build_options
29
- end
30
-
31
- class InfoCommand < HammerCLIForeman::InfoCommand
32
- output do
33
- field :id, _('Id')
34
- field :name, _('Name')
35
- field :label, _("Label")
36
- field :trendable_type, _('Type')
37
- HammerCLIForeman::References.taxonomies(self)
38
- HammerCLIForeman::References.timestamps(self)
39
- end
40
-
41
- build_options
42
- end
43
-
44
- autoload_subcommands
45
- end
46
- end
47
-
@@ -1,83 +0,0 @@
1
- require File.join(File.dirname(__FILE__), 'test_helper')
2
-
3
- describe 'trend' do
4
- describe 'list' do
5
- before do
6
- @cmd = %w[trend list]
7
- @trends =
8
- [{
9
- id: 1,
10
- label: "Operatingsystem",
11
- trendable_type: "Operatingsystem",
12
- name: "os_trend" }]
13
- end
14
-
15
- it 'should return a list of trends' do
16
- api_expects(:trends, :index, 'List trends').returns(@trends)
17
-
18
- result = run_cmd(@cmd)
19
- _(result.exit_code).must_equal HammerCLI::EX_OK
20
- end
21
- end
22
-
23
- describe 'info' do
24
- before do
25
- @cmd = %w[trend info]
26
- @trend = {
27
- id: 1,
28
- label: "Operatingsystem",
29
- trendable_type: "Operatingsystem",
30
- name: "os_trend"
31
- }
32
- end
33
-
34
- it 'should return a trend' do
35
- params = ['--id=1']
36
- api_expects(:trends, :show, 'Show trend').returns(@trend)
37
-
38
- result = run_cmd(@cmd + params)
39
- _(result.exit_code).must_equal HammerCLI::EX_OK
40
- end
41
- end
42
-
43
- describe 'create' do
44
- before do
45
- @cmd = %w[trend create]
46
- end
47
-
48
- it 'should print error on missing --trendable-type' do
49
- expected_result = "Could not create the trend:\n Missing arguments for '--trendable-type'.\n"
50
-
51
- api_expects_no_call
52
- result = run_cmd(@cmd)
53
- assert_match(expected_result, result.err)
54
- end
55
-
56
- it 'should create a trend' do
57
- params = ['--trendable-type=ComputeResource']
58
-
59
- api_expects(:trends, :create, 'Create a trend') do |params|
60
- (params['trendable_type'] == 'ComputeResource')
61
- end
62
-
63
- result = run_cmd(@cmd + params)
64
-
65
- assert_cmd(success_result("Trend for %<trendable_type>s created.\n"), result)
66
- end
67
- end
68
-
69
- describe 'delete' do
70
- before do
71
- @cmd = %w[trend delete]
72
- end
73
-
74
- it 'should delete a trend' do
75
- params = ['--id=1']
76
-
77
- api_expects(:trends, :destroy, 'Delete trend').with_params(:id => '1')
78
-
79
- result = run_cmd(@cmd + params)
80
- assert_cmd(success_result("Trend for %<trendable_type>s deleted.\n"), result)
81
- end
82
- end
83
- end