Skip to content

Commit

Permalink
Drop compatibility with smart_proxy_openscap < 0.6.1
Browse files Browse the repository at this point in the history
If this was still needed, we could use capabilities and easily check
this statically but version 0.6.1 was released in 2017 so by now it's
safe to assume it's new enough.

Dropping the old code makes it more reliable and we have less code to
maintain.
  • Loading branch information
ekohl committed Jul 9, 2024
1 parent 6096ca1 commit 1fab050
Show file tree
Hide file tree
Showing 9 changed files with 2 additions and 142 deletions.
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
27 changes: 0 additions & 27 deletions test/unit/services/tailoring_files_proxy_check_test.rb

This file was deleted.

0 comments on commit 1fab050

Please sign in to comment.