Skip to content

Commit

Permalink
Fallback to default user ('system') when session is logged out
Browse files Browse the repository at this point in the history
fixing specs

fix failed tests
  • Loading branch information
nimrodshn committed Apr 2, 2018
1 parent a1915c1 commit 595d47b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 595d47b

Please sign in to comment.