hammer_cli_foreman 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c478d3535da7a22a10907ad8838baedd0dd1ad9cd3f5168cadab57ef5cc61e53
4
- data.tar.gz: d362b8e3e44db4ec092ea2451363be8875cbd1576aaa14e4f8b3652b19ae483f
3
+ metadata.gz: 1cb3de28c168226867cc9b1f4f63ea96bf2ff8746b831e2cdf01e6fe6670a53b
4
+ data.tar.gz: 55b321941992865b2339fd1e0d11b3845c1396c0699f90c52ab4ba774974b70f
5
5
  SHA512:
6
- metadata.gz: 1bebff2d84aacc7ed3053a64920ff86b1420f10d98fc2cfba91a627d69722d5d9866afbf31131c25868ecdf705161ec0401aeaa338f26a5f2f97476664fd1704
7
- data.tar.gz: 5dd93dbc8bfff2308ee1768c80ed545dd452278fa0753d2b7016d80ba659741b4c39c1f1b99aa27149e546bc2628b08bcc84419ab5f85cb8ab2ef673952c2581
6
+ metadata.gz: 7e50e0beb69a60b01613b3d7c282b927e54872de4533364e079f768e22f4a1e63aea967d7113e72a32ee35a20d4475a1cefef03055af956027e7fb3ce0fde00e
7
+ data.tar.gz: 8ec8cc1402c57faa1b5bbb960bb9b4963e2c4c0e21b9e0a62e88c7e02ca2a01f976c83795c21b7c801aa635842df6fc5fb0794283bd8f666364bd91f404c661d
@@ -1,5 +1,23 @@
1
1
  Release notes
2
2
  =============
3
+ ### 2.3.0 (2020-11-03)
4
+ * Hammer ping skip authentication ([PR #550](https://github.com/theforeman/hammer-cli-foreman/pull/550)), [#31140](http://projects.theforeman.org/issues/31140)
5
+ * Return non-zero exit code if services failed, [#30496](http://projects.theforeman.org/issues/30496)
6
+ * Better option assignment for nested params ([PR #544](https://github.com/theforeman/hammer-cli-foreman/pull/544)), [#30910](http://projects.theforeman.org/issues/30910)
7
+ * Use parent resource instead of hardcoded one, [#30938](http://projects.theforeman.org/issues/30938)
8
+ * Added missing tests to setting, [#30886](http://projects.theforeman.org/issues/30886)
9
+ * Added missing tests to installation medium test, [#30805](http://projects.theforeman.org/issues/30805)
10
+ * Added missing tests to location test, [#30829](http://projects.theforeman.org/issues/30829)
11
+ * Added missing tests to organization test, [#30794](http://projects.theforeman.org/issues/30794)
12
+ * Added missing tests to audit test ([PR #537](https://github.com/theforeman/hammer-cli-foreman/pull/537)), [#30740](http://projects.theforeman.org/issues/30740)
13
+ * Use underscores in `login oauth` option values ([PR #536](https://github.com/theforeman/hammer-cli-foreman/pull/536)), [#30720](http://projects.theforeman.org/issues/30720)
14
+ * Drop trends from hammer-cli-foreman ([PR #535](https://github.com/theforeman/hammer-cli-foreman/pull/535)), [#30134](http://projects.theforeman.org/issues/30134)
15
+ * Added highly available option to ovirt ([PR #532](https://github.com/theforeman/hammer-cli-foreman/pull/532)), [#30494](http://projects.theforeman.org/issues/30494)
16
+ * Add ptables and realms to location and organization info ([PR #534](https://github.com/theforeman/hammer-cli-foreman/pull/534)), [#30663](http://projects.theforeman.org/issues/30663)
17
+ * Bump to 2.3.0-develop
18
+ * Bump to 2.2.0
19
+ * Added missing tests to user test, [#30593](http://projects.theforeman.org/issues/30593)
20
+
3
21
  ### 2.2.0 (2020-08-11)
4
22
  * Change config templates to provisioning templates ([PR #531](https://github.com/theforeman/hammer-cli-foreman/pull/531)), [#29971](http://projects.theforeman.org/issues/29971)
5
23
  * Fix minitest deprecation ([PR #523](https://github.com/theforeman/hammer-cli-foreman/pull/523))
@@ -178,10 +178,6 @@ module HammerCLIForeman
178
178
  'HammerCLIForeman::StatusCommand', 'hammer_cli_foreman/status'
179
179
  )
180
180
 
181
- HammerCLI::MainCommand.lazy_subcommand('trend', _("Manage trends"),
182
- 'HammerCLIForeman::Trend', 'hammer_cli_foreman/trend'
183
- )
184
-
185
181
  HammerCLI::MainCommand.lazy_subcommand('mail-notification', _("Manage mail notifications"),
186
182
  'HammerCLIForeman::MailNotification', 'hammer_cli_foreman/mail_notification'
187
183
  )
@@ -280,7 +280,7 @@ module HammerCLIForeman
280
280
  def request_params
281
281
  params = super
282
282
 
283
- template_ids = params['operatingsystem']['provisioning_template_ids']
283
+ template_ids = params[resource.singular_name]['provisioning_template_ids']
284
284
  if options['option_provisioning_template_search']
285
285
  templates = HammerCLIForeman.collection_to_common_format(
286
286
  associated_resource.call(
@@ -294,7 +294,7 @@ module HammerCLIForeman
294
294
  template_ids.delete(template_id.to_s)
295
295
  end
296
296
  end
297
- params['operatingsystem']['provisioning_template_ids'] = template_ids.uniq
297
+ params[resource.singular_name]['provisioning_template_ids'] = template_ids.uniq
298
298
  params
299
299
  end
300
300
 
@@ -36,11 +36,11 @@ module HammerCLIForeman
36
36
 
37
37
  option ["-u", "--username"], "USERNAME", _("Username to access the remote system")
38
38
  option ["-p", "--password"], "PASSWORD", _("Password to access the remote system")
39
- option ["-t", "--oidc-token-endpoint"], "OPENIDC-TOKEN-ENDPOINT", _("Openidc provider URL which issues access token")
40
- option ["-a", "--oidc-authorization-endpoint"], "OPENIDC-AUTHORIZATION-ENDPOINT", _("Openidc provider URL which issues authentication code (two factor only)")
41
- option ["-c", "--oidc-client-id"], "OPENIDC-CLIENT-ID", _("Client id used in the Openidc provider")
39
+ option ["-t", "--oidc-token-endpoint"], "OPENIDC_TOKEN_ENDPOINT", _("Openidc provider URL which issues access token")
40
+ option ["-a", "--oidc-authorization-endpoint"], "OPENIDC_AUTHORIZATION_ENDPOINT", _("Openidc provider URL which issues authentication code (two factor only)")
41
+ option ["-c", "--oidc-client-id"], "OPENIDC_CLIENT_ID", _("Client id used in the Openidc provider")
42
42
  option ["-f", "--two-factor"], :flag, _("Authenticate with two factor")
43
- option ["-r", "--oidc-redirect-uri"], "OPENIDC-REDIRECT-URI", _("Redirect URI for the authentication code grant flow")
43
+ option ["-r", "--oidc-redirect-uri"], "OPENIDC_REDIRECT_URI", _("Redirect URI for the authentication code grant flow")
44
44
 
45
45
  def execute
46
46
  if option_two_factor?
@@ -6,9 +6,18 @@ module HammerCLIForeman
6
6
  status = data['results']['foreman']['database']['active']
7
7
  data['results']['foreman']['database']['active'] = status ? 'ok' : 'FAIL'
8
8
  duration = data['results']['foreman']['database']['duration_ms']
9
- data['results']['foreman']['database']['duration_ms'] = _("Duration: %sms") % duration
9
+ data['results']['foreman']['database']['duration_ms'] = _('Duration: %sms') % duration
10
10
  end
11
11
  end
12
+
13
+ def self.failed?(services)
14
+ services.each_value.any? { |s| s['status'] == _('FAIL') } ||
15
+ services['foreman']['database']['active'] == 'FAIL'
16
+ end
17
+
18
+ request_options do |options|
19
+ options[:with_authentication] = false
20
+ end
12
21
  end
13
22
  end
14
23
  end
@@ -548,10 +548,12 @@ module HammerCLIForeman
548
548
  builder
549
549
  end
550
550
 
551
- def method_options_for_params(params, include_nil=true)
551
+ def method_options_for_params(params, options)
552
552
  opts = super
553
553
  # overwrite searchables with correct values
554
554
  searchables.for(resource).each do |s|
555
+ next unless params.map(&:name).include?(s.name)
556
+
555
557
  new_value = get_option_value("new_#{s.name}")
556
558
  opts[s.name] = new_value unless new_value.nil?
557
559
  end
@@ -12,6 +12,7 @@ module HammerCLIForeman
12
12
  ['cores', _('Integer value, number of cores')],
13
13
  ['sockets', _('Integer value, number of sockets')],
14
14
  ['memory', _('Amount of memory, integer value in bytes')],
15
+ ['ha', _('Boolean, set 1 to high availability')],
15
16
  ['display_type', _('Possible values: %s') % 'VNC, SPICE'],
16
17
  ['keyboard_layout', _('Possible values: %s. Not usable if display type is SPICE.') % 'ar, de-ch, es, fo, fr-ca, hu, ja, mk, no, pt-br, sv, da, en-gb, et, fr, fr-ch, is, lt, nl, pl, ru, th, de, en-us, fi, fr-be, hr, it, lv, nl-be, pt, sl, tr']
17
18
  ]
@@ -84,18 +84,16 @@ module HammerCLIForeman
84
84
 
85
85
  params['host']['host_parameters_attributes'] = parameter_attributes unless option_parameters.nil?
86
86
  params['host']['host_parameters_attributes'] ||= option_typed_parameters unless option_typed_parameters.nil?
87
- params['host']['compute_attributes'] = option_compute_attributes || {}
88
87
 
89
- compute_attributes = params['host']['compute_attributes']
90
- compute_attributes['display'] = {} unless compute_attributes['display_type'].nil? && compute_attributes['keyboard_layout'].nil?
91
- compute_attributes['display']['type'] = compute_attributes['display_type'] unless compute_attributes['display_type'].nil?
92
- compute_attributes['display']['keyboard_layout'] = compute_attributes['keyboard_layout'] unless compute_attributes['keyboard_layout'].nil?
93
- compute_attributes.delete('display_type')
94
- compute_attributes.delete('keyboard_layout')
95
- params['host']['compute_attributes'] = compute_attributes
88
+ if option_compute_attributes && !option_compute_attributes.empty?
89
+ params['host']['compute_attributes'] = host_compute_attrs(option_compute_attributes)
90
+ end
96
91
 
97
92
  if action == :update
98
- params['host']['compute_attributes']['volumes_attributes'] = nested_attributes(option_volume_list) unless option_volume_list.empty?
93
+ unless option_volume_list.empty?
94
+ params['host']['compute_attributes'] ||= {}
95
+ params['host']['compute_attributes']['volumes_attributes'] = nested_attributes(option_volume_list)
96
+ end
99
97
  params['host']['interfaces_attributes'] = interfaces_attributes unless option_interface_list.empty?
100
98
  if options['option_new_location_id']
101
99
  params['host']['location_id'] = options['option_new_location_id']
@@ -108,6 +106,7 @@ module HammerCLIForeman
108
106
  params['host'].delete('organization_id')
109
107
  end
110
108
  else
109
+ params['host']['compute_attributes'] ||= {}
111
110
  params['host']['compute_attributes']['volumes_attributes'] = nested_attributes(option_volume_list)
112
111
  params['host']['interfaces_attributes'] = interfaces_attributes
113
112
  end
@@ -121,6 +120,7 @@ module HammerCLIForeman
121
120
  end
122
121
  raise ArgumentError, "Missing argument for 'compute_resource'" if compute_resource_id.nil?
123
122
  image_uuid = ::HammerCLIForeman::ComputeResources.get_image_uuid(compute_resource_id, options["option_image_id"])
123
+ params['host']['compute_attributes'] ||= {}
124
124
  params['host']['compute_attributes']['image_id'] = image_uuid
125
125
  end
126
126
  params['host']['root_pass'] = option_root_password unless option_root_password.nil?
@@ -164,6 +164,13 @@ module HammerCLIForeman
164
164
  end
165
165
  end
166
166
 
167
+ def host_compute_attrs(attrs)
168
+ attrs['display'] = {} unless attrs['display_type'].nil? && attrs['keyboard_layout'].nil?
169
+ attrs['display']['type'] = attrs.delete('display_type') unless attrs['display_type'].nil?
170
+ attrs['display']['keyboard_layout'] = attrs.delete('keyboard_layout') unless attrs['keyboard_layout'].nil?
171
+ attrs
172
+ end
173
+
167
174
  def nested_attributes(attrs)
168
175
  return {} unless attrs
169
176
 
@@ -33,7 +33,9 @@ module HammerCLIForeman
33
33
  HammerCLIForeman::References.compute_resources(self)
34
34
  HammerCLIForeman::References.media(self)
35
35
  HammerCLIForeman::References.provisioning_templates(self)
36
+ HammerCLIForeman::References.partition_tables(self)
36
37
  HammerCLIForeman::References.domains(self)
38
+ HammerCLIForeman::References.realms(self)
37
39
  HammerCLIForeman::References.environments(self)
38
40
  HammerCLIForeman::References.hostgroups(self)
39
41
  HammerCLIForeman::References.parameters(self)
@@ -33,7 +33,9 @@ module HammerCLIForeman
33
33
  HammerCLIForeman::References.compute_resources(self)
34
34
  HammerCLIForeman::References.media(self)
35
35
  HammerCLIForeman::References.provisioning_templates(self)
36
+ HammerCLIForeman::References.partition_tables(self)
36
37
  HammerCLIForeman::References.domains(self)
38
+ HammerCLIForeman::References.realms(self)
37
39
  HammerCLIForeman::References.environments(self)
38
40
  HammerCLIForeman::References.hostgroups(self)
39
41
  HammerCLIForeman::References.parameters(self)
@@ -1,23 +1,32 @@
1
1
  module HammerCLIForeman
2
2
  class PingCommand < HammerCLIForeman::Command
3
- resource :ping
3
+ resource :ping
4
4
 
5
- class ForemanCommand < HammerCLIForeman::Command
6
- action :ping
7
- command_name 'foreman'
5
+ class ForemanCommand < HammerCLIForeman::Command
6
+ action :ping
7
+ command_name 'foreman'
8
8
 
9
- output do
10
- from 'foreman' do
11
- field :database, _('database'), Fields::Label do
12
- field :active, _('Status')
13
- field :duration_ms, _('Server Response')
14
- end
9
+ output do
10
+ from 'foreman' do
11
+ field :database, _('database'), Fields::Label do
12
+ field :active, _('Status')
13
+ field :duration_ms, _('Server Response')
15
14
  end
16
15
  end
16
+ end
17
+
18
+ def execute
19
+ response = send_request
20
+ print_data(response)
17
21
 
18
- extend_with(HammerCLIForeman::CommandExtensions::Ping.new)
22
+ return 1 if HammerCLIForeman::CommandExtensions::Ping.failed?(response)
23
+
24
+ HammerCLI::EX_OK
19
25
  end
20
26
 
27
+ extend_with(HammerCLIForeman::CommandExtensions::Ping.new)
28
+ end
29
+
21
30
  self.default_subcommand = 'foreman'
22
31
  autoload_subcommands
23
32
  end
@@ -88,6 +88,14 @@ module HammerCLIForeman
88
88
  end
89
89
  end
90
90
 
91
+ def self.partition_tables(dsl)
92
+ dsl.build do
93
+ collection :ptables, _("Partition Tables"), :numbered => false do
94
+ custom_field Fields::Reference
95
+ end
96
+ end
97
+ end
98
+
91
99
  def self.domains(dsl)
92
100
  dsl.build do
93
101
  collection :domains, _("Domains"), :numbered => false do
@@ -96,6 +104,14 @@ module HammerCLIForeman
96
104
  end
97
105
  end
98
106
 
107
+ def self.realms(dsl)
108
+ dsl.build do
109
+ collection :realms, _("Realms"), :numbered => false do
110
+ custom_field Fields::Reference
111
+ end
112
+ end
113
+ end
114
+
99
115
  def self.environments(dsl)
100
116
  dsl.build do
101
117
  collection :environments, _("Environments"), :numbered => false do
@@ -32,6 +32,20 @@ module HammerCLIForeman
32
32
  build_options
33
33
  end
34
34
 
35
+ class InfoCommand < HammerCLIForeman::InfoCommand
36
+ output do
37
+ field :id, _("Id")
38
+ field :name, _("Name")
39
+ field :description, _("Description")
40
+ field :category_name, _("Category")
41
+ field :settings_type, _("Settings type")
42
+ field :value, _("Value")
43
+ end
44
+
45
+ build_options
46
+ end
47
+
48
+
35
49
  autoload_subcommands
36
50
  end
37
51
 
@@ -1,5 +1,5 @@
1
1
  module HammerCLIForeman
2
2
  def self.version
3
- @version ||= Gem::Version.new "2.2.0"
3
+ @version ||= Gem::Version.new "2.3.0"
4
4
  end
5
5
  end
@@ -1,28 +1,28 @@
1
1
  require File.join(File.dirname(__FILE__), 'test_helper')
2
2
 
3
3
  describe 'audit' do
4
- describe 'audit-list' do
4
+ before do
5
+ @audit_changed = {
6
+ 'id' => 83,
7
+ 'created_at' => "2017-10-31 11:25:44 UTC",
8
+ 'remote_address' => '::1',
9
+ 'user_name' => "foreman_api_admin",
10
+ 'user_id' => 11,
11
+ 'action' => "update",
12
+ 'auditable_type' => "ProvisioningTemplate",
13
+ 'auditable_name' => "default_location_subscribed_hosts",
14
+ 'auditable_id' => 32,
15
+ 'audited_changes' => {
16
+ 'value' => [
17
+ nil,
18
+ "--- false\n..."
19
+ ]
20
+ }
21
+ }
22
+ end
23
+ describe 'audit-info' do
5
24
  let (:cmd) { ['audit', 'info'] }
6
25
  let(:params) { ['--id=83'] }
7
- let(:audit_changed) do
8
- {
9
- 'id' => 83,
10
- 'created_at' => "2017-10-31 11:25:44 UTC",
11
- 'remote_address' => '::1',
12
- 'user_name' => "foreman_api_admin",
13
- 'user_id' => 11,
14
- 'action' => "update",
15
- 'auditable_type' => "ProvisioningTemplate",
16
- 'auditable_name' => "default_location_subscribed_hosts",
17
- 'auditable_id' => 32,
18
- 'audited_changes' => {
19
- 'value' => [
20
- nil,
21
- "--- false\n..."
22
- ]
23
- }
24
- }
25
- end
26
26
  let(:audit_new) do
27
27
  {
28
28
  "user_id" => 1,
@@ -62,24 +62,26 @@ describe 'audit' do
62
62
  it 'shows audit information for changed records' do
63
63
  api_expects(:audits, :show, 'info')
64
64
  .with_params('id' => '83')
65
- .returns(audit_changed)
65
+ .returns(@audit_changed)
66
66
 
67
- output = OutputMatcher.new([
68
- 'Id: 83',
69
- 'At: 2017/10/31 11:25:44',
70
- 'IP: ::1',
71
- 'User: foreman_api_admin',
72
- 'Action: update',
73
- 'Audit type: ProvisioningTemplate',
74
- 'Audit record: default_location_subscribed_hosts',
75
- 'Audited changes:',
76
- ' 1) Attribute: value',
77
- ' Old:',
78
- '',
79
- ' New:',
80
- ' --- false',
81
- ' ...',
82
- ])
67
+ output = OutputMatcher.new(
68
+ [
69
+ 'Id: 83',
70
+ 'At: 2017/10/31 11:25:44',
71
+ 'IP: ::1',
72
+ 'User: foreman_api_admin',
73
+ 'Action: update',
74
+ 'Audit type: ProvisioningTemplate',
75
+ 'Audit record: default_location_subscribed_hosts',
76
+ 'Audited changes:',
77
+ ' 1) Attribute: value',
78
+ ' Old:',
79
+ '',
80
+ ' New:',
81
+ ' --- false',
82
+ ' ...',
83
+ ]
84
+ )
83
85
  expected_result = success_result(output)
84
86
 
85
87
  result = run_cmd(cmd + params)
@@ -91,36 +93,57 @@ describe 'audit' do
91
93
  .with_params('id' => '83')
92
94
  .returns(audit_new)
93
95
 
94
- output = OutputMatcher.new([
95
- 'Id: 63',
96
- 'At: 2017/10/09 23:42:44',
97
- 'IP: ::1',
98
- 'User: foreman_admin',
99
- 'Action: create',
100
- 'Audit type: User',
101
- 'Audit record: John Doe',
102
- 'Audited changes:',
103
- ' 1) Attribute: login',
104
- ' Value: john',
105
- ' 2) Attribute: firstname',
106
- ' Value: John',
107
- ' 3) Attribute: lastname',
108
- ' Value: Doe',
109
- ' 4) Attribute: mail',
110
- ' Value: john@ipa.test',
111
- ' 5) Attribute: admin',
112
- ' Value: false',
113
- ' 6) Attribute: auth_source_id',
114
- ' Value: 3',
115
- ' 7) Attribute: lower_login',
116
- ' Value: john',
117
- ' 8) Attribute: mail_enabled',
118
- ' Value: true',
119
- ])
96
+ output = OutputMatcher.new(
97
+ [
98
+ 'Id: 63',
99
+ 'At: 2017/10/09 23:42:44',
100
+ 'IP: ::1',
101
+ 'User: foreman_admin',
102
+ 'Action: create',
103
+ 'Audit type: User',
104
+ 'Audit record: John Doe',
105
+ 'Audited changes:',
106
+ ' 1) Attribute: login',
107
+ ' Value: john',
108
+ ' 2) Attribute: firstname',
109
+ ' Value: John',
110
+ ' 3) Attribute: lastname',
111
+ ' Value: Doe',
112
+ ' 4) Attribute: mail',
113
+ ' Value: john@ipa.test',
114
+ ' 5) Attribute: admin',
115
+ ' Value: false',
116
+ ' 6) Attribute: auth_source_id',
117
+ ' Value: 3',
118
+ ' 7) Attribute: lower_login',
119
+ ' Value: john',
120
+ ' 8) Attribute: mail_enabled',
121
+ ' Value: true',
122
+ ]
123
+ )
120
124
  expected_result = success_result(output)
121
125
 
122
126
  result = run_cmd(cmd + params)
123
127
  assert_cmd(expected_result, result)
124
128
  end
125
129
  end
130
+
131
+ describe 'audit-list' do
132
+ let(:cmd) { ['audit', 'list'] }
133
+ let(:audits) do
134
+ [@audit_changed]
135
+ end
136
+
137
+ it "should show index list" do
138
+ api_expects(:audits, :index).returns(audits)
139
+
140
+ output = IndexMatcher.new([
141
+ ['ID', 'AT', 'IP', 'USER', 'ACTION', 'AUDIT TYPE', 'AUDIT RECORD'],
142
+ ['83', '2017/10/31 11:25:44', '::1', 'foreman_api_admin', 'update', 'ProvisioningTemplate', 'default_location_subscribed_hosts']
143
+ ])
144
+
145
+ result = run_cmd(cmd)
146
+ assert_cmd(success_result(output), result)
147
+ end
148
+ end
126
149
  end