diff --git a/app/models/katello/host/content_facet.rb b/app/models/katello/host/content_facet.rb index ae25d2fd1e9..0fdea8d25eb 100644 --- a/app/models/katello/host/content_facet.rb +++ b/app/models/katello/host/content_facet.rb @@ -59,7 +59,7 @@ class ContentFacet < Katello::Model validates_associated :content_view_environment_content_facets, :message => _("invalid: The content source must sync the lifecycle environment assigned to the host. See the logs for more information.") validates :host, :presence => true, :allow_blank => false validates :bootc_booted_digest, :bootc_available_digest, :bootc_staged_digest, :bootc_rollback_digest, - format: { with: /\Asha256:[A-Fa-f0-9]{64}\z/, message: "must be a valid sha256 digest", allow_nil: true } + format: { with: /\Asha256:[A-Fa-f0-9]{64}\z/, message: "must be a valid sha256 digest", allow_blank: true } scope :with_environments, ->(lifecycle_environments) do joins(:content_view_environment_content_facets => :content_view_environment). diff --git a/test/models/concerns/host_managed_extensions_test.rb b/test/models/concerns/host_managed_extensions_test.rb index ae6227ea8a3..de2f42e6de5 100644 --- a/test/models/concerns/host_managed_extensions_test.rb +++ b/test/models/concerns/host_managed_extensions_test.rb @@ -70,6 +70,14 @@ def test_pools_expiring_in_days assert_includes ::Host.search_for('pools_expiring_in_days = 30'), host_with_pool end + def test_bootc_allow_blank + host_no_image = FactoryBot.create(:host, :with_content, :with_subscription, :content_view => @library_view, :lifecycle_environment => @library) + Support::HostSupport.attach_content_facet(@foreman_host, @view, @library) + @foreman_host.content_facet.update(bootc_booted_image: 'quay.io/salami/soup') + @foreman_host.content_facet.update(bootc_booted_digest: '') + assert @foreman_host.content_facet.image_mode_host? + end + def test_image_mode_search host_no_image = FactoryBot.create(:host, :with_content, :with_subscription, :content_view => @library_view, :lifecycle_environment => @library) Support::HostSupport.attach_content_facet(@foreman_host, @view, @library)