foreman_omaha 0.0.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +5 -2
- data/app/assets/javascripts/foreman_omaha/application.js +1 -0
- data/app/assets/stylesheets/foreman_omaha/version_breakdown.scss +13 -0
- data/app/controllers/api/v2/omaha_groups_controller.rb +29 -0
- data/app/controllers/api/v2/omaha_reports_controller.rb +9 -7
- data/app/controllers/omaha_groups_controller.rb +28 -0
- data/app/controllers/omaha_hosts_controller.rb +42 -0
- data/app/controllers/omaha_reports_controller.rb +0 -11
- data/app/helpers/concerns/foreman_omaha/hosts_helper_extensions.rb +15 -6
- data/app/helpers/foreman_omaha/application_helper.rb +7 -0
- data/app/helpers/foreman_omaha/omaha_groups_helper.rb +52 -0
- data/app/helpers/omaha_hosts_helper.rb +43 -0
- data/app/models/concerns/foreman_omaha/host_extensions.rb +16 -2
- data/app/models/concerns/foreman_omaha/omaha_facet_host_extensions.rb +23 -0
- data/app/models/foreman_omaha/omaha_facet.rb +40 -0
- data/app/models/foreman_omaha/omaha_group.rb +34 -0
- data/app/models/foreman_omaha/omaha_report.rb +13 -21
- data/app/models/host_status/omaha_status.rb +6 -16
- data/app/services/foreman_omaha/charts/oem_distribution.rb +24 -0
- data/app/services/foreman_omaha/charts/status_distribution.rb +57 -0
- data/app/services/foreman_omaha/charts/version_distribution.rb +24 -0
- data/app/services/foreman_omaha/container_linux_config_transpiler.rb +33 -0
- data/app/services/foreman_omaha/fact_parser.rb +19 -3
- data/app/services/foreman_omaha/group_version_breakdown.rb +30 -0
- data/app/services/foreman_omaha/omaha_report_importer.rb +52 -3
- data/app/services/foreman_omaha/renderer_methods.rb +7 -0
- data/app/services/foreman_omaha/status_mapper.rb +53 -0
- data/app/views/api/v2/omaha_groups/base.json.rabl +3 -0
- data/app/views/api/v2/omaha_groups/index.json.rabl +3 -0
- data/app/views/api/v2/omaha_groups/main.json.rabl +5 -0
- data/app/views/api/v2/omaha_groups/show.json.rabl +3 -0
- data/app/views/application/foreman_omaha/_toolbar.html.erb +11 -0
- data/app/views/foreman_omaha/api/v2/omaha_facets/base.json.rabl +5 -0
- data/app/views/foreman_omaha/api/v2/omaha_facets/base_with_root.json.rabl +3 -0
- data/app/views/foreman_omaha/api/v2/omaha_facets/show.json.rabl +3 -0
- data/app/views/hosts/_omaha_tab.html.erb +29 -0
- data/app/views/omaha_groups/index.html.erb +34 -0
- data/app/views/omaha_groups/show.html.erb +196 -0
- data/app/views/omaha_hosts/index.html.erb +51 -0
- data/app/views/omaha_hosts/welcome.html.erb +12 -0
- data/app/views/omaha_reports/_details.html.erb +5 -3
- data/app/views/omaha_reports/_list.html.erb +2 -2
- data/app/views/omaha_reports/show.html.erb +1 -1
- data/app/views/omaha_reports/welcome.html.erb +1 -1
- data/config/routes.rb +14 -1
- data/db/migrate/20160812083100_add_omaha_fields_to_reports.foreman_omaha.rb +1 -1
- data/db/migrate/20171101204100_create_omaha_facets.foreman_omaha.rb +22 -0
- data/db/seeds.d/200_omaha_groups.rb +6 -0
- data/lib/foreman_omaha/engine.rb +74 -21
- data/lib/foreman_omaha/version.rb +1 -1
- data/lib/tasks/foreman_omaha_tasks.rake +2 -4
- data/test/factories/feature.rb +1 -1
- data/test/factories/foreman_omaha_factories.rb +16 -1
- data/test/factories/host.rb +21 -0
- data/test/factories/smart_proxy.rb +1 -1
- data/test/functional/api/v2/omaha_groups_controller_test.rb +32 -0
- data/test/functional/api/v2/omaha_reports_controller_test.rb +24 -24
- data/test/functional/omaha_groups_controller_test.rb +18 -0
- data/test/functional/omaha_hosts_controller_test.rb +11 -0
- data/test/functional/omaha_reports_controller_test.rb +13 -13
- data/test/test_plugin_helper.rb +3 -3
- data/test/unit/charts/oem_distribution_test.rb +26 -0
- data/test/unit/charts/status_distribution_test.rb +28 -0
- data/test/unit/charts/version_distribution_test.rb +28 -0
- data/test/unit/group_version_breakdown_test.rb +65 -0
- data/test/unit/host_status/omaha_status_test.rb +19 -0
- data/test/unit/host_test.rb +55 -0
- data/test/unit/omaha_fact_parser_test.rb +77 -0
- data/test/unit/omaha_report_test.rb +63 -17
- data/test/unit/renderer_test.rb +21 -0
- metadata +80 -9
@@ -0,0 +1,22 @@
|
|
1
|
+
class CreateOmahaFacets < ActiveRecord::Migration[4.2]
|
2
|
+
def change
|
3
|
+
create_table :omaha_groups do |t|
|
4
|
+
t.string :name, limit: 255, null: false, index: true
|
5
|
+
t.string :uuid, limit: 36, null: false, index: true
|
6
|
+
|
7
|
+
t.timestamps null: false
|
8
|
+
end
|
9
|
+
|
10
|
+
create_table :omaha_facets do |t|
|
11
|
+
t.references :host, null: false, foreign_key: true, index: true, unique: true
|
12
|
+
t.column :last_report, :datetime
|
13
|
+
t.string :version, limit: 255, index: true
|
14
|
+
t.string :machineid, limit: 32, index: true
|
15
|
+
t.integer :status, default: 1, index: true
|
16
|
+
t.string :oem, limit: 255, index: true
|
17
|
+
t.references :omaha_group, index: true, foreign_key: true
|
18
|
+
|
19
|
+
t.timestamps null: false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/foreman_omaha/engine.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'jquery-matchheight-rails'
|
2
|
+
|
1
3
|
module ForemanOmaha
|
2
4
|
class Engine < ::Rails::Engine
|
3
5
|
engine_name 'foreman_omaha'
|
@@ -16,7 +18,7 @@ module ForemanOmaha
|
|
16
18
|
|
17
19
|
initializer 'foreman_omaha.register_plugin', :before => :finisher_hook do |_app|
|
18
20
|
Foreman::Plugin.register :foreman_omaha do
|
19
|
-
requires_foreman '>= 1.
|
21
|
+
requires_foreman '>= 1.17'
|
20
22
|
|
21
23
|
apipie_documented_controllers ["#{ForemanOmaha::Engine.root}/app/controllers/api/v2/*.rb"]
|
22
24
|
|
@@ -24,12 +26,25 @@ module ForemanOmaha
|
|
24
26
|
|
25
27
|
# Add permissions
|
26
28
|
security_block :foreman_omaha do
|
27
|
-
permission :view_omaha_reports,
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
permission :view_omaha_reports, {
|
30
|
+
:omaha_reports => [:index, :show, :auto_complete_search],
|
31
|
+
:'api/v2/omaha_reports' => [:index, :show, :last]
|
32
|
+
}, :resource_type => 'ForemanOmaha::OmahaReport'
|
33
|
+
|
34
|
+
permission :destroy_omaha_reports, {
|
35
|
+
:omaha_reports => [:destroy],
|
36
|
+
:'api/v2/omaha_reports' => [:destroy]
|
37
|
+
}, :resource_type => 'ForemanOmaha::OmahaReport'
|
38
|
+
|
39
|
+
permission :upload_omaha_reports, {
|
40
|
+
:omaha_reports => [:create],
|
41
|
+
:'api/v2/omaha_reports' => [:create]
|
42
|
+
}, :resource_type => 'ForemanOmaha::OmahaReport'
|
43
|
+
|
44
|
+
permission :view_omaha_groups, {
|
45
|
+
:omaha_groups => [:index, :auto_complete_search, :show],
|
46
|
+
:'api/v2/omaha_groups' => [:index, :show]
|
47
|
+
}, :resource_type => 'ForemanOmaha::OmahaGroup'
|
33
48
|
end
|
34
49
|
|
35
50
|
role 'Omaha reports viewer',
|
@@ -40,14 +55,49 @@ module ForemanOmaha
|
|
40
55
|
# add menu entry
|
41
56
|
menu :top_menu, :omaha_reports,
|
42
57
|
:url_hash => { controller: :omaha_reports, action: :index },
|
43
|
-
:caption => N_('Omaha
|
58
|
+
:caption => N_('Omaha Reports'),
|
44
59
|
:parent => :monitor_menu,
|
45
|
-
after
|
46
|
-
end
|
60
|
+
:after => :reports
|
47
61
|
|
48
|
-
|
49
|
-
|
62
|
+
menu :top_menu, :omaha_hosts,
|
63
|
+
:url_hash => { :controller => :omaha_hosts, :action => :index },
|
64
|
+
:caption => N_('Omaha Hosts'),
|
65
|
+
:parent => :hosts_menu,
|
66
|
+
:after => :hosts
|
67
|
+
|
68
|
+
divider :top_menu, :caption => N_('Omaha'), :parent => :configure_menu, :last => true
|
69
|
+
|
70
|
+
menu :top_menu, :omaha_groups,
|
71
|
+
:url_hash => { :controller => :omaha_groups, :action => :index },
|
72
|
+
:caption => N_('Omaha Groups'),
|
73
|
+
:parent => :configure_menu,
|
74
|
+
:last => :true
|
75
|
+
|
76
|
+
# Omaha Facet
|
77
|
+
register_facet(ForemanOmaha::OmahaFacet, :omaha_facet) do
|
78
|
+
api_view :list => 'foreman_omaha/api/v2/omaha_facets/base_with_root', :single => 'foreman_omaha/api/v2/omaha_facets/show'
|
79
|
+
end
|
80
|
+
|
81
|
+
# extend host show page
|
82
|
+
extend_page('hosts/show') do |context|
|
83
|
+
context.add_pagelet :main_tabs,
|
84
|
+
:name => N_('Omaha'),
|
85
|
+
:partial => 'hosts/omaha_tab',
|
86
|
+
:onlyif => proc { |host| host.omaha_facet }
|
87
|
+
end
|
88
|
+
|
89
|
+
add_controller_action_scope(HostsController, :index) { |base_scope| base_scope.includes(:omaha_facet) }
|
90
|
+
|
91
|
+
# add renderer extensions
|
92
|
+
allowed_template_helpers :transpile_container_linux_config
|
93
|
+
extend_template_helpers ForemanOmaha::RendererMethods
|
50
94
|
end
|
95
|
+
|
96
|
+
# Extend built in permissions
|
97
|
+
Foreman::AccessControl.permission(:view_hosts).actions.concat [
|
98
|
+
'omaha_hosts/index',
|
99
|
+
'omaha_hosts/auto_complete_search'
|
100
|
+
]
|
51
101
|
end
|
52
102
|
|
53
103
|
# Include concerns in this config.to_prepare block
|
@@ -57,22 +107,25 @@ module ForemanOmaha
|
|
57
107
|
::FactParser.register_fact_parser(:foreman_omaha, ForemanOmaha::FactParser)
|
58
108
|
|
59
109
|
Host::Managed.send(:include, ForemanOmaha::HostExtensions)
|
110
|
+
Host::Managed.send(:include, ForemanOmaha::OmahaFacetHostExtensions)
|
60
111
|
HostsHelper.send(:include, ForemanOmaha::HostsHelperExtensions)
|
61
|
-
rescue => e
|
112
|
+
rescue StandardError => e
|
62
113
|
Rails.logger.warn "ForemanOmaha: skipping engine hook (#{e})"
|
63
114
|
end
|
64
115
|
end
|
65
116
|
|
117
|
+
# Precompile any JS, Stylesheet or Image files under app/assets/
|
118
|
+
assets_to_precompile =
|
119
|
+
Dir.chdir(root) do
|
120
|
+
Dir['app/assets/javascripts/**/*', 'app/assets/images/**/*', 'app/assets/stylesheets/**/*'].map do |f|
|
121
|
+
f.split(File::SEPARATOR, 4).last
|
122
|
+
end
|
123
|
+
end
|
66
124
|
initializer 'foreman_omaha.assets.precompile' do |app|
|
67
|
-
app.config.assets.precompile +=
|
125
|
+
app.config.assets.precompile += assets_to_precompile
|
68
126
|
end
|
69
|
-
|
70
|
-
|
71
|
-
SETTINGS[:foreman_omaha] = {
|
72
|
-
:assets => {
|
73
|
-
:precompile => ['foreman_omaha/Omaha.png']
|
74
|
-
}
|
75
|
-
}
|
127
|
+
initializer 'foreman_omaha.configure_assets', group: :assets do
|
128
|
+
SETTINGS[:foreman_omaha] = { assets: { precompile: assets_to_precompile } }
|
76
129
|
end
|
77
130
|
|
78
131
|
rake_tasks do
|
@@ -29,7 +29,7 @@ namespace :foreman_omaha do
|
|
29
29
|
"#{ForemanOmaha::Engine.root}/lib/**/*.rb",
|
30
30
|
"#{ForemanOmaha::Engine.root}/test/**/*.rb"]
|
31
31
|
end
|
32
|
-
rescue
|
32
|
+
rescue StandardError
|
33
33
|
puts 'Rubocop not loaded.'
|
34
34
|
end
|
35
35
|
|
@@ -40,6 +40,4 @@ end
|
|
40
40
|
Rake::Task[:test].enhance ['test:foreman_omaha']
|
41
41
|
|
42
42
|
load 'tasks/jenkins.rake'
|
43
|
-
if Rake::Task.task_defined?(:'jenkins:unit')
|
44
|
-
Rake::Task['jenkins:unit'].enhance ['test:foreman_omaha', 'foreman_omaha:rubocop']
|
45
|
-
end
|
43
|
+
Rake::Task['jenkins:unit'].enhance ['test:foreman_omaha', 'foreman_omaha:rubocop'] if Rake::Task.task_defined?(:'jenkins:unit')
|
data/test/factories/feature.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
FactoryBot.define do
|
2
2
|
factory :omaha_report, :class => 'ForemanOmaha::OmahaReport' do
|
3
3
|
host
|
4
4
|
sequence(:reported_at) { |n| n.minutes.ago }
|
@@ -6,4 +6,19 @@ FactoryGirl.define do
|
|
6
6
|
omaha_version '1068.9.0'
|
7
7
|
type 'ForemanOmaha::OmahaReport'
|
8
8
|
end
|
9
|
+
|
10
|
+
factory :omaha_facet, :class => 'ForemanOmaha::OmahaFacet' do
|
11
|
+
sequence(:last_report) { |n| n.minutes.ago }
|
12
|
+
version '1068.9.0'
|
13
|
+
oem 'rackspace'
|
14
|
+
sequence(:machineid) { SecureRandom.hex }
|
15
|
+
status 1
|
16
|
+
host
|
17
|
+
omaha_group
|
18
|
+
end
|
19
|
+
|
20
|
+
factory :omaha_group, :class => 'ForemanOmaha::OmahaGroup' do
|
21
|
+
sequence(:name) { |n| "Omaha Group #{n}" }
|
22
|
+
sequence(:uuid) { SecureRandom.uuid }
|
23
|
+
end
|
9
24
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
FactoryBot.modify do
|
2
|
+
factory :host do
|
3
|
+
trait :with_omaha_facet do
|
4
|
+
association :omaha_facet, :factory => :omaha_facet, :strategy => :build
|
5
|
+
|
6
|
+
transient do
|
7
|
+
omaha_status 1
|
8
|
+
omaha_version '1068.9.0'
|
9
|
+
omaha_oem 'rackspace'
|
10
|
+
omaha_group nil
|
11
|
+
end
|
12
|
+
|
13
|
+
after(:build) do |host, evaluator|
|
14
|
+
host.omaha_facet.status = evaluator.omaha_status
|
15
|
+
host.omaha_facet.version = evaluator.omaha_version
|
16
|
+
host.omaha_facet.oem = evaluator.omaha_oem
|
17
|
+
host.omaha_facet.omaha_group = evaluator.omaha_group if evaluator.omaha_group.present?
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'test_plugin_helper'
|
2
|
+
|
3
|
+
class Api::V2::OmahaGroupsControllerTest < ActionController::TestCase
|
4
|
+
context '#index' do
|
5
|
+
test 'should list omaha groups' do
|
6
|
+
omaha_group = FactoryBot.create(:omaha_group, :name => 'Stable', :uuid => 'stable')
|
7
|
+
get :index
|
8
|
+
assert_response :success
|
9
|
+
body = ActiveSupport::JSON.decode(@response.body)
|
10
|
+
results = body['results']
|
11
|
+
assert results
|
12
|
+
entry = results.detect { |e| e['id'] == omaha_group.id }
|
13
|
+
assert entry
|
14
|
+
assert_equal omaha_group.name, entry['name']
|
15
|
+
assert_equal omaha_group.uuid, entry['uuid']
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context '#show' do
|
20
|
+
let(:omaha_group) { FactoryBot.create(:omaha_group) }
|
21
|
+
|
22
|
+
test 'should show individual record' do
|
23
|
+
get :show, params: { :id => omaha_group.to_param }
|
24
|
+
assert_response :success
|
25
|
+
body = ActiveSupport::JSON.decode(@response.body)
|
26
|
+
refute_empty body
|
27
|
+
assert_equal omaha_group.id, body['id']
|
28
|
+
assert_equal omaha_group.name, body['name']
|
29
|
+
assert_equal omaha_group.uuid, body['uuid']
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -2,18 +2,18 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class Api::V2::OmahaReportsControllerTest < ActionController::TestCase
|
4
4
|
test 'create valid' do
|
5
|
-
post :create, { :omaha_report => create_report }, set_session_user
|
5
|
+
post :create, params: { :omaha_report => create_report }, session: set_session_user
|
6
6
|
assert_response :success
|
7
7
|
end
|
8
8
|
|
9
9
|
test 'create invalid' do
|
10
|
-
post :create, { :omaha_report => ['not a hash', 'throw an error'] }, set_session_user
|
10
|
+
post :create, params: { :omaha_report => ['not a hash', 'throw an error'] }, session: set_session_user
|
11
11
|
assert_response :unprocessable_entity
|
12
12
|
end
|
13
13
|
|
14
14
|
test 'should get index' do
|
15
|
-
|
16
|
-
get :index
|
15
|
+
FactoryBot.create(:omaha_report)
|
16
|
+
get :index
|
17
17
|
assert_response :success
|
18
18
|
assert_not_nil assigns(:omaha_reports)
|
19
19
|
reports = ActiveSupport::JSON.decode(@response.body)
|
@@ -21,25 +21,25 @@ class Api::V2::OmahaReportsControllerTest < ActionController::TestCase
|
|
21
21
|
end
|
22
22
|
|
23
23
|
test 'should show individual record' do
|
24
|
-
report =
|
25
|
-
get :show, :id => report.to_param
|
24
|
+
report = FactoryBot.create(:omaha_report)
|
25
|
+
get :show, params: { :id => report.to_param }
|
26
26
|
assert_response :success
|
27
27
|
show_response = ActiveSupport::JSON.decode(@response.body)
|
28
28
|
assert !show_response.empty?
|
29
29
|
end
|
30
30
|
|
31
31
|
test 'should destroy report' do
|
32
|
-
report =
|
32
|
+
report = FactoryBot.create(:omaha_report)
|
33
33
|
assert_difference('ForemanOmaha::OmahaReport.count', -1) do
|
34
|
-
delete :destroy, :id => report.to_param
|
34
|
+
delete :destroy, params: { :id => report.to_param }
|
35
35
|
end
|
36
36
|
assert_response :success
|
37
37
|
refute Report.find_by(id: report.id)
|
38
38
|
end
|
39
39
|
|
40
40
|
test 'should get reports for given host only' do
|
41
|
-
report =
|
42
|
-
get :index, :host_id => report.host.to_param
|
41
|
+
report = FactoryBot.create(:omaha_report)
|
42
|
+
get :index, params: { :host_id => report.host.to_param }
|
43
43
|
assert_response :success
|
44
44
|
assert_not_nil assigns(:omaha_reports)
|
45
45
|
reports = ActiveSupport::JSON.decode(@response.body)
|
@@ -48,8 +48,8 @@ class Api::V2::OmahaReportsControllerTest < ActionController::TestCase
|
|
48
48
|
end
|
49
49
|
|
50
50
|
test 'should return empty result for host with no reports' do
|
51
|
-
host =
|
52
|
-
get :index, :host_id => host.to_param
|
51
|
+
host = FactoryBot.create(:host)
|
52
|
+
get :index, params: { :host_id => host.to_param }
|
53
53
|
assert_response :success
|
54
54
|
assert_not_nil assigns(:omaha_reports)
|
55
55
|
reports = ActiveSupport::JSON.decode(@response.body)
|
@@ -58,8 +58,8 @@ class Api::V2::OmahaReportsControllerTest < ActionController::TestCase
|
|
58
58
|
end
|
59
59
|
|
60
60
|
test 'should get last report' do
|
61
|
-
reports =
|
62
|
-
get :last, set_session_user
|
61
|
+
reports = FactoryBot.create_list(:omaha_report, 5)
|
62
|
+
get :last, session: set_session_user
|
63
63
|
assert_response :success
|
64
64
|
assert_not_nil assigns(:omaha_report)
|
65
65
|
report = ActiveSupport::JSON.decode(@response.body)
|
@@ -68,9 +68,9 @@ class Api::V2::OmahaReportsControllerTest < ActionController::TestCase
|
|
68
68
|
end
|
69
69
|
|
70
70
|
test 'should get last report for given host only' do
|
71
|
-
main_report =
|
72
|
-
|
73
|
-
get :last, { :host_id => main_report.host.to_param }, set_session_user
|
71
|
+
main_report = FactoryBot.create(:omaha_report)
|
72
|
+
FactoryBot.create_list(:omaha_report, 5)
|
73
|
+
get :last, params: { :host_id => main_report.host.to_param }, session: set_session_user
|
74
74
|
assert_response :success
|
75
75
|
assert_not_nil assigns(:omaha_report)
|
76
76
|
report = ActiveSupport::JSON.decode(@response.body)
|
@@ -79,32 +79,32 @@ class Api::V2::OmahaReportsControllerTest < ActionController::TestCase
|
|
79
79
|
end
|
80
80
|
|
81
81
|
test 'should give error if no last report for given host' do
|
82
|
-
host =
|
83
|
-
get :last, :host_id => host.to_param
|
82
|
+
host = FactoryBot.create(:host)
|
83
|
+
get :last, params: { :host_id => host.to_param }
|
84
84
|
assert_response :not_found
|
85
85
|
end
|
86
86
|
|
87
87
|
test 'cannot view the last report without hosts view permission' do
|
88
|
-
report =
|
88
|
+
report = FactoryBot.create(:report)
|
89
89
|
setup_user('view', 'omaha_reports')
|
90
|
-
get :last, { :host_id => report.host.id }, set_session_user.merge(:user => User.current.id)
|
90
|
+
get :last, params: { :host_id => report.host.id }, session: set_session_user.merge(:user => User.current.id)
|
91
91
|
assert_response :not_found
|
92
92
|
end
|
93
93
|
|
94
94
|
describe 'unpriveliged user' do
|
95
95
|
def setup
|
96
|
-
User.current =
|
96
|
+
User.current = FactoryBot.create(:user, :admin)
|
97
97
|
end
|
98
98
|
|
99
99
|
test 'hosts with a registered smart proxy on should create a report successfully' do
|
100
100
|
Setting[:restrict_registered_smart_proxies] = true
|
101
101
|
Setting[:require_ssl_smart_proxies] = false
|
102
102
|
|
103
|
-
proxy =
|
103
|
+
proxy = FactoryBot.create(:smart_proxy, :omaha)
|
104
104
|
host = URI.parse(proxy.url).host
|
105
105
|
Resolv.any_instance.stubs(:getnames).returns([host])
|
106
106
|
as_user :one do
|
107
|
-
post :create, :omaha_report => create_report
|
107
|
+
post :create, params: { :omaha_report => create_report }
|
108
108
|
end
|
109
109
|
assert_equal proxy, @controller.detected_proxy
|
110
110
|
assert_response :created
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'test_plugin_helper'
|
2
|
+
|
3
|
+
class OmahaGroupsControllerTest < ActionController::TestCase
|
4
|
+
test '#index' do
|
5
|
+
FactoryBot.create(:omaha_group)
|
6
|
+
get :index, session: set_session_user
|
7
|
+
assert_response :success
|
8
|
+
assert_not_nil assigns('omaha_groups')
|
9
|
+
assert_template 'index'
|
10
|
+
end
|
11
|
+
|
12
|
+
test '#show' do
|
13
|
+
omaha_group = FactoryBot.create(:omaha_group)
|
14
|
+
get :show, params: { :id => omaha_group.id }, session: set_session_user
|
15
|
+
assert_response :success
|
16
|
+
assert_template 'show'
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'test_plugin_helper'
|
2
|
+
|
3
|
+
class OmahaHostsControllerTest < ActionController::TestCase
|
4
|
+
test '#index' do
|
5
|
+
FactoryBot.create(:host, :with_omaha_facet)
|
6
|
+
get :index, session: set_session_user
|
7
|
+
assert_response :success
|
8
|
+
assert_not_nil assigns('hosts')
|
9
|
+
assert_template 'index'
|
10
|
+
end
|
11
|
+
end
|