hammer_cli_foreman 2.1.1 → 2.3.1
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 +31 -1
- data/doc/testing.md +13 -0
- data/lib/hammer_cli_foreman.rb +1 -5
- data/lib/hammer_cli_foreman/associating_commands.rb +4 -5
- data/lib/hammer_cli_foreman/audit.rb +7 -0
- 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/host.rb +3 -2
- data/lib/hammer_cli_foreman/hosts/common_update_options.rb +16 -9
- data/lib/hammer_cli_foreman/id_resolver.rb +2 -2
- data/lib/hammer_cli_foreman/location.rb +2 -0
- data/lib/hammer_cli_foreman/option_builders.rb +1 -1
- data/lib/hammer_cli_foreman/organization.rb +2 -0
- 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/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/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/audit_test.rb +86 -63
- data/test/functional/commands/list_test.rb +11 -11
- data/test/functional/compute_profile_test.rb +4 -2
- data/test/functional/host_test.rb +43 -18
- 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 +103 -0
- 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/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/audit_test.rb +1 -0
- 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 +1 -24
- data/test/unit/id_resolver_test.rb +23 -23
- data/test/unit/media_test.rb +1 -1
- 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/partition_table_test.rb +2 -2
- data/test/unit/role_test.rb +2 -2
- data/test/unit/sessions_test.rb +24 -24
- data/test/unit/template_test.rb +1 -1
- metadata +108 -103
- data/lib/hammer_cli_foreman/trend.rb +0 -47
- data/test/functional/trend_test.rb +0 -22
@@ -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
|
@@ -119,8 +119,8 @@ describe HammerCLIForeman::PartitionTable do
|
|
119
119
|
# TODO: temporarily disabled, parameters are checked in the id resolver
|
120
120
|
end
|
121
121
|
|
122
|
-
with_params [
|
123
|
-
it_should_call_action :update, {'id' => '83', '
|
122
|
+
with_params ['--id=83', '--new-name=ptable', '--file=~/table.sh', '--os-family=RedHat'] do
|
123
|
+
it_should_call_action :update, { 'id' => '83', 'ptable' => { 'name' => 'ptable', 'layout' => 'FILE_CONTENT', 'os_family' => 'RedHat' } }
|
124
124
|
end
|
125
125
|
|
126
126
|
end
|
data/test/unit/role_test.rb
CHANGED
@@ -77,8 +77,8 @@ describe HammerCLIForeman::Role do
|
|
77
77
|
it_should_accept "name and new name", ["--name=role", "--new-name=role2"]
|
78
78
|
end
|
79
79
|
|
80
|
-
with_params [
|
81
|
-
it_should_call_action :update, {'id' => '1', '
|
80
|
+
with_params ['--id=1', '--new-name=role2'] do
|
81
|
+
it_should_call_action :update, { 'id' => '1', 'role' => { 'name' => 'role2' } }
|
82
82
|
end
|
83
83
|
|
84
84
|
end
|
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
|