hammer_cli_foreman 2.1.3 → 2.2.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 +8 -7
- data/doc/testing.md +13 -0
- data/lib/hammer_cli_foreman/associating_commands.rb +2 -3
- data/lib/hammer_cli_foreman/auth.rb +4 -4
- data/lib/hammer_cli_foreman/output/fields.rb +1 -1
- data/lib/hammer_cli_foreman/output/formatters.rb +1 -1
- data/lib/hammer_cli_foreman/testing/api_expectations.rb +10 -0
- data/lib/hammer_cli_foreman/version.rb +1 -1
- data/lib/minitest/coverage_reporter.rb +94 -0
- data/lib/minitest/hammer_coverage_plugin.rb +19 -0
- 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/commands/list_test.rb +11 -11
- data/test/functional/host_test.rb +3 -3
- data/test/functional/realm_test.rb +104 -0
- data/test/functional/trend_test.rb +63 -2
- data/test/reports/TEST-Minitest-Result.xml +4344 -0
- data/test/test_helper.rb +5 -2
- data/test/unit/api/interactive_basic_auth_test.rb +3 -1
- 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_test.rb +3 -4
- data/test/unit/apipie_resource_mock.rb +4 -4
- data/test/unit/commands_test.rb +19 -19
- data/test/unit/common_parameter_test.rb +1 -1
- data/test/unit/dependency_resolver_test.rb +4 -4
- data/test/unit/exception_handler_test.rb +13 -13
- data/test/unit/helpers/command.rb +5 -5
- data/test/unit/helpers/resource_disabled.rb +2 -2
- data/test/unit/host_test.rb +2 -2
- data/test/unit/id_resolver_test.rb +23 -23
- data/test/unit/option_builders_test.rb +49 -49
- data/test/unit/option_sources/id_params_test.rb +2 -2
- data/test/unit/option_sources/ids_params_test.rb +2 -2
- data/test/unit/output/formatters_test.rb +21 -21
- data/test/unit/param_filters_test.rb +17 -17
- data/test/unit/sessions_test.rb +24 -24
- data/test/unit/template_test.rb +1 -1
- metadata +105 -99
@@ -15,7 +15,7 @@ describe HammerCLIForeman::OptionSources::IdParams do
|
|
15
15
|
hg_cmd.expects(:get_resource_id).with { |res| res.name == :domains }.never
|
16
16
|
option_data = { 'option_domain_id' => 3, 'option_domain_name' => 'test' }
|
17
17
|
params = id_params_source.get_options([], option_data)
|
18
|
-
params.must_equal option_data
|
18
|
+
_(params).must_equal option_data
|
19
19
|
end
|
20
20
|
|
21
21
|
it "resolves param when unset" do
|
@@ -24,7 +24,7 @@ describe HammerCLIForeman::OptionSources::IdParams do
|
|
24
24
|
option_data = { 'option_domain_id' => nil, 'option_domain_name' => 'test' }
|
25
25
|
expected_data = { 'option_domain_id' => 1, 'option_domain_name' => 'test' }
|
26
26
|
params = id_params_source.get_options([], option_data)
|
27
|
-
params.must_equal expected_data
|
27
|
+
_(params).must_equal expected_data
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -15,7 +15,7 @@ describe HammerCLIForeman::OptionSources::IdsParams do
|
|
15
15
|
cmd.expects(:get_resource_ids).with { |res| res.name == :locations }.never
|
16
16
|
option_data = { 'option_location_ids' => [3], 'option_location_names' => 'test' }
|
17
17
|
params = ids_params_source.get_options([], option_data)
|
18
|
-
params.must_equal option_data
|
18
|
+
_(params).must_equal option_data
|
19
19
|
end
|
20
20
|
|
21
21
|
it "resolves param when unset" do
|
@@ -24,7 +24,7 @@ describe HammerCLIForeman::OptionSources::IdsParams do
|
|
24
24
|
option_data = { 'option_location_ids' => nil, 'option_location_names' => 'test' }
|
25
25
|
expected_data = { 'option_location_ids' => [1], 'option_location_names' => 'test' }
|
26
26
|
params = ids_params_source.get_options([], option_data)
|
27
|
-
params.must_equal expected_data
|
27
|
+
_(params).must_equal expected_data
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -19,13 +19,13 @@ describe HammerCLIForeman::Output::Formatters::StructuredReferenceFormatter do
|
|
19
19
|
context 'with symbol keys' do
|
20
20
|
it 'formats name' do
|
21
21
|
options = {:display_field_key => :server_name}
|
22
|
-
formatter.format(reference, options).must_equal('Name' => "#{reference_str_keys['server_name']}")
|
22
|
+
_(formatter.format(reference, options)).must_equal('Name' => "#{reference_str_keys['server_name']}")
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'formats id' do
|
26
26
|
options = {:display_field_key => :server_name,
|
27
27
|
:details => {:structured_label => 'Id', :key => :server_id}}
|
28
|
-
formatter.format(reference, options)
|
28
|
+
_(formatter.format(reference, options))
|
29
29
|
.must_equal('Name' => "#{reference_str_keys['server_name']}", 'Id' => reference_str_keys['server_id'])
|
30
30
|
end
|
31
31
|
end
|
@@ -33,13 +33,13 @@ describe HammerCLIForeman::Output::Formatters::StructuredReferenceFormatter do
|
|
33
33
|
context 'with string keys' do
|
34
34
|
it 'formats name' do
|
35
35
|
options = {:display_field_key => :server_name}
|
36
|
-
formatter.format(reference_str_keys, options).must_equal('Name' => "#{reference_str_keys['server_name']}")
|
36
|
+
_(formatter.format(reference_str_keys, options)).must_equal('Name' => "#{reference_str_keys['server_name']}")
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'formats id' do
|
40
40
|
options = {:display_field_key => :server_name,
|
41
41
|
:details => {:structured_label => 'Id', :key => :server_id}}
|
42
|
-
formatter.format(reference_str_keys, options).must_equal('Name' => "#{reference_str_keys['server_name']}", 'Id' => reference_str_keys['server_id'])
|
42
|
+
_(formatter.format(reference_str_keys, options)).must_equal('Name' => "#{reference_str_keys['server_name']}", 'Id' => reference_str_keys['server_id'])
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -59,7 +59,7 @@ describe HammerCLIForeman::Output::Formatters::ReferenceFormatter do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'recovers when the resource is missing' do
|
62
|
-
formatter.format(nil).must_equal ''
|
62
|
+
_(formatter.format(nil)).must_equal ''
|
63
63
|
end
|
64
64
|
|
65
65
|
context 'with symbol keys' do
|
@@ -68,40 +68,40 @@ describe HammerCLIForeman::Output::Formatters::ReferenceFormatter do
|
|
68
68
|
end
|
69
69
|
|
70
70
|
it 'formats name' do
|
71
|
-
formatter.format(reference_sym_keys, {}).must_equal("#{reference_sym_keys[:name]}")
|
71
|
+
_(formatter.format(reference_sym_keys, {})).must_equal("#{reference_sym_keys[:name]}")
|
72
72
|
end
|
73
73
|
|
74
74
|
it 'can override name key' do
|
75
75
|
options = {:display_field_key => :another_name}
|
76
|
-
formatter.format(reference_sym_keys, options).must_equal("#{reference_sym_keys[:another_name]}")
|
76
|
+
_(formatter.format(reference_sym_keys, options)).must_equal("#{reference_sym_keys[:another_name]}")
|
77
77
|
end
|
78
78
|
|
79
79
|
it 'formats id' do
|
80
|
-
options = {:details => {:key => :id, :label => 'Id'}, :context => {:show_ids => true}}
|
81
|
-
formatter.format(reference_sym_keys, options)
|
80
|
+
options = {:details => {:key => :id, :label => {:target => 'Id'}}, :context => {:show_ids => true}}
|
81
|
+
_(formatter.format(reference_sym_keys, options))
|
82
82
|
.must_equal("Server (Id: #{reference_sym_keys[:id]})")
|
83
83
|
end
|
84
84
|
|
85
85
|
it 'formats details' do
|
86
86
|
options = { :details => { :label => _('url'), :key => :url } }
|
87
|
-
formatter.format(reference_sym_keys, options).must_equal("Server (url: #{reference_sym_keys[:url]})")
|
87
|
+
_(formatter.format(reference_sym_keys, options)).must_equal("Server (url: #{reference_sym_keys[:url]})")
|
88
88
|
end
|
89
89
|
|
90
90
|
it 'formats multiple details' do
|
91
91
|
options = { :details => [{ :label => _('url'), :key => :url },
|
92
92
|
{:label => _('desc'), :key => :desc }]
|
93
93
|
}
|
94
|
-
formatter.format(reference_sym_keys, options)
|
94
|
+
_(formatter.format(reference_sym_keys, options))
|
95
95
|
.must_equal("Server (url: #{reference_sym_keys[:url]}, desc: #{reference_sym_keys[:desc]})")
|
96
96
|
end
|
97
97
|
|
98
98
|
it 'formats details and id' do
|
99
99
|
options = {:context => {:show_ids => true},
|
100
|
-
:details => [{
|
100
|
+
:details => [{:label => _('url'), :key => :url },
|
101
101
|
{:label => _('desc'), :key => :desc },
|
102
102
|
{:label => _('Id'), :key => :id }]
|
103
103
|
}
|
104
|
-
formatter.format(reference_sym_keys, options)
|
104
|
+
_(formatter.format(reference_sym_keys, options))
|
105
105
|
.must_equal("Server (url: #{reference_sym_keys[:url]}, desc: #{reference_sym_keys[:desc]}, Id: #{reference_sym_keys[:id]})")
|
106
106
|
end
|
107
107
|
end
|
@@ -114,36 +114,36 @@ describe HammerCLIForeman::Output::Formatters::ReferenceFormatter do
|
|
114
114
|
end
|
115
115
|
|
116
116
|
it 'formats name' do
|
117
|
-
formatter.format(reference_str_keys, {}).must_equal("#{reference_str_keys['name']}")
|
117
|
+
_(formatter.format(reference_str_keys, {})).must_equal("#{reference_str_keys['name']}")
|
118
118
|
end
|
119
119
|
|
120
120
|
it 'can override name key' do
|
121
121
|
options = {:display_field_key => :another_name}
|
122
|
-
formatter.format(reference_str_keys, options).must_equal("#{reference_str_keys['another_name']}")
|
122
|
+
_(formatter.format(reference_str_keys, options)).must_equal("#{reference_str_keys['another_name']}")
|
123
123
|
end
|
124
124
|
|
125
125
|
it 'formats id when show_ids is true' do
|
126
|
-
options = {:details => {:label => 'Id', :key => :id, :id => 1}, :context => {:show_ids => true}}
|
127
|
-
formatter.format(reference_str_keys, options)
|
126
|
+
options = {:details => {:label => {:target => 'Id'}, :key => :id, :id => 1}, :context => {:show_ids => true}}
|
127
|
+
_(formatter.format(reference_str_keys, options))
|
128
128
|
.must_equal("Server (Id: #{reference_str_keys['id']})")
|
129
129
|
end
|
130
130
|
|
131
131
|
it 'does not formats id when show_ids is false' do
|
132
132
|
options = {:details => {:label => 'Id', :key => :id, :id => 1}, :context => {:show_ids => false}}
|
133
|
-
formatter.format(reference_str_keys, options)
|
133
|
+
_(formatter.format(reference_str_keys, options))
|
134
134
|
.must_equal("#{reference_str_keys['name']}")
|
135
135
|
end
|
136
136
|
|
137
137
|
it 'formats details' do
|
138
138
|
options = { :details => { :label => _('url'), :key => :url } }
|
139
|
-
formatter.format(reference_str_keys, options)
|
139
|
+
_(formatter.format(reference_str_keys, options))
|
140
140
|
.must_equal("Server (url: #{reference_str_keys['url']})")
|
141
141
|
end
|
142
142
|
|
143
143
|
it 'formats multiple details' do
|
144
144
|
options = { :details => [{ :label => _('url'), :key => :url },
|
145
145
|
{ :label => _('desc'), :key => :desc }] }
|
146
|
-
formatter.format(reference_str_keys, options)
|
146
|
+
_(formatter.format(reference_str_keys, options))
|
147
147
|
.must_equal("Server (url: #{reference_str_keys['url']}, desc: #{reference_str_keys['desc']})")
|
148
148
|
end
|
149
149
|
|
@@ -152,7 +152,7 @@ describe HammerCLIForeman::Output::Formatters::ReferenceFormatter do
|
|
152
152
|
:details => [{ :label => _('url'), :key => :url },
|
153
153
|
{ :label => _('desc'), :key => :desc },
|
154
154
|
{ :label => _('Id'), :key => :id }] }
|
155
|
-
formatter.format(reference_str_keys, options)
|
155
|
+
_(formatter.format(reference_str_keys, options))
|
156
156
|
.must_equal("Server (url: #{reference_str_keys['url']}, desc: #{reference_str_keys['desc']}, Id: #{reference_str_keys['id']})")
|
157
157
|
end
|
158
158
|
end
|
@@ -24,11 +24,11 @@ describe HammerCLIForeman::ParamsFlattener do
|
|
24
24
|
}
|
25
25
|
|
26
26
|
it "flatten params" do
|
27
|
-
flattener.filter([param1, param2, hash_param2]).must_equal [param1, param2, hash_param2, param1, hash_param, param1, param2]
|
27
|
+
_(flattener.filter([param1, param2, hash_param2])).must_equal [param1, param2, hash_param2, param1, hash_param, param1, param2]
|
28
28
|
end
|
29
29
|
|
30
30
|
it "returns empty array for no params" do
|
31
|
-
flattener.filter([]).must_equal []
|
31
|
+
_(flattener.filter([])).must_equal []
|
32
32
|
end
|
33
33
|
|
34
34
|
end
|
@@ -63,15 +63,15 @@ describe HammerCLIForeman::IdParamsFilter do
|
|
63
63
|
}
|
64
64
|
|
65
65
|
it "returns only required params ending with _id" do
|
66
|
-
required_filter.for_action(action).must_equal required_params
|
66
|
+
_(required_filter.for_action(action)).must_equal required_params
|
67
67
|
end
|
68
68
|
|
69
69
|
it "returns only ending with _id when :only_required is set to false" do
|
70
|
-
nonrequired_filter.for_action(action).must_equal (required_params+id_params)
|
70
|
+
_(nonrequired_filter.for_action(action)).must_equal (required_params+id_params)
|
71
71
|
end
|
72
72
|
|
73
73
|
it "returns required params by default" do
|
74
|
-
filter.for_action(action).must_equal required_params
|
74
|
+
_(filter.for_action(action)).must_equal required_params
|
75
75
|
end
|
76
76
|
|
77
77
|
context "with hash params" do
|
@@ -81,15 +81,15 @@ describe HammerCLIForeman::IdParamsFilter do
|
|
81
81
|
}
|
82
82
|
|
83
83
|
it "finds params inside a hash" do
|
84
|
-
filter.for_action(action).must_equal required_params
|
84
|
+
_(filter.for_action(action)).must_equal required_params
|
85
85
|
end
|
86
86
|
|
87
87
|
it "returns only required params ending with _id" do
|
88
|
-
required_filter.for_action(action).must_equal required_params
|
88
|
+
_(required_filter.for_action(action)).must_equal required_params
|
89
89
|
end
|
90
90
|
|
91
91
|
it "returns only ending with _id when :only_required is set to false" do
|
92
|
-
nonrequired_filter.for_action(action).must_equal (required_params+id_params)
|
92
|
+
_(nonrequired_filter.for_action(action)).must_equal (required_params+id_params)
|
93
93
|
end
|
94
94
|
|
95
95
|
end
|
@@ -128,15 +128,15 @@ describe HammerCLIForeman::IdArrayParamsFilter do
|
|
128
128
|
}
|
129
129
|
|
130
130
|
it "returns only required params ending with _ids" do
|
131
|
-
required_filter.for_action(action).must_equal required_params
|
131
|
+
_(required_filter.for_action(action)).must_equal required_params
|
132
132
|
end
|
133
133
|
|
134
134
|
it "returns only ending with _ids when :only_required is set to false" do
|
135
|
-
nonrequired_filter.for_action(action).must_equal (required_params+id_params)
|
135
|
+
_(nonrequired_filter.for_action(action)).must_equal (required_params+id_params)
|
136
136
|
end
|
137
137
|
|
138
138
|
it "returns required params by default" do
|
139
|
-
filter.for_action(action).must_equal required_params
|
139
|
+
_(filter.for_action(action)).must_equal required_params
|
140
140
|
end
|
141
141
|
|
142
142
|
context "with hash params" do
|
@@ -146,15 +146,15 @@ describe HammerCLIForeman::IdArrayParamsFilter do
|
|
146
146
|
}
|
147
147
|
|
148
148
|
it "finds params inside a hash" do
|
149
|
-
filter.for_action(action).must_equal required_params
|
149
|
+
_(filter.for_action(action)).must_equal required_params
|
150
150
|
end
|
151
151
|
|
152
152
|
it "returns only required params ending with _ids" do
|
153
|
-
required_filter.for_action(action).must_equal required_params
|
153
|
+
_(required_filter.for_action(action)).must_equal required_params
|
154
154
|
end
|
155
155
|
|
156
156
|
it "returns only ending with _ids when :only_required is set to false" do
|
157
|
-
nonrequired_filter.for_action(action).must_equal (required_params+id_params)
|
157
|
+
_(nonrequired_filter.for_action(action)).must_equal (required_params+id_params)
|
158
158
|
end
|
159
159
|
|
160
160
|
end
|
@@ -188,19 +188,19 @@ describe HammerCLIForeman::ParamsNameFilter do
|
|
188
188
|
it "finds parameter by name" do
|
189
189
|
action = stub(:params => ([the_param]+other_params))
|
190
190
|
filter = HammerCLIForeman::ParamsNameFilter.new("xxx")
|
191
|
-
filter.for_action(action).must_equal [the_param]
|
191
|
+
_(filter.for_action(action)).must_equal [the_param]
|
192
192
|
end
|
193
193
|
|
194
194
|
it "finds parameter by name nested in another hash parameter" do
|
195
195
|
action = stub(:params => ([hash_param]+other_params))
|
196
196
|
filter = HammerCLIForeman::ParamsNameFilter.new("xxx")
|
197
|
-
filter.for_action(action).must_equal [the_param]
|
197
|
+
_(filter.for_action(action)).must_equal [the_param]
|
198
198
|
end
|
199
199
|
|
200
200
|
it "returns empty array when the parameter is not found" do
|
201
201
|
action = stub(:params => ([the_param]+other_params))
|
202
202
|
filter = HammerCLIForeman::ParamsNameFilter.new("???")
|
203
|
-
filter.for_action(action).must_equal []
|
203
|
+
_(filter.for_action(action)).must_equal []
|
204
204
|
end
|
205
205
|
|
206
206
|
end
|
data/test/unit/sessions_test.rb
CHANGED
@@ -12,8 +12,8 @@ describe HammerCLIForeman do
|
|
12
12
|
Dir.mktmpdir do |dir|
|
13
13
|
HammerCLIForeman::Sessions.stubs(:storage).returns(dir)
|
14
14
|
session = HammerCLIForeman::Sessions.get('http://example.com')
|
15
|
-
session.id.must_be_nil
|
16
|
-
session.user_name.must_be_nil
|
15
|
+
_(session.id).must_be_nil
|
16
|
+
_(session.user_name).must_be_nil
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -32,8 +32,8 @@ describe HammerCLIForeman do
|
|
32
32
|
File.chmod(0600, session_path)
|
33
33
|
|
34
34
|
session = HammerCLIForeman::Sessions.get('http://example.com')
|
35
|
-
session.id.must_equal '3040b0f04c3a35a499e6837278904d48'
|
36
|
-
session.user_name.must_equal 'admin'
|
35
|
+
_(session.id).must_equal '3040b0f04c3a35a499e6837278904d48'
|
36
|
+
_(session.user_name).must_equal 'admin'
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -43,7 +43,7 @@ describe HammerCLIForeman do
|
|
43
43
|
HammerCLIForeman::Sessions.stubs(:storage).returns(dir)
|
44
44
|
FileUtils.rm_rf(dir)
|
45
45
|
HammerCLIForeman::Sessions.get('http://example.com')
|
46
|
-
File.exist?(dir).must_equal true
|
46
|
+
_(File.exist?(dir)).must_equal true
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -53,7 +53,7 @@ describe HammerCLIForeman do
|
|
53
53
|
HammerCLIForeman::Sessions.stubs(:storage).returns(dir)
|
54
54
|
FileUtils.chmod(0777, dir)
|
55
55
|
_, err = capture_io { HammerCLIForeman::Sessions.get('http://example.com') }
|
56
|
-
err.must_equal("Invalid permissions for #{dir}: 40777, expected 40700.\n" \
|
56
|
+
_(err).must_equal("Invalid permissions for #{dir}: 40777, expected 40700.\n" \
|
57
57
|
"Using session auth with invalid permissions on session files is not recommended.\n")
|
58
58
|
end
|
59
59
|
end
|
@@ -73,44 +73,44 @@ describe HammerCLIForeman do
|
|
73
73
|
File.chmod(0666, session_path)
|
74
74
|
|
75
75
|
_, err = capture_io { HammerCLIForeman::Sessions.get('http://example.com') }
|
76
|
-
err.must_equal("Invalid permissions for #{session_path}: 100666, expected 100600.\n" \
|
76
|
+
_(err).must_equal("Invalid permissions for #{session_path}: 100666, expected 100600.\n" \
|
77
77
|
"Using session auth with invalid permissions on session files is not recommended.\n")
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
81
|
it 'should fail if sessions are not enabled' do
|
82
82
|
HammerCLI::Settings.expects(:get).with(:foreman, :use_sessions).returns(false)
|
83
|
-
e = proc { HammerCLIForeman::Sessions.get('http://example.com')}.must_raise RuntimeError
|
84
|
-
e.message.must_equal "Sessions are not enabled, please check your Hammer settings."
|
83
|
+
e = _(proc { HammerCLIForeman::Sessions.get('http://example.com')}).must_raise RuntimeError
|
84
|
+
_(e.message).must_equal "Sessions are not enabled, please check your Hammer settings."
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
88
|
describe "#enabled?" do
|
89
89
|
it 'tests sessions are enabled' do
|
90
90
|
HammerCLI::Settings.expects(:get).with(:foreman, :use_sessions).returns(true)
|
91
|
-
HammerCLIForeman::Sessions.enabled
|
91
|
+
_(HammerCLIForeman::Sessions.enabled?).must_equal true
|
92
92
|
end
|
93
93
|
|
94
94
|
it 'tests sessions are disabled' do
|
95
95
|
HammerCLI::Settings.expects(:get).with(:foreman, :use_sessions).returns(false)
|
96
|
-
HammerCLIForeman::Sessions.enabled
|
96
|
+
_(HammerCLIForeman::Sessions.enabled?).must_equal false
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
100
|
describe "#session_file" do
|
101
101
|
it 'should return file path for session' do
|
102
102
|
file_path = HammerCLIForeman::Sessions.session_file('http://example.com')
|
103
|
-
file_path.must_equal(File.join(HammerCLIForeman::Sessions.storage, 'http_example.com'))
|
103
|
+
_(file_path).must_equal(File.join(HammerCLIForeman::Sessions.storage, 'http_example.com'))
|
104
104
|
end
|
105
105
|
|
106
106
|
it 'should handle invalid url' do
|
107
|
-
e = proc { HammerCLIForeman::Sessions.session_file('/\/')}.must_raise RuntimeError
|
108
|
-
e.message.must_equal "The url (/\\/) is not a valid URL. Session can not be created."
|
107
|
+
e = _(proc { HammerCLIForeman::Sessions.session_file('/\/')}).must_raise RuntimeError
|
108
|
+
_(e.message).must_equal "The url (/\\/) is not a valid URL. Session can not be created."
|
109
109
|
end
|
110
110
|
|
111
111
|
it 'should handle empty url' do
|
112
|
-
e = proc { HammerCLIForeman::Sessions.session_file('')}.must_raise RuntimeError
|
113
|
-
e.message.must_equal "The url is empty. Session can not be created."
|
112
|
+
e = _(proc { HammerCLIForeman::Sessions.session_file('')}).must_raise RuntimeError
|
113
|
+
_(e.message).must_equal "The url is empty. Session can not be created."
|
114
114
|
end
|
115
115
|
end
|
116
116
|
end
|
@@ -124,8 +124,8 @@ describe HammerCLIForeman do
|
|
124
124
|
session.store
|
125
125
|
|
126
126
|
session = HammerCLIForeman::Session.new(f.path)
|
127
|
-
session.id.must_equal '3040b0f04c3a35a499e6837278904d48'
|
128
|
-
session.user_name.must_equal 'admin'
|
127
|
+
_(session.id).must_equal '3040b0f04c3a35a499e6837278904d48'
|
128
|
+
_(session.user_name).must_equal 'admin'
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
@@ -133,7 +133,7 @@ describe HammerCLIForeman do
|
|
133
133
|
Tempfile.create('session') do |f|
|
134
134
|
session = HammerCLIForeman::Session.new(f.path)
|
135
135
|
session.store
|
136
|
-
File.stat(f.path).mode.to_s(8).must_equal '100600'
|
136
|
+
_(File.stat(f.path).mode.to_s(8)).must_equal '100600'
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
@@ -146,7 +146,7 @@ describe HammerCLIForeman do
|
|
146
146
|
session.id = nil
|
147
147
|
session.user_name = nil
|
148
148
|
end
|
149
|
-
err.must_equal("Invalid session data. Resetting the session.\n")
|
149
|
+
_(err).must_equal("Invalid session data. Resetting the session.\n")
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
@@ -159,8 +159,8 @@ describe HammerCLIForeman do
|
|
159
159
|
session.destroy
|
160
160
|
|
161
161
|
session = HammerCLIForeman::Session.new(f.path)
|
162
|
-
session.id.must_be_nil
|
163
|
-
session.user_name.must_equal 'admin'
|
162
|
+
_(session.id).must_be_nil
|
163
|
+
_(session.user_name).must_equal 'admin'
|
164
164
|
end
|
165
165
|
end
|
166
166
|
end
|
@@ -171,7 +171,7 @@ describe HammerCLIForeman do
|
|
171
171
|
session = HammerCLIForeman::Session.new(f.path)
|
172
172
|
session.id = nil
|
173
173
|
session.user_name = 'admin'
|
174
|
-
session.valid
|
174
|
+
_(session.valid?).must_equal false
|
175
175
|
end
|
176
176
|
end
|
177
177
|
|
@@ -180,7 +180,7 @@ describe HammerCLIForeman do
|
|
180
180
|
session = HammerCLIForeman::Session.new(f.path)
|
181
181
|
session.id = '34252624635723572357234'
|
182
182
|
session.user_name = 'admin'
|
183
|
-
session.valid
|
183
|
+
_(session.valid?).must_equal true
|
184
184
|
end
|
185
185
|
end
|
186
186
|
end
|
data/test/unit/template_test.rb
CHANGED
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.
|
4
|
+
version: 2.2.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-
|
12
|
+
date: 2020-08-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hammer_cli
|
@@ -75,20 +75,20 @@ dependencies:
|
|
75
75
|
version: 2.2.1
|
76
76
|
description: 'Foreman commands for Hammer CLI
|
77
77
|
|
78
|
-
'
|
78
|
+
'
|
79
79
|
email: tstracho@redhat.com
|
80
80
|
executables: []
|
81
81
|
extensions: []
|
82
82
|
extra_rdoc_files:
|
83
|
-
- doc/configuration.md
|
84
|
-
- doc/developer_docs.md
|
85
83
|
- doc/host_create.md
|
86
|
-
- doc/
|
87
|
-
- doc/option_builder.md
|
84
|
+
- doc/release_notes.md
|
88
85
|
- doc/plugin.md
|
86
|
+
- doc/configuration.md
|
87
|
+
- doc/name_id_resolution.md
|
88
|
+
- doc/developer_docs.md
|
89
89
|
- doc/using_hammer_cli_foreman_command.md
|
90
90
|
- doc/testing.md
|
91
|
-
- doc/
|
91
|
+
- doc/option_builder.md
|
92
92
|
- README.md
|
93
93
|
files:
|
94
94
|
- LICENSE
|
@@ -217,6 +217,8 @@ files:
|
|
217
217
|
- lib/hammer_cli_foreman/usergroup.rb
|
218
218
|
- lib/hammer_cli_foreman/version.rb
|
219
219
|
- lib/hammer_cli_foreman/virtual_machine.rb
|
220
|
+
- lib/minitest/coverage_reporter.rb
|
221
|
+
- lib/minitest/hammer_coverage_plugin.rb
|
220
222
|
- locale/ca/LC_MESSAGES/hammer-cli-foreman.mo
|
221
223
|
- locale/de/LC_MESSAGES/hammer-cli-foreman.mo
|
222
224
|
- locale/en/LC_MESSAGES/hammer-cli-foreman.mo
|
@@ -264,6 +266,7 @@ files:
|
|
264
266
|
- test/functional/personal_access_token_test.rb
|
265
267
|
- test/functional/ping_test.rb
|
266
268
|
- test/functional/proxy_test.rb
|
269
|
+
- test/functional/realm_test.rb
|
267
270
|
- test/functional/report_template_test.rb
|
268
271
|
- test/functional/role_test.rb
|
269
272
|
- test/functional/settings_test.rb
|
@@ -278,6 +281,7 @@ files:
|
|
278
281
|
- test/functional/user_mail_notification_test.rb
|
279
282
|
- test/functional/user_test.rb
|
280
283
|
- test/functional/virtual_machine_test.rb
|
284
|
+
- test/reports/TEST-Minitest-Result.xml
|
281
285
|
- test/test_helper.rb
|
282
286
|
- test/unit/api/interactive_basic_auth_test.rb
|
283
287
|
- test/unit/api/oauth/oauth_authentication_code_grant_test.rb
|
@@ -355,114 +359,116 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
355
359
|
- !ruby/object:Gem::Version
|
356
360
|
version: '0'
|
357
361
|
requirements: []
|
358
|
-
rubygems_version: 3.
|
362
|
+
rubygems_version: 3.0.8
|
359
363
|
signing_key:
|
360
364
|
specification_version: 4
|
361
365
|
summary: Foreman commands for Hammer
|
362
366
|
test_files:
|
363
|
-
- test/
|
367
|
+
- test/unit/image_test.rb
|
368
|
+
- test/unit/helpers/resource_disabled.rb
|
369
|
+
- test/unit/helpers/fake_searchables.rb
|
370
|
+
- test/unit/helpers/command.rb
|
371
|
+
- test/unit/messages_test.rb
|
372
|
+
- test/unit/config_group_test.rb
|
373
|
+
- test/unit/option_sources/id_params_test.rb
|
374
|
+
- test/unit/option_sources/ids_params_test.rb
|
375
|
+
- test/unit/exception_handler_test.rb
|
376
|
+
- test/unit/user_test.rb
|
377
|
+
- test/unit/api/session_authenticator_wrapper_test.rb
|
378
|
+
- test/unit/api/interactive_basic_auth_test.rb
|
379
|
+
- test/unit/api/oauth/oauth_authentication_code_grant_test.rb
|
380
|
+
- test/unit/api/oauth/oauth_password_grant_test.rb
|
381
|
+
- test/unit/api/void_auth_test.rb
|
382
|
+
- test/unit/hostgroup_test.rb
|
383
|
+
- test/unit/realm_test.rb
|
384
|
+
- test/unit/auth_source_external.rb
|
385
|
+
- test/unit/data/test_api.json
|
386
|
+
- test/unit/auth_source_ldap_test.rb
|
387
|
+
- test/unit/audit_test.rb
|
388
|
+
- test/unit/test_helper.rb
|
389
|
+
- test/unit/smart_class_parameter_test.rb
|
390
|
+
- test/unit/partition_table_test.rb
|
391
|
+
- test/unit/operating_system_test.rb
|
392
|
+
- test/unit/media_test.rb
|
393
|
+
- test/unit/architecture_test.rb
|
394
|
+
- test/unit/usergroup_test.rb
|
395
|
+
- test/unit/role_test.rb
|
396
|
+
- test/unit/location_test.rb
|
397
|
+
- test/unit/param_filters_test.rb
|
398
|
+
- test/unit/apipie_resource_mock.rb
|
399
|
+
- test/unit/option_builders_test.rb
|
400
|
+
- test/unit/api_test.rb
|
401
|
+
- test/unit/test_output_adapter.rb
|
402
|
+
- test/unit/sessions_test.rb
|
403
|
+
- test/unit/organization_test.rb
|
404
|
+
- test/unit/settings_test.rb
|
405
|
+
- test/unit/template_test.rb
|
406
|
+
- test/unit/dependency_resolver_test.rb
|
407
|
+
- test/unit/smart_proxy_test.rb
|
408
|
+
- test/unit/domain_test.rb
|
409
|
+
- test/unit/defaults_test.rb
|
410
|
+
- test/unit/model_test.rb
|
411
|
+
- test/unit/puppet_class_test.rb
|
412
|
+
- test/unit/compute_resource_test.rb
|
413
|
+
- test/unit/id_resolver_test.rb
|
414
|
+
- test/unit/filter_test.rb
|
415
|
+
- test/unit/puppet_environment_test.rb
|
416
|
+
- test/unit/output/formatters_test.rb
|
417
|
+
- test/unit/host_test.rb
|
418
|
+
- test/unit/config_report_test.rb
|
419
|
+
- test/unit/fact_test.rb
|
420
|
+
- test/unit/external_usergroup_test.rb
|
421
|
+
- test/unit/commands_test.rb
|
422
|
+
- test/unit/common_parameter_test.rb
|
423
|
+
- test/unit/subnet_test.rb
|
424
|
+
- test/data/2.1/foreman_api.json
|
425
|
+
- test/data/2.0/foreman_api.json
|
426
|
+
- test/data/1.24/foreman_api.json
|
427
|
+
- test/data/1.18/foreman_api.json
|
364
428
|
- test/data/1.11/foreman_api.json
|
429
|
+
- test/data/1.10/foreman_api.json
|
430
|
+
- test/data/1.17/foreman_api.json
|
431
|
+
- test/data/1.15/foreman_api.json
|
365
432
|
- test/data/1.14/_foreman_api.json
|
366
433
|
- test/data/1.14/foreman_api.json
|
367
|
-
- test/data/1.15/foreman_api.json
|
368
|
-
- test/data/1.16/foreman_api.json
|
369
|
-
- test/data/1.17/foreman_api.json
|
370
|
-
- test/data/1.18/foreman_api.json
|
371
|
-
- test/data/1.20/foreman_api.json
|
372
434
|
- test/data/1.21/foreman_api.json
|
373
435
|
- test/data/1.22/foreman_api.json
|
374
|
-
- test/data/1.
|
375
|
-
- test/data/2.0/foreman_api.json
|
376
|
-
- test/data/2.1/foreman_api.json
|
436
|
+
- test/data/1.20/foreman_api.json
|
377
437
|
- test/data/README.md
|
378
|
-
- test/
|
379
|
-
- test/functional/
|
380
|
-
- test/functional/bookmark_test.rb
|
438
|
+
- test/data/1.16/foreman_api.json
|
439
|
+
- test/functional/http_proxy_test.rb
|
381
440
|
- test/functional/commands/list_test.rb
|
382
|
-
- test/functional/
|
383
|
-
- test/functional/
|
384
|
-
- test/functional/
|
385
|
-
- test/functional/
|
441
|
+
- test/functional/user_mail_notification_test.rb
|
442
|
+
- test/functional/user_test.rb
|
443
|
+
- test/functional/realm_test.rb
|
444
|
+
- test/functional/personal_access_token_test.rb
|
445
|
+
- test/functional/audit_test.rb
|
446
|
+
- test/functional/test_helper.rb
|
447
|
+
- test/functional/mail_notification_test.rb
|
448
|
+
- test/functional/ping_test.rb
|
449
|
+
- test/functional/smart_class_parameter_test.rb
|
450
|
+
- test/functional/role_test.rb
|
451
|
+
- test/functional/location_test.rb
|
386
452
|
- test/functional/hostgroup/create_test.rb
|
387
453
|
- test/functional/hostgroup/update_test.rb
|
388
|
-
- test/functional/
|
389
|
-
- test/functional/
|
454
|
+
- test/functional/subnet/create_test.rb
|
455
|
+
- test/functional/subnet/update_test.rb
|
390
456
|
- test/functional/organization_test.rb
|
391
|
-
- test/functional/
|
392
|
-
- test/functional/
|
457
|
+
- test/functional/settings_test.rb
|
458
|
+
- test/functional/template_test.rb
|
393
459
|
- test/functional/proxy_test.rb
|
460
|
+
- test/functional/compute_resource_test.rb
|
461
|
+
- test/functional/compute_attribute_test.rb
|
462
|
+
- test/functional/filter_test.rb
|
463
|
+
- test/functional/trend_test.rb
|
394
464
|
- test/functional/report_template_test.rb
|
395
|
-
- test/functional/
|
396
|
-
- test/functional/
|
397
|
-
- test/functional/smart_class_parameter_test.rb
|
465
|
+
- test/functional/compute_profile_test.rb
|
466
|
+
- test/functional/host_test.rb
|
398
467
|
- test/functional/ssh_keys_test.rb
|
399
468
|
- test/functional/status_test.rb
|
400
|
-
- test/functional/
|
401
|
-
- test/functional/
|
402
|
-
- test/functional/template_test.rb
|
403
|
-
- test/functional/test_helper.rb
|
469
|
+
- test/functional/associating_commands_test.rb
|
470
|
+
- test/functional/auth_source_test.rb
|
404
471
|
- test/functional/virtual_machine_test.rb
|
405
|
-
- test/functional/
|
406
|
-
- test/functional/http_proxy_test.rb
|
407
|
-
- test/functional/audit_test.rb
|
408
|
-
- test/functional/host_test.rb
|
409
|
-
- test/functional/trend_test.rb
|
410
|
-
- test/functional/user_test.rb
|
411
|
-
- test/unit/api/oauth/oauth_authentication_code_grant_test.rb
|
412
|
-
- test/unit/api/oauth/oauth_password_grant_test.rb
|
413
|
-
- test/unit/api/session_authenticator_wrapper_test.rb
|
414
|
-
- test/unit/api/void_auth_test.rb
|
415
|
-
- test/unit/api/interactive_basic_auth_test.rb
|
416
|
-
- test/unit/architecture_test.rb
|
417
|
-
- test/unit/auth_source_external.rb
|
418
|
-
- test/unit/auth_source_ldap_test.rb
|
419
|
-
- test/unit/compute_resource_test.rb
|
420
|
-
- test/unit/config_group_test.rb
|
421
|
-
- test/unit/config_report_test.rb
|
422
|
-
- test/unit/data/test_api.json
|
423
|
-
- test/unit/defaults_test.rb
|
424
|
-
- test/unit/domain_test.rb
|
425
|
-
- test/unit/external_usergroup_test.rb
|
426
|
-
- test/unit/fact_test.rb
|
427
|
-
- test/unit/filter_test.rb
|
428
|
-
- test/unit/helpers/fake_searchables.rb
|
429
|
-
- test/unit/helpers/command.rb
|
430
|
-
- test/unit/helpers/resource_disabled.rb
|
431
|
-
- test/unit/hostgroup_test.rb
|
432
|
-
- test/unit/image_test.rb
|
433
|
-
- test/unit/location_test.rb
|
434
|
-
- test/unit/media_test.rb
|
435
|
-
- test/unit/messages_test.rb
|
436
|
-
- test/unit/model_test.rb
|
437
|
-
- test/unit/operating_system_test.rb
|
438
|
-
- test/unit/option_sources/id_params_test.rb
|
439
|
-
- test/unit/option_sources/ids_params_test.rb
|
440
|
-
- test/unit/organization_test.rb
|
441
|
-
- test/unit/output/formatters_test.rb
|
442
|
-
- test/unit/partition_table_test.rb
|
443
|
-
- test/unit/puppet_class_test.rb
|
444
|
-
- test/unit/puppet_environment_test.rb
|
445
|
-
- test/unit/realm_test.rb
|
446
|
-
- test/unit/role_test.rb
|
447
|
-
- test/unit/settings_test.rb
|
448
|
-
- test/unit/smart_class_parameter_test.rb
|
449
|
-
- test/unit/smart_proxy_test.rb
|
450
|
-
- test/unit/subnet_test.rb
|
451
|
-
- test/unit/test_helper.rb
|
452
|
-
- test/unit/test_output_adapter.rb
|
453
|
-
- test/unit/user_test.rb
|
454
|
-
- test/unit/usergroup_test.rb
|
455
|
-
- test/unit/apipie_resource_mock.rb
|
456
|
-
- test/unit/dependency_resolver_test.rb
|
457
|
-
- test/unit/option_builders_test.rb
|
458
|
-
- test/unit/host_test.rb
|
459
|
-
- test/unit/commands_test.rb
|
460
|
-
- test/unit/common_parameter_test.rb
|
461
|
-
- test/unit/exception_handler_test.rb
|
462
|
-
- test/unit/id_resolver_test.rb
|
463
|
-
- test/unit/param_filters_test.rb
|
464
|
-
- test/unit/sessions_test.rb
|
465
|
-
- test/unit/template_test.rb
|
466
|
-
- test/unit/audit_test.rb
|
467
|
-
- test/unit/api_test.rb
|
472
|
+
- test/functional/bookmark_test.rb
|
468
473
|
- test/test_helper.rb
|
474
|
+
- test/reports/TEST-Minitest-Result.xml
|