diff --git a/app/models/manageiq/providers/kubernetes/container_manager_mixin.rb b/app/models/manageiq/providers/kubernetes/container_manager_mixin.rb index b701f9cf11..18ef08e259 100644 --- a/app/models/manageiq/providers/kubernetes/container_manager_mixin.rb +++ b/app/models/manageiq/providers/kubernetes/container_manager_mixin.rb @@ -192,12 +192,11 @@ def default_authentication_type end def scan_job_create(entity) - check_policy_prevent(:request_containerimage_scan, entity, User.current_user.userid, :raw_scan_job_create) + check_policy_prevent(:request_containerimage_scan, entity, User.current_user.try(:userid), :raw_scan_job_create) end def raw_scan_job_create(target_class, target_id = nil, userid = nil, target_name = nil) raise MiqException::Error, _("target_class must be a class not an instance") if target_class.kind_of?(ContainerImage) - userid ||= User.current_user.userid Job.create_job( "ManageIQ::Providers::Kubernetes::ContainerManager::Scanning::Job", :userid => userid, diff --git a/spec/models/manageiq/providers/kubernetes/container_manager/scanning/job_spec.rb b/spec/models/manageiq/providers/kubernetes/container_manager/scanning/job_spec.rb index dbe6f4c8e6..65ec76191f 100644 --- a/spec/models/manageiq/providers/kubernetes/container_manager/scanning/job_spec.rb +++ b/spec/models/manageiq/providers/kubernetes/container_manager/scanning/job_spec.rb @@ -164,7 +164,7 @@ def fetch_oscap_arf # https://github.com/ManageIQ/manageiq-providers-kubernetes/pull/54/files image = FactoryGirl.create(:container_image, :ext_management_system => @ems) User.current_user = FactoryGirl.create(:user, :userid => "bob") - job = @ems.raw_scan_job_create(image.class, image.id) + job = @ems.raw_scan_job_create(image.class, image.id, User.current_user.userid) expect(job).to have_attributes( :dispatch_status => "pending", :state => "waiting_to_start", diff --git a/spec/models/manageiq/providers/kubernetes/container_manager_spec.rb b/spec/models/manageiq/providers/kubernetes/container_manager_spec.rb index 66ecc2691f..dae2291cad 100644 --- a/spec/models/manageiq/providers/kubernetes/container_manager_spec.rb +++ b/spec/models/manageiq/providers/kubernetes/container_manager_spec.rb @@ -146,7 +146,7 @@ it ".scan_job_create" do image = FactoryGirl.create(:container_image, :ext_management_system => @ems) User.current_user = FactoryGirl.create(:user, :userid => "bob") - job = @ems.raw_scan_job_create(image.class, image.id) + job = @ems.raw_scan_job_create(image.class, image.id, User.current_user.userid) expect(job.state).to eq("waiting_to_start") expect(job.status).to eq("ok")