hammer_cli_foreman 2.1.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes.md +33 -0
  3. data/doc/testing.md +13 -0
  4. data/lib/hammer_cli_foreman.rb +1 -5
  5. data/lib/hammer_cli_foreman/api/connection.rb +1 -18
  6. data/lib/hammer_cli_foreman/api/session_authenticator_wrapper.rb +0 -1
  7. data/lib/hammer_cli_foreman/associating_commands.rb +4 -5
  8. data/lib/hammer_cli_foreman/audit.rb +7 -0
  9. data/lib/hammer_cli_foreman/auth.rb +4 -4
  10. data/lib/hammer_cli_foreman/command_extensions/ping.rb +10 -1
  11. data/lib/hammer_cli_foreman/commands.rb +3 -1
  12. data/lib/hammer_cli_foreman/compute_resource/ovirt.rb +1 -0
  13. data/lib/hammer_cli_foreman/hosts/common_update_options.rb +16 -9
  14. data/lib/hammer_cli_foreman/id_resolver.rb +2 -2
  15. data/lib/hammer_cli_foreman/location.rb +2 -0
  16. data/lib/hammer_cli_foreman/option_builders.rb +1 -1
  17. data/lib/hammer_cli_foreman/organization.rb +2 -0
  18. data/lib/hammer_cli_foreman/output/fields.rb +1 -1
  19. data/lib/hammer_cli_foreman/output/formatters.rb +1 -1
  20. data/lib/hammer_cli_foreman/ping.rb +20 -11
  21. data/lib/hammer_cli_foreman/references.rb +16 -0
  22. data/lib/hammer_cli_foreman/sessions.rb +1 -3
  23. data/lib/hammer_cli_foreman/settings.rb +14 -0
  24. data/lib/hammer_cli_foreman/testing/api_expectations.rb +10 -0
  25. data/lib/hammer_cli_foreman/user.rb +4 -0
  26. data/lib/hammer_cli_foreman/user_mail_notification.rb +51 -0
  27. data/lib/hammer_cli_foreman/version.rb +1 -1
  28. data/lib/minitest/coverage_reporter.rb +94 -0
  29. data/lib/minitest/hammer_coverage_plugin.rb +19 -0
  30. data/locale/ca/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  31. data/locale/de/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  32. data/locale/en/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  33. data/locale/en_GB/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  34. data/locale/es/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  35. data/locale/fr/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  36. data/locale/it/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  37. data/locale/ja/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  38. data/locale/ko/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  39. data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  40. data/locale/ru/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  41. data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  42. data/locale/zh_TW/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  43. data/test/data/2.1/foreman_api.json +1 -1
  44. data/test/functional/audit_test.rb +86 -63
  45. data/test/functional/commands/list_test.rb +11 -11
  46. data/test/functional/compute_profile_test.rb +4 -2
  47. data/test/functional/host_test.rb +29 -18
  48. data/test/functional/http_proxy_test.rb +1 -4
  49. data/test/functional/location_test.rb +134 -0
  50. data/test/functional/media_test.rb +130 -0
  51. data/test/functional/organization_test.rb +52 -0
  52. data/test/functional/realm_test.rb +103 -0
  53. data/test/functional/role_test.rb +9 -12
  54. data/test/functional/settings_test.rb +57 -1
  55. data/test/functional/user_mail_notification_test.rb +89 -0
  56. data/test/functional/user_test.rb +39 -0
  57. data/test/reports/TEST-Minitest-Result.xml +4344 -0
  58. data/test/test_helper.rb +5 -2
  59. data/test/unit/api/interactive_basic_auth_test.rb +3 -1
  60. data/test/unit/api/oauth/oauth_authentication_code_grant_test.rb +2 -2
  61. data/test/unit/api/oauth/oauth_password_grant_test.rb +2 -2
  62. data/test/unit/api_test.rb +3 -4
  63. data/test/unit/apipie_resource_mock.rb +4 -4
  64. data/test/unit/audit_test.rb +1 -0
  65. data/test/unit/commands_test.rb +19 -19
  66. data/test/unit/common_parameter_test.rb +1 -1
  67. data/test/unit/dependency_resolver_test.rb +4 -4
  68. data/test/unit/exception_handler_test.rb +13 -13
  69. data/test/unit/helpers/command.rb +5 -5
  70. data/test/unit/helpers/resource_disabled.rb +2 -2
  71. data/test/unit/host_test.rb +2 -2
  72. data/test/unit/id_resolver_test.rb +23 -23
  73. data/test/unit/media_test.rb +1 -1
  74. data/test/unit/option_builders_test.rb +49 -49
  75. data/test/unit/option_sources/id_params_test.rb +2 -2
  76. data/test/unit/option_sources/ids_params_test.rb +2 -2
  77. data/test/unit/output/formatters_test.rb +21 -21
  78. data/test/unit/param_filters_test.rb +17 -17
  79. data/test/unit/partition_table_test.rb +2 -2
  80. data/test/unit/role_test.rb +2 -2
  81. data/test/unit/sessions_test.rb +26 -37
  82. data/test/unit/template_test.rb +1 -1
  83. metadata +15 -7
  84. data/lib/hammer_cli_foreman/trend.rb +0 -47
  85. 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 => [{ :label => _('url'), :key => :url },
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 ["--id=83", "--new-name=ptable","--file=~/table.sh", "--os-family=RedHat"] do
123
- it_should_call_action :update, {'id' => '83', 'name' => 'ptable', 'ptable' => {'name' => 'ptable', 'layout' => 'FILE_CONTENT', 'os_family' => 'RedHat'}}
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
@@ -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 ["--id=1", "--new-name=role2"] do
81
- it_should_call_action :update, {'id' => '1', 'name' => 'role2', 'role' => {'name' => 'role2'}}
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
@@ -12,9 +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.auth_type.must_be_nil
17
- session.user_name.must_be_nil
15
+ _(session.id).must_be_nil
16
+ _(session.user_name).must_be_nil
18
17
  end
19
18
  end
20
19
 
@@ -24,8 +23,7 @@ describe HammerCLIForeman do
24
23
  HammerCLIForeman::Sessions.stubs(:storage).returns(dir)
25
24
  session_content = {
26
25
  :id => '3040b0f04c3a35a499e6837278904d48',
27
- :user_name => 'admin',
28
- :auth_type => 'basic_auth'
26
+ :user_name => 'admin'
29
27
  }
30
28
  session_path = "#{dir}/http_example.com"
31
29
  File.open(session_path,"w") do |f|
@@ -34,9 +32,8 @@ describe HammerCLIForeman do
34
32
  File.chmod(0600, session_path)
35
33
 
36
34
  session = HammerCLIForeman::Sessions.get('http://example.com')
37
- session.id.must_equal '3040b0f04c3a35a499e6837278904d48'
38
- session.auth_type.must_equal 'basic_auth'
39
- session.user_name.must_equal 'admin'
35
+ _(session.id).must_equal '3040b0f04c3a35a499e6837278904d48'
36
+ _(session.user_name).must_equal 'admin'
40
37
  end
41
38
  end
42
39
 
@@ -46,7 +43,7 @@ describe HammerCLIForeman do
46
43
  HammerCLIForeman::Sessions.stubs(:storage).returns(dir)
47
44
  FileUtils.rm_rf(dir)
48
45
  HammerCLIForeman::Sessions.get('http://example.com')
49
- File.exist?(dir).must_equal true
46
+ _(File.exist?(dir)).must_equal true
50
47
  end
51
48
  end
52
49
 
@@ -56,7 +53,7 @@ describe HammerCLIForeman do
56
53
  HammerCLIForeman::Sessions.stubs(:storage).returns(dir)
57
54
  FileUtils.chmod(0777, dir)
58
55
  _, err = capture_io { HammerCLIForeman::Sessions.get('http://example.com') }
59
- err.must_equal("Invalid permissions for #{dir}: 40777, expected 40700.\n" \
56
+ _(err).must_equal("Invalid permissions for #{dir}: 40777, expected 40700.\n" \
60
57
  "Using session auth with invalid permissions on session files is not recommended.\n")
61
58
  end
62
59
  end
@@ -67,8 +64,7 @@ describe HammerCLIForeman do
67
64
  HammerCLIForeman::Sessions.stubs(:storage).returns(dir)
68
65
  session_content = {
69
66
  :id => '3040b0f04c3a35a499e6837278904d48',
70
- :user_name => 'admin',
71
- :auth_type => 'basic_auth'
67
+ :user_name => 'admin'
72
68
  }
73
69
  session_path = "#{dir}/http_example.com"
74
70
  File.open(session_path,"w") do |f|
@@ -77,44 +73,44 @@ describe HammerCLIForeman do
77
73
  File.chmod(0666, session_path)
78
74
 
79
75
  _, err = capture_io { HammerCLIForeman::Sessions.get('http://example.com') }
80
- 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" \
81
77
  "Using session auth with invalid permissions on session files is not recommended.\n")
82
78
  end
83
79
  end
84
80
 
85
81
  it 'should fail if sessions are not enabled' do
86
82
  HammerCLI::Settings.expects(:get).with(:foreman, :use_sessions).returns(false)
87
- e = proc { HammerCLIForeman::Sessions.get('http://example.com')}.must_raise RuntimeError
88
- 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."
89
85
  end
90
86
  end
91
87
 
92
88
  describe "#enabled?" do
93
89
  it 'tests sessions are enabled' do
94
90
  HammerCLI::Settings.expects(:get).with(:foreman, :use_sessions).returns(true)
95
- HammerCLIForeman::Sessions.enabled?.must_equal true
91
+ _(HammerCLIForeman::Sessions.enabled?).must_equal true
96
92
  end
97
93
 
98
94
  it 'tests sessions are disabled' do
99
95
  HammerCLI::Settings.expects(:get).with(:foreman, :use_sessions).returns(false)
100
- HammerCLIForeman::Sessions.enabled?.must_equal false
96
+ _(HammerCLIForeman::Sessions.enabled?).must_equal false
101
97
  end
102
98
  end
103
99
 
104
100
  describe "#session_file" do
105
101
  it 'should return file path for session' do
106
102
  file_path = HammerCLIForeman::Sessions.session_file('http://example.com')
107
- 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'))
108
104
  end
109
105
 
110
106
  it 'should handle invalid url' do
111
- e = proc { HammerCLIForeman::Sessions.session_file('/\/')}.must_raise RuntimeError
112
- 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."
113
109
  end
114
110
 
115
111
  it 'should handle empty url' do
116
- e = proc { HammerCLIForeman::Sessions.session_file('')}.must_raise RuntimeError
117
- 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."
118
114
  end
119
115
  end
120
116
  end
@@ -124,14 +120,12 @@ describe HammerCLIForeman do
124
120
  Tempfile.create('session') do |f|
125
121
  session = HammerCLIForeman::Session.new(f.path)
126
122
  session.id = '3040b0f04c3a35a499e6837278904d48'
127
- session.auth_type = 'basic_auth'
128
123
  session.user_name = 'admin'
129
124
  session.store
130
125
 
131
126
  session = HammerCLIForeman::Session.new(f.path)
132
- session.id.must_equal '3040b0f04c3a35a499e6837278904d48'
133
- session.auth_type.must_equal 'basic_auth'
134
- session.user_name.must_equal 'admin'
127
+ _(session.id).must_equal '3040b0f04c3a35a499e6837278904d48'
128
+ _(session.user_name).must_equal 'admin'
135
129
  end
136
130
  end
137
131
 
@@ -139,7 +133,7 @@ describe HammerCLIForeman do
139
133
  Tempfile.create('session') do |f|
140
134
  session = HammerCLIForeman::Session.new(f.path)
141
135
  session.store
142
- File.stat(f.path).mode.to_s(8).must_equal '100600'
136
+ _(File.stat(f.path).mode.to_s(8)).must_equal '100600'
143
137
  end
144
138
  end
145
139
 
@@ -150,10 +144,9 @@ describe HammerCLIForeman do
150
144
  _, err = capture_io do
151
145
  session = HammerCLIForeman::Session.new(f.path)
152
146
  session.id = nil
153
- session.auth_type = nil
154
147
  session.user_name = nil
155
148
  end
156
- err.must_equal("Invalid session data. Resetting the session.\n")
149
+ _(err).must_equal("Invalid session data. Resetting the session.\n")
157
150
  end
158
151
  end
159
152
 
@@ -162,14 +155,12 @@ describe HammerCLIForeman do
162
155
  Tempfile.create('session') do |f|
163
156
  session = HammerCLIForeman::Session.new(f.path)
164
157
  session.id = '3040b0f04c3a35a499e6837278904d48'
165
- session.auth_type = 'basic_auth'
166
158
  session.user_name = 'admin'
167
159
  session.destroy
168
160
 
169
161
  session = HammerCLIForeman::Session.new(f.path)
170
- session.id.must_be_nil
171
- session.auth_type.must_equal 'basic_auth'
172
- session.user_name.must_equal 'admin'
162
+ _(session.id).must_be_nil
163
+ _(session.user_name).must_equal 'admin'
173
164
  end
174
165
  end
175
166
  end
@@ -179,9 +170,8 @@ describe HammerCLIForeman do
179
170
  Tempfile.create('session') do |f|
180
171
  session = HammerCLIForeman::Session.new(f.path)
181
172
  session.id = nil
182
- session.auth_type = 'basic_auth'
183
173
  session.user_name = 'admin'
184
- session.valid?.must_equal false
174
+ _(session.valid?).must_equal false
185
175
  end
186
176
  end
187
177
 
@@ -189,9 +179,8 @@ describe HammerCLIForeman do
189
179
  Tempfile.create('session') do |f|
190
180
  session = HammerCLIForeman::Session.new(f.path)
191
181
  session.id = '34252624635723572357234'
192
- session.auth_type = 'basic_auth'
193
182
  session.user_name = 'admin'
194
- session.valid?.must_equal true
183
+ _(session.valid?).must_equal true
195
184
  end
196
185
  end
197
186
  end