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

adding userid as param to scan_job_create
  • Loading branch information
nimrodshn committed Apr 9, 2018
1 parent a1915c1 commit 0d11ffc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,12 @@ def default_authentication_type
:bearer
end

def scan_job_create(entity)
check_policy_prevent(:request_containerimage_scan, entity, User.current_user.userid, :raw_scan_job_create)
def scan_job_create(entity, userid)
check_policy_prevent(:request_containerimage_scan, entity, 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 0d11ffc

Please sign in to comment.