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.
- checksums.yaml +4 -4
- data/doc/release_notes.md +18 -0
- data/lib/hammer_cli_foreman.rb +0 -4
- data/lib/hammer_cli_foreman/associating_commands.rb +2 -2
- data/lib/hammer_cli_foreman/auth.rb +4 -4
- data/lib/hammer_cli_foreman/command_extensions/ping.rb +10 -1
- data/lib/hammer_cli_foreman/commands.rb +3 -1
- data/lib/hammer_cli_foreman/compute_resource/ovirt.rb +1 -0
- data/lib/hammer_cli_foreman/hosts/common_update_options.rb +16 -9
- data/lib/hammer_cli_foreman/location.rb +2 -0
- data/lib/hammer_cli_foreman/organization.rb +2 -0
- data/lib/hammer_cli_foreman/ping.rb +20 -11
- data/lib/hammer_cli_foreman/references.rb +16 -0
- data/lib/hammer_cli_foreman/settings.rb +14 -0
- data/lib/hammer_cli_foreman/version.rb +1 -1
- data/locale/ca/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/de/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/en/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/en_GB/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/es/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/fr/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/it/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ja/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ko/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ru/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/zh_TW/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/test/functional/audit_test.rb +86 -63
- data/test/functional/compute_profile_test.rb +4 -2
- data/test/functional/host_test.rb +26 -15
- data/test/functional/location_test.rb +134 -0
- data/test/functional/media_test.rb +130 -0
- data/test/functional/organization_test.rb +52 -0
- data/test/functional/realm_test.rb +1 -2
- data/test/functional/role_test.rb +9 -12
- data/test/functional/settings_test.rb +57 -1
- data/test/functional/user_test.rb +39 -0
- data/test/unit/media_test.rb +1 -1
- data/test/unit/partition_table_test.rb +2 -2
- data/test/unit/role_test.rb +2 -2
- metadata +6 -7
- data/lib/hammer_cli_foreman/trend.rb +0 -47
- data/test/functional/trend_test.rb +0 -83
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cb3de28c168226867cc9b1f4f63ea96bf2ff8746b831e2cdf01e6fe6670a53b
|
4
|
+
data.tar.gz: 55b321941992865b2339fd1e0d11b3845c1396c0699f90c52ab4ba774974b70f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e50e0beb69a60b01613b3d7c282b927e54872de4533364e079f768e22f4a1e63aea967d7113e72a32ee35a20d4475a1cefef03055af956027e7fb3ce0fde00e
|
7
|
+
data.tar.gz: 8ec8cc1402c57faa1b5bbb960bb9b4963e2c4c0e21b9e0a62e88c7e02ca2a01f976c83795c21b7c801aa635842df6fc5fb0794283bd8f666364bd91f404c661d
|
data/doc/release_notes.md
CHANGED
@@ -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))
|
data/lib/hammer_cli_foreman.rb
CHANGED
@@ -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[
|
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[
|
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"], "
|
40
|
-
option ["-a", "--oidc-authorization-endpoint"], "
|
41
|
-
option ["-c", "--oidc-client-id"], "
|
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"], "
|
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'] = _(
|
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,
|
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
|
-
|
90
|
-
|
91
|
-
|
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
|
-
|
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
|
-
|
3
|
+
resource :ping
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
class ForemanCommand < HammerCLIForeman::Command
|
6
|
+
action :ping
|
7
|
+
command_name 'foreman'
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
-
|
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
|
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,28 +1,28 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
2
|
|
3
3
|
describe 'audit' do
|
4
|
-
|
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
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
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
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
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
|