Skip to content

Commit

Permalink
Set the current userid when running a report
Browse files Browse the repository at this point in the history
With nothing specified it defaults to "system". Since we now enforce
checking the ownership of report results, the report results' userid
must be set to the current user instead.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1479296
  • Loading branch information
imtayadeway committed Aug 21, 2017
1 parent 74db741 commit 5f73e46
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/api/reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def find_reports(id)

def run_resource(type, id, _data)
report = resource_search(id, type, MiqReport)
report_result = MiqReportResult.find(report.queue_generate_table)
report_result = MiqReportResult.find(report.queue_generate_table(:userid => User.current_user.userid))
run_report_result(true,
"running report #{report.id}",
:task_id => report_result.miq_task_id,
Expand Down
2 changes: 2 additions & 0 deletions spec/requests/reports_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@
:success => true,
:message => "running report #{report.id}"
)
actual = MiqReportResult.find(ApplicationRecord.uncompress_id(response.parsed_body["result_id"]))
expect(actual.userid).to eq("api_user_id")
end

it "can schedule a run" do
Expand Down

0 comments on commit 5f73e46

Please sign in to comment.