Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #37642 - Drop compatibility with smart_proxy_openscap < 0.6.1 #575

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class TailoringFilesController < ::Api::V2::BaseController
include ForemanOpenscap::Api::V2::ScapApiControllerExtensions

before_action :find_resource, :except => %w[index create]
before_action :openscap_proxy_check, :only => %w[create]

api :GET, '/compliance/tailoring_files', N_('List Tailoring files')
param_group :search_and_pagination, ::Api::V2::BaseController
Expand Down Expand Up @@ -77,13 +76,6 @@ def action_permission
super
end
end

def openscap_proxy_check
unless ForemanOpenscap::TailoringFile.any?
check = ForemanOpenscap::OpenscapProxyVersionCheck.new.run
render_error :custom_error, :status => :unprocessable_entity, :locals => { :message => check.message } unless check.pass?
end
end
end
end
end
5 changes: 0 additions & 5 deletions app/helpers/tailoring_files_helper.rb

This file was deleted.

4 changes: 1 addition & 3 deletions app/models/concerns/foreman_openscap/host_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ def policies_enc
end

def policies_enc_raw
check = ForemanOpenscap::OpenscapProxyAssignedVersionCheck.new(self).run
method = check.pass? ? :to_enc : :to_enc_legacy
combined_policies.map(&method)
combined_policies.map(&:to_enc)
end

def combined_policies
Expand Down
4 changes: 0 additions & 4 deletions app/models/foreman_openscap/policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,6 @@ def to_enc
}.merge(period_enc)
end

def to_enc_legacy
to_enc.tap { |hash| hash['download_path'] = "/compliance/policies/#{self.id}/content" }
end

def should_validate?(step_name)
if new_record? && wizard_initiated?
step_index > step_to_i(step_name)
Expand Down

This file was deleted.

62 changes: 0 additions & 62 deletions app/services/foreman_openscap/openscap_proxy_version_check.rb

This file was deleted.

9 changes: 1 addition & 8 deletions app/views/tailoring_files/welcome.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,7 @@
<%= (_('In Foreman, tailoring_files represent the custom modifications to default XCCDF profiles and they can be applied to hosts
via %s') % link_to('compliance policies', policies_path)).html_safe %>
</p>
<% proxy_check = run_tailoring_proxy_check %>
<div class="blank-slate-pf-main-action">
<%= new_link(_('New Tailoring File'), {}, { :class => "btn-lg", :disabled => !proxy_check.pass? }) %>
<%= new_link(_('New Tailoring File'), {}, { :class => "btn-lg" }) %>
</div>

<p>
<% unless proxy_check.pass? %>
<%= alert :class => 'alert-warning', :header => '', :text => proxy_check.message.html_safe %>
<% end %>
</p>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ class Api::V2::Compliance::TailoringFilesControllerTest < ActionController::Test
test "should create tailoring_file" do
tf = FactoryBot.build(:tailoring_file)
tf_params = { :name => tf.name, :original_filename => tf.original_filename, :scap_file => tf.scap_file }
ForemanOpenscap::OpenscapProxyVersionCheck.any_instance.stubs(:openscap_proxy_versions)
.returns({})
post :create, :params => tf_params, :session => set_session_user
assert_response :success
end
Expand All @@ -50,13 +48,4 @@ class Api::V2::Compliance::TailoringFilesControllerTest < ActionController::Test
assert_response :ok
refute ForemanOpenscap::ScapContent.exists?(tailoring_file.id)
end

test "should not create tailoring file when there is outdated proxy version" do
tf = FactoryBot.build(:tailoring_file)
tf_params = { :name => tf.name, :original_filename => tf.original_filename, :scap_file => tf.scap_file }
ForemanOpenscap::OpenscapProxyVersionCheck.any_instance.stubs(:openscap_proxy_versions)
.returns('test-proxy' => '0.5.4')
post :create, :params => tf_params, :session => set_session_user
assert_response :unprocessable_entity
end
end
9 changes: 0 additions & 9 deletions test/unit/concerns/host_extensions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,7 @@ class HostExtensionsTest < ActiveSupport::TestCase
@host = FactoryBot.create(:compliance_host, :policies => [@policy])
end

test "should have download_path in enc without digest" do
ForemanOpenscap::OpenscapProxyAssignedVersionCheck.any_instance.stubs(:openscap_proxy_versions)
.returns('test-proxy' => '0.5.4')
enc_out = JSON.parse @host.policies_enc
assert_equal 5, enc_out.first['download_path'].split('/').length
end

test "should have download_path in enc with digest" do
ForemanOpenscap::OpenscapProxyAssignedVersionCheck.any_instance.stubs(:openscap_proxy_versions)
.returns({})
enc_out = JSON.parse @host.policies_enc
assert_equal 6, enc_out.first['download_path'].split('/').length
end
Expand Down
27 changes: 0 additions & 27 deletions test/unit/services/tailoring_files_proxy_check_test.rb

This file was deleted.

Loading