Skip to content
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 @@ -59,11 +59,13 @@ def plan(filename, organization_id)
def try_execute
if content_disconnected?
logger.info("Upload canceled: connection to Insights is not enabled. Report location: #{filename}")
done!
return
end

unless organization.owner_details&.dig('upstreamConsumer', 'idCert')
logger.info("Skipping organization '#{organization}', no candlepin certificate defined.")
done!
return
end

Expand Down
29 changes: 29 additions & 0 deletions test/jobs/upload_report_direct_job_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -401,4 +401,33 @@ class UploadReportDirectJobTest < ActiveSupport::TestCase
file.close
end
end

test 'mark as done when upload aborted due to missing certificate' do
# Remove certificate from organization
Organization.any_instance.stubs(:owner_details).returns({})

action = create_action(ForemanInventoryUpload::Async::UploadReportDirectJob)
action.expects(:action_subject).with(@organization)
plan_action(action, nil, @organization.id)

# Execute the action
action.send(:try_execute)

# Verify it is marked as done
assert action.done?
end

test 'mark as done when upload aborted due to disconnected mode' do
Setting.stubs(:[]).with(:subscription_connection_enabled).returns(false)

action = create_action(ForemanInventoryUpload::Async::UploadReportDirectJob)
action.expects(:action_subject).with(@organization)
plan_action(action, nil, @organization.id)

# Execute the action
action.send(:try_execute)

# Verify it is marked as done
assert action.done?
end
end
Loading