hammer_cli_foreman 3.6.0 → 3.8.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 +13 -0
- data/lib/hammer_cli_foreman/command_extensions/update_common.rb +1 -1
- data/lib/hammer_cli_foreman/commands.rb +2 -4
- data/lib/hammer_cli_foreman/compute_resource/utils.rb +7 -7
- data/lib/hammer_cli_foreman/exception_handler.rb +2 -8
- data/lib/hammer_cli_foreman/external_usergroup.rb +0 -2
- data/lib/hammer_cli_foreman/resource_supported_test.rb +1 -1
- data/lib/hammer_cli_foreman/testing/api_expectations.rb +2 -2
- data/lib/hammer_cli_foreman/version.rb +1 -1
- data/locale/ca/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/cs_CZ/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/ka/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/associating_commands_test.rb +2 -2
- data/test/functional/bookmark_test.rb +2 -2
- data/test/functional/commands/list_test.rb +4 -4
- data/test/functional/filter_test.rb +1 -1
- data/test/functional/location_test.rb +1 -1
- data/test/functional/media_test.rb +2 -2
- data/test/functional/report_template_test.rb +4 -4
- data/test/functional/settings_test.rb +1 -1
- data/test/functional/virtual_machine_test.rb +4 -4
- data/test/test_helper.rb +0 -1
- data/test/unit/api/interactive_basic_auth_test.rb +2 -2
- data/test/unit/api/oauth/oauth_authentication_code_grant_test.rb +2 -2
- data/test/unit/api/oauth/oauth_password_grant_test.rb +2 -2
- data/test/unit/api/session_authenticator_wrapper_test.rb +7 -7
- data/test/unit/architecture_test.rb +12 -12
- data/test/unit/audit_test.rb +6 -6
- data/test/unit/auth_source_external.rb +5 -5
- data/test/unit/auth_source_ldap_test.rb +12 -12
- data/test/unit/bookmark_test.rb +12 -12
- data/test/unit/commands_test.rb +9 -9
- data/test/unit/common_parameter_test.rb +10 -10
- data/test/unit/compute_profile_test.rb +12 -12
- data/test/unit/compute_resource_test.rb +18 -18
- data/test/unit/config_report_test.rb +7 -7
- data/test/unit/domain_test.rb +16 -16
- data/test/unit/exception_handler_test.rb +1 -1
- data/test/unit/external_usergroup_test.rb +15 -15
- data/test/unit/fact_test.rb +3 -3
- data/test/unit/filter_test.rb +18 -18
- data/test/unit/helpers/command.rb +33 -33
- data/test/unit/helpers/resource_disabled.rb +1 -1
- data/test/unit/host_test.rb +35 -35
- data/test/unit/hostgroup_test.rb +18 -18
- data/test/unit/id_resolver_test.rb +1 -1
- data/test/unit/image_test.rb +15 -15
- data/test/unit/location_test.rb +12 -12
- data/test/unit/mail_notification_test.rb +6 -6
- data/test/unit/media_test.rb +12 -12
- data/test/unit/model_test.rb +12 -12
- data/test/unit/operating_system_test.rb +16 -16
- data/test/unit/option_builders_test.rb +2 -2
- data/test/unit/organization_test.rb +12 -12
- data/test/unit/output/formatters_test.rb +4 -4
- data/test/unit/param_filters_test.rb +2 -2
- data/test/unit/partition_table_test.rb +14 -14
- data/test/unit/realm_test.rb +12 -12
- data/test/unit/role_test.rb +14 -14
- data/test/unit/settings_test.rb +5 -5
- data/test/unit/smart_proxy_test.rb +14 -14
- data/test/unit/subnet_test.rb +12 -12
- data/test/unit/template_test.rb +16 -16
- data/test/unit/user_test.rb +12 -12
- data/test/unit/usergroup_test.rb +12 -12
- metadata +24 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee6e69c32f2da750f35474c76deab901c34156e02f588831793b7f668e3445db
|
4
|
+
data.tar.gz: db9db4349a41cf3e1058b33de2cdb599df9526dc6477c12d8fbb8cb3cfccba1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38103b52f65f395870d1cf31da86d4df330248f06ffceb346ed63ec1c9bfb7a7f79a8bfd30fd46d458af97b47ef3c9d08cdd32c056e9eb4765bbef4f2d74be91
|
7
|
+
data.tar.gz: 5c57d8514e09458120a4e01dda31de420b27c85616572ad6577fccf486065294d9308b6b70f344c36070b4d08e52dbfd6f5d78a980f98e81256d95f45ff84a15
|
data/doc/release_notes.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
Release notes
|
2
2
|
=============
|
3
|
+
### 3.8.0 (2023-08-25)
|
4
|
+
* Support mocha 2.1 ([PR #618](https://github.com/theforeman/hammer-cli-foreman/pull/618)), [#34879](http://projects.theforeman.org/issues/34879)
|
5
|
+
* Add ga to run tests on ruby 3+ ([PR #617](https://github.com/theforeman/hammer-cli-foreman/pull/617))
|
6
|
+
* Update tx for hammer-cli-foreman, [#36315](http://projects.theforeman.org/issues/36315)
|
7
|
+
* Add packit config
|
8
|
+
* Bump to 3.8.0-develop
|
9
|
+
|
10
|
+
### 3.7.0 (2023-05-23)
|
11
|
+
* Update rake for hammer-cli-foreman ([PR #613](https://github.com/theforeman/hammer-cli-foreman/pull/613)), [#36337](http://projects.theforeman.org/issues/36337)
|
12
|
+
* Update minitest version ([PR #611](https://github.com/theforeman/hammer-cli-foreman/pull/611)), [#36349](http://projects.theforeman.org/issues/36349)
|
13
|
+
* Allow to suppress nothing to update message, [#36213](http://projects.theforeman.org/issues/36213)
|
14
|
+
* Bump to 3.7.0-develop
|
15
|
+
|
3
16
|
### 3.6.0 (2023-02-23)
|
4
17
|
* Support basic auth for external sources, [#11317](http://projects.theforeman.org/issues/11317)
|
5
18
|
* Remove underscore from labels ([PR #608](https://github.com/theforeman/hammer-cli-foreman/pull/608)), [#35904](http://projects.theforeman.org/issues/35904)
|
@@ -7,7 +7,7 @@ module HammerCLIForeman
|
|
7
7
|
|
8
8
|
request_params do |params, command_object|
|
9
9
|
update_params = params[command_object.resource.singular_name]
|
10
|
-
command_object.context[:action_message] = :nothing_to_do if update_params && update_params.empty?
|
10
|
+
command_object.context[:action_message] = :nothing_to_do if update_params && update_params.empty? && command_object.context[:action_message].nil?
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -244,7 +244,7 @@ module HammerCLIForeman
|
|
244
244
|
super
|
245
245
|
begin
|
246
246
|
output_definition.update_field_sets('THIN', (searchables.for(resource).map(&:name) + ['id']).map(&:to_sym))
|
247
|
-
rescue StandardError
|
247
|
+
rescue StandardError
|
248
248
|
# Some subcommands may not have such fields or defined resource
|
249
249
|
end
|
250
250
|
end
|
@@ -489,7 +489,7 @@ module HammerCLIForeman
|
|
489
489
|
super
|
490
490
|
begin
|
491
491
|
output_definition.update_field_sets('THIN', (searchables.for(resource).map(&:name) + ['id']).map(&:to_sym))
|
492
|
-
rescue StandardError
|
492
|
+
rescue StandardError
|
493
493
|
# Some subcommands may not have such fields or defined resource
|
494
494
|
end
|
495
495
|
end
|
@@ -585,8 +585,6 @@ module HammerCLIForeman
|
|
585
585
|
action :update
|
586
586
|
|
587
587
|
def self.create_option_builder
|
588
|
-
configurator = BuilderConfigurator.new(searchables, dependency_resolver)
|
589
|
-
|
590
588
|
builder = ForemanOptionBuilder.new(searchables)
|
591
589
|
builder.builders = [
|
592
590
|
SearchablesOptionBuilder.new(resource, searchables),
|
@@ -13,13 +13,13 @@ module HammerCLIForeman
|
|
13
13
|
HammerCLIForeman.foreman_resource(:hostgroups).call(:show, 'id' => hostgroup_id)
|
14
14
|
)
|
15
15
|
compute_resource_id = hostgroup['compute_resource_id']
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
if !hostgroup['compute_resource_name'].to_s.strip.empty? && compute_resource_id.nil?
|
17
|
+
compute_resource= HammerCLIForeman.record_to_common_format(
|
18
|
+
HammerCLIForeman.foreman_resource(:compute_resources).call(
|
19
|
+
:index, :search => "name = \"#{hostgroup['compute_resource_name']}\""
|
20
|
+
)
|
21
|
+
)
|
22
|
+
compute_resource_id = compute_resource['results'][0]['id'] if compute_resource['results'][0]
|
23
23
|
end
|
24
24
|
compute_resource_id
|
25
25
|
end
|
@@ -99,7 +99,7 @@ module HammerCLIForeman
|
|
99
99
|
response = JSON.parse(e.response)
|
100
100
|
response = HammerCLIForeman.record_to_common_format(response) unless response.has_key?('message')
|
101
101
|
message = response['message'] || e.message
|
102
|
-
rescue JSON::ParserError
|
102
|
+
rescue JSON::ParserError
|
103
103
|
message = e.message
|
104
104
|
end
|
105
105
|
|
@@ -123,13 +123,7 @@ module HammerCLIForeman
|
|
123
123
|
host_url = HammerCLI::Settings.get(:_params, :host) || HammerCLI::Settings.get(:foreman, :host)
|
124
124
|
uri = URI.parse(host_url)
|
125
125
|
ssl_option = HammerCLI::SSLOptions.new.get_options(uri)
|
126
|
-
|
127
|
-
host = '<FOREMAN_HOST>'
|
128
|
-
cert_name = "#{host}.crt"
|
129
|
-
else
|
130
|
-
host = uri.to_s
|
131
|
-
cert_name = "#{uri.host}.crt"
|
132
|
-
end
|
126
|
+
host = uri.host.nil? ? '<FOREMAN_HOST>' : uri.to_s
|
133
127
|
|
134
128
|
cmd = "hammer --fetch-ca-cert #{host}"
|
135
129
|
|
@@ -12,12 +12,12 @@ module HammerCLIForeman
|
|
12
12
|
def initialize(resource=nil, action=nil, &block)
|
13
13
|
@expected_resource = resource
|
14
14
|
@expected_action = action
|
15
|
-
@block = block
|
15
|
+
@block = block
|
16
16
|
@expected_params = {}
|
17
17
|
end
|
18
18
|
|
19
19
|
def matches?(actual_parameters)
|
20
|
-
action, params,
|
20
|
+
action, params, _headers, _options = actual_parameters.shift(4)
|
21
21
|
action_name = action.name.to_s
|
22
22
|
resource_name = action.resource.to_s
|
23
23
|
|
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
|
Binary file
|
Binary file
|
@@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), 'test_helper')
|
|
3
3
|
require 'hammer_cli_foreman/operating_system'
|
4
4
|
|
5
5
|
describe HammerCLIForeman::OperatingSystem do
|
6
|
-
|
6
|
+
describe 'AddProvisioningTemplateCommand' do
|
7
7
|
before do
|
8
8
|
@cmd = ['os', 'add-provisioning-template']
|
9
9
|
@os_before_update = {
|
@@ -106,7 +106,7 @@ describe HammerCLIForeman::OperatingSystem do
|
|
106
106
|
|
107
107
|
end
|
108
108
|
|
109
|
-
|
109
|
+
describe 'RemoveProvisioningTemplateCommand' do
|
110
110
|
before do
|
111
111
|
@cmd = ['os', 'remove-provisioning-template']
|
112
112
|
@os_before_update = {
|
@@ -87,8 +87,8 @@ describe 'bookmark' do
|
|
87
87
|
it 'should create a bookmark' do
|
88
88
|
params = ['--name=newBookmark', '--controller=hosts', '--query=status = failed']
|
89
89
|
api_expects(:bookmarks, :create, 'Create bookmark') do |params|
|
90
|
-
(params['bookmark']['name'] == 'newBookmark')
|
91
|
-
(params['bookmark']['controller'] == 'hosts')
|
90
|
+
(params['bookmark']['name'] == 'newBookmark') &&
|
91
|
+
(params['bookmark']['controller'] == 'hosts') &&
|
92
92
|
(params['bookmark']['query'] == 'status = failed')
|
93
93
|
end
|
94
94
|
result = run_cmd(@cmd + params)
|
@@ -33,7 +33,7 @@ describe HammerCLIForeman::ListCommand do
|
|
33
33
|
HammerCLI::Settings.clear
|
34
34
|
end
|
35
35
|
|
36
|
-
|
36
|
+
describe 'help' do
|
37
37
|
let(:cmd) { ['host', 'list'] }
|
38
38
|
let(:params) { ['--help'] }
|
39
39
|
|
@@ -49,7 +49,7 @@ describe HammerCLIForeman::ListCommand do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
describe "api interaction" do
|
52
|
-
|
52
|
+
describe "without per_page in settings" do
|
53
53
|
it "fetches only first page when there's not enough records" do
|
54
54
|
expect_paged_call(1, 1000, 10)
|
55
55
|
result = run_cmd([], {}, TestList)
|
@@ -86,7 +86,7 @@ describe HammerCLIForeman::ListCommand do
|
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
|
-
|
89
|
+
describe "with per_page in settings" do
|
90
90
|
let(:per_page_in_settings) { 30 }
|
91
91
|
before do
|
92
92
|
HammerCLI::Settings.load({ :ui => { :per_page => per_page_in_settings } })
|
@@ -139,7 +139,7 @@ describe HammerCLIForeman::ListCommand do
|
|
139
139
|
assert_cmd(expected_result, result)
|
140
140
|
end
|
141
141
|
|
142
|
-
|
142
|
+
describe 'with per_page in settings' do
|
143
143
|
before do
|
144
144
|
HammerCLI::Settings.load({ :ui => { :per_page => '1' } })
|
145
145
|
end
|
@@ -262,7 +262,7 @@ describe 'update' do
|
|
262
262
|
|
263
263
|
api_expects(:locations, :index)
|
264
264
|
api_expects(:locations, :update, 'Update a location') do |params|
|
265
|
-
(params['
|
265
|
+
(params['id'] == '1') &&
|
266
266
|
(params['location']['name'] == 'Default Location test')
|
267
267
|
end
|
268
268
|
|
@@ -77,7 +77,7 @@ describe 'medium' do
|
|
77
77
|
params = ['--name=CentOS mirror', '--path=http://mirror.centos.org/centos/$major/os/$arch']
|
78
78
|
|
79
79
|
api_expects(:media, :create) do |params|
|
80
|
-
(params['medium']['name'] == 'CentOS mirror')
|
80
|
+
(params['medium']['name'] == 'CentOS mirror') &&
|
81
81
|
(params['medium']['path'] == 'http://mirror.centos.org/centos/$major/os/$arch')
|
82
82
|
end
|
83
83
|
|
@@ -119,7 +119,7 @@ describe 'medium' do
|
|
119
119
|
params = ['--id=1', '--new-name=CentOS mirror test']
|
120
120
|
|
121
121
|
api_expects(:media, :update, 'Update a media') do |params|
|
122
|
-
(params['
|
122
|
+
(params['id'] == '1') &&
|
123
123
|
(params['medium']['name'] == 'CentOS mirror test')
|
124
124
|
end
|
125
125
|
|
@@ -114,7 +114,7 @@ describe 'report-template' do
|
|
114
114
|
|
115
115
|
it 'invokes editor in interactive mode' do
|
116
116
|
params = ['--name=test', '--default=yes', "--interactive", '--locked=no', '--snippet=no']
|
117
|
-
HammerCLI.expects(:open_in_editor).with("",
|
117
|
+
HammerCLI.expects(:open_in_editor).with("", content_type: "report_template", suffix: ".erb").returns('Template content')
|
118
118
|
api_expects(:report_templates, :create, 'Create template').with_params(
|
119
119
|
'report_template' => {
|
120
120
|
'name' => 'test',
|
@@ -181,7 +181,7 @@ describe 'report-template' do
|
|
181
181
|
it 'invokes editor in interactive mode' do
|
182
182
|
params = ['--id=3', '--new-name=test', '--default=yes', "--interactive", '--locked=no', '--snippet=no']
|
183
183
|
HammerCLI.expects(:open_in_editor).with(
|
184
|
-
"Template Content",
|
184
|
+
"Template Content", content_type: "report_template", suffix: ".erb").returns('Template content')
|
185
185
|
api_expects(:report_templates, :show, 'Show').with_params('id' => '3').returns(third_report)
|
186
186
|
api_expects(:report_templates, :update, 'Update template').with_params(
|
187
187
|
'report_template' => {
|
@@ -307,7 +307,7 @@ describe 'report-template' do
|
|
307
307
|
{ 'job_id' => job_id, 'data_url' => "/report_data/#{job_id}" }
|
308
308
|
end
|
309
309
|
|
310
|
-
|
310
|
+
describe 'without --wait' do
|
311
311
|
it 'schedule report and prints out data for getting the result' do
|
312
312
|
params = ['--id=3', '--inputs=Host filter=filter']
|
313
313
|
api_expects(:report_templates, :schedule_report, 'Schedule').with_params(
|
@@ -320,7 +320,7 @@ describe 'report-template' do
|
|
320
320
|
end
|
321
321
|
end
|
322
322
|
|
323
|
-
|
323
|
+
describe 'with --wait' do
|
324
324
|
it 'generates the report to the file' do
|
325
325
|
params = ['--id=3', '--inputs=Host filter=filter', '--wait', '--path=/tmp']
|
326
326
|
api_expects(:report_templates, :schedule_report, 'Schedule').with_params(
|
@@ -101,7 +101,7 @@ describe 'Settings' do
|
|
101
101
|
params = ['--id=1', '--value=true']
|
102
102
|
|
103
103
|
api_expects(:settings, :update, 'Update a setting') do |params|
|
104
|
-
(params['
|
104
|
+
(params['id'] == '1') &&
|
105
105
|
(params['setting']['value'] == 'true')
|
106
106
|
end
|
107
107
|
|
@@ -5,7 +5,7 @@ require 'hammer_cli_foreman/compute_resource'
|
|
5
5
|
|
6
6
|
describe HammerCLIForeman::VirtualMachine do
|
7
7
|
|
8
|
-
|
8
|
+
describe "InfoCommand" do
|
9
9
|
before do
|
10
10
|
@cmd = ["compute-resource", "virtual-machine", "info"]
|
11
11
|
@vm = {
|
@@ -43,7 +43,7 @@ describe HammerCLIForeman::VirtualMachine do
|
|
43
43
|
|
44
44
|
end
|
45
45
|
|
46
|
-
|
46
|
+
describe "ListCommand" do
|
47
47
|
before do
|
48
48
|
@cmd = ["compute-resource", "virtual-machines"]
|
49
49
|
@available_virtual_machines = [
|
@@ -68,7 +68,7 @@ describe HammerCLIForeman::VirtualMachine do
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
|
71
|
+
describe "PowerCommand" do
|
72
72
|
before do
|
73
73
|
@cmd = ["compute-resource", "virtual-machine", "power"]
|
74
74
|
end
|
@@ -97,7 +97,7 @@ describe HammerCLIForeman::VirtualMachine do
|
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
-
|
100
|
+
describe "DeleteCommand" do
|
101
101
|
before do
|
102
102
|
@cmd = ["compute-resource", "virtual-machine", "delete"]
|
103
103
|
end
|
data/test/test_helper.rb
CHANGED
@@ -4,7 +4,7 @@ describe HammerCLIForeman::Api::InteractiveBasicAuth do
|
|
4
4
|
let(:request) { mock() }
|
5
5
|
let(:args) { {} }
|
6
6
|
|
7
|
-
|
7
|
+
describe "interactive mode" do
|
8
8
|
before :each do
|
9
9
|
HammerCLI.stubs(:interactive?).returns true
|
10
10
|
end
|
@@ -42,7 +42,7 @@ describe HammerCLIForeman::Api::InteractiveBasicAuth do
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
|
45
|
+
describe "non-interactive mode" do
|
46
46
|
it "doesn't ask for credentials when they're not provided" do
|
47
47
|
HammerCLI.stubs(:interactive?).returns false
|
48
48
|
auth = HammerCLIForeman::Api::InteractiveBasicAuth.new(nil, nil)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), '../../test_helper')
|
2
2
|
|
3
3
|
describe HammerCLIForeman::Api::Oauth::AuthenticationCodeGrant do
|
4
|
-
let(:request) {
|
4
|
+
let(:request) { {} }
|
5
5
|
let(:args) { {} }
|
6
6
|
let(:params) {{
|
7
7
|
oidc_redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',
|
@@ -33,7 +33,7 @@ describe HammerCLIForeman::Api::Oauth::AuthenticationCodeGrant do
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
|
36
|
+
describe "interactive mode" do
|
37
37
|
before :each do
|
38
38
|
HammerCLI.stubs(:interactive?).returns true
|
39
39
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), '../../test_helper')
|
2
2
|
|
3
3
|
describe HammerCLIForeman::Api::Oauth::PasswordGrant do
|
4
|
-
let(:request) {
|
4
|
+
let(:request) { {} }
|
5
5
|
let(:args) { {} }
|
6
6
|
let(:params) {{
|
7
7
|
username: 'user1',
|
@@ -31,7 +31,7 @@ describe HammerCLIForeman::Api::Oauth::PasswordGrant do
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
|
34
|
+
describe "interactive mode" do
|
35
35
|
before :each do
|
36
36
|
HammerCLI.stubs(:interactive?).returns true
|
37
37
|
end
|
@@ -52,7 +52,7 @@ describe HammerCLIForeman::Api::SessionAuthenticatorWrapper do
|
|
52
52
|
end
|
53
53
|
|
54
54
|
describe '#authenticate' do
|
55
|
-
|
55
|
+
describe "when there's saved session" do
|
56
56
|
it 'sets session id in cookies for basic auth' do
|
57
57
|
session_params = {
|
58
58
|
session_id: 'SOME_SESSION_ID', auth_type: 'Basic_Auth'
|
@@ -139,9 +139,9 @@ describe HammerCLIForeman::Api::SessionAuthenticatorWrapper do
|
|
139
139
|
end
|
140
140
|
end
|
141
141
|
|
142
|
-
|
142
|
+
describe "when the session file is corrupted" do
|
143
143
|
it 'reports error' do
|
144
|
-
|
144
|
+
_dir, _out, err = prepare_session_storage :session_id => 'SOME_SESSION_ID' do |auth, dir|
|
145
145
|
write_session(dir, '{not a valid: json')
|
146
146
|
|
147
147
|
wrapped_auth.expects(:authenticate).with(request, args)
|
@@ -152,7 +152,7 @@ describe HammerCLIForeman::Api::SessionAuthenticatorWrapper do
|
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
155
|
-
|
155
|
+
describe "when no session is saved" do
|
156
156
|
it 'passes to wrapped authenticator' do
|
157
157
|
prepare_session_storage do |auth, dir|
|
158
158
|
wrapped_auth.expects(:authenticate).with(request, args)
|
@@ -164,7 +164,7 @@ describe HammerCLIForeman::Api::SessionAuthenticatorWrapper do
|
|
164
164
|
end
|
165
165
|
|
166
166
|
describe '#error' do
|
167
|
-
|
167
|
+
describe 'when there is existing session' do
|
168
168
|
it 'sets session id to nil on unauthorized exception' do
|
169
169
|
prepare_session_storage :session_id => 'SOME_SESSION_ID' do |auth, dir|
|
170
170
|
ex = RestClient::Unauthorized.new
|
@@ -204,7 +204,7 @@ describe HammerCLIForeman::Api::SessionAuthenticatorWrapper do
|
|
204
204
|
end
|
205
205
|
end
|
206
206
|
|
207
|
-
|
207
|
+
describe 'when user has changed' do
|
208
208
|
it 'sets a special error message' do
|
209
209
|
prepare_session_storage :session_id => 'SOME_SESSION_ID' do |auth, dir|
|
210
210
|
auth.force_user_change
|
@@ -227,7 +227,7 @@ describe HammerCLIForeman::Api::SessionAuthenticatorWrapper do
|
|
227
227
|
end
|
228
228
|
end
|
229
229
|
|
230
|
-
|
230
|
+
describe 'when there is no existing session' do
|
231
231
|
it 'passes exception to wrapped authenticator on unauthorized exception' do
|
232
232
|
prepare_session_storage do |auth, dir|
|
233
233
|
ex = RestClient::Unauthorized.new
|
@@ -7,21 +7,21 @@ describe HammerCLIForeman::Architecture do
|
|
7
7
|
|
8
8
|
include CommandTestHelper
|
9
9
|
|
10
|
-
|
10
|
+
describe "ListCommand" do
|
11
11
|
before do
|
12
12
|
ResourceMocks.mock_action_call(:architectures, :index, [])
|
13
13
|
end
|
14
14
|
|
15
15
|
let(:cmd) { HammerCLIForeman::Architecture::ListCommand.new("", ctx) }
|
16
16
|
|
17
|
-
|
17
|
+
describe "parameters" do
|
18
18
|
it_should_accept "no arguments"
|
19
19
|
it_should_accept_search_params
|
20
20
|
it_should_accept 'organization', ['--organization-id=1']
|
21
21
|
it_should_accept 'location', ['--location-id=1']
|
22
22
|
end
|
23
23
|
|
24
|
-
|
24
|
+
describe "output" do
|
25
25
|
let(:expected_record_count) { count_records(cmd.resource.call(:index)) }
|
26
26
|
|
27
27
|
it_should_print_n_records
|
@@ -32,11 +32,11 @@ describe HammerCLIForeman::Architecture do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
|
35
|
-
|
35
|
+
describe "InfoCommand" do
|
36
36
|
|
37
37
|
let(:cmd) { HammerCLIForeman::Architecture::InfoCommand.new("", ctx) }
|
38
38
|
|
39
|
-
|
39
|
+
describe "parameters" do
|
40
40
|
it_should_accept "id", ["--id=1"]
|
41
41
|
it_should_accept "name", ["--name=arch"]
|
42
42
|
it_should_accept 'organization', %w[--id=1 --organization-id=1]
|
@@ -44,7 +44,7 @@ describe HammerCLIForeman::Architecture do
|
|
44
44
|
# it_should_fail_with "no arguments" # TODO: temporarily disabled, parameters are checked in the id resolver
|
45
45
|
end
|
46
46
|
|
47
|
-
|
47
|
+
describe "output" do
|
48
48
|
with_params ["--id=1"] do
|
49
49
|
it_should_print_n_records 1
|
50
50
|
it_should_print_column "Name"
|
@@ -55,11 +55,11 @@ describe HammerCLIForeman::Architecture do
|
|
55
55
|
end
|
56
56
|
|
57
57
|
|
58
|
-
|
58
|
+
describe "CreateCommand" do
|
59
59
|
|
60
60
|
let(:cmd) { HammerCLIForeman::Architecture::CreateCommand.new("", ctx) }
|
61
61
|
|
62
|
-
|
62
|
+
describe "parameters" do
|
63
63
|
it_should_accept "name", ["--name=arch"]
|
64
64
|
it_should_accept 'organization', %w[--name=arch --organization-id=1]
|
65
65
|
it_should_accept 'location', %w[--name=arch --location-id=1]
|
@@ -70,11 +70,11 @@ describe HammerCLIForeman::Architecture do
|
|
70
70
|
end
|
71
71
|
|
72
72
|
|
73
|
-
|
73
|
+
describe "DeleteCommand" do
|
74
74
|
|
75
75
|
let(:cmd) { HammerCLIForeman::Architecture::DeleteCommand.new("", ctx) }
|
76
76
|
|
77
|
-
|
77
|
+
describe "parameters" do
|
78
78
|
it_should_accept "name", ["--name=arch"]
|
79
79
|
it_should_accept "id", ["--id=1"]
|
80
80
|
it_should_accept 'organization', %w[--id=1 --organization-id=1]
|
@@ -85,11 +85,11 @@ describe HammerCLIForeman::Architecture do
|
|
85
85
|
end
|
86
86
|
|
87
87
|
|
88
|
-
|
88
|
+
describe "UpdateCommand" do
|
89
89
|
|
90
90
|
let(:cmd) { HammerCLIForeman::Architecture::UpdateCommand.new("", ctx) }
|
91
91
|
|
92
|
-
|
92
|
+
describe "parameters" do
|
93
93
|
it_should_accept "name", ["--name=arch", "--new-name=arch2"]
|
94
94
|
it_should_accept "id", ["--id=1", "--new-name=arch2"]
|
95
95
|
it_should_accept 'organization', %w[--id=1 --new-name=arch2 --organization-id=1]
|
data/test/unit/audit_test.rb
CHANGED
@@ -6,19 +6,19 @@ require 'hammer_cli_foreman/audit'
|
|
6
6
|
describe HammerCLIForeman::Audit do
|
7
7
|
include CommandTestHelper
|
8
8
|
|
9
|
-
|
9
|
+
describe "ListCommand" do
|
10
10
|
before do
|
11
11
|
ResourceMocks.mock_action_call(:audits, :index, [])
|
12
12
|
end
|
13
13
|
|
14
14
|
let(:cmd) { HammerCLIForeman::Audit::ListCommand.new("", ctx) }
|
15
15
|
|
16
|
-
|
16
|
+
describe "parameters" do
|
17
17
|
it_should_accept "no arguments"
|
18
18
|
it_should_accept_search_params
|
19
19
|
end
|
20
20
|
|
21
|
-
|
21
|
+
describe "output" do
|
22
22
|
let(:expected_record_count) { count_records(cmd.resource.call(:index)) }
|
23
23
|
|
24
24
|
it_should_print_n_records
|
@@ -32,18 +32,18 @@ describe HammerCLIForeman::Audit do
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
|
35
|
+
describe "InfoCommand" do
|
36
36
|
before do
|
37
37
|
cmd.stubs(:extend_data)
|
38
38
|
end
|
39
39
|
|
40
40
|
let(:cmd) { HammerCLIForeman::Audit::InfoCommand.new("", ctx) }
|
41
41
|
|
42
|
-
|
42
|
+
describe "parameters" do
|
43
43
|
it_should_accept "id", ["--id=1"]
|
44
44
|
end
|
45
45
|
|
46
|
-
|
46
|
+
describe "output" do
|
47
47
|
with_params ["--id=1"] do
|
48
48
|
it_should_print_n_records 1
|
49
49
|
it_should_print_column "Id"
|