Expose authentication provider ID and integration ID in reports

Fixes: CNVS-31655

Test plan:
- Navigate to the account settings page
- Navigate to the Reports tab
- Click `Configure` for the Provisioning report
- In the modal click `Users CSV` and then click `Run Report`
- Once the report finishes click the download link
- Open the csv and confirm the `authentication_provider_id`
  and the `integration_id` are present in the report
- Repeat the Provisioning report scenario just for `Courses CSV`
  AND `Sections CSV`. NOTE: The `Courses CSV` and `Sections CSV`
  reoprts WILL NOT have `authentication_provider_id`
- Repeat these same steps for the `SIS Export` report and expect
  the same results

Change-Id: I543292565c5435cdfae737d7105574a83c9702f4
Reviewed-on: https://gerrit.instructure.com/108217
Tested-by: Jenkins
Reviewed-by: Jayce Higgins <jhiggins@instructure.com>
QA-Review: Mark McDermott <mmcdermott@instructure.com>
Product-Review: Brad Humphrey <brad@instructure.com>
This commit is contained in:
Nick Houle 2017-04-11 12:22:53 -06:00
parent ff19c48de2
commit 0a9c46b52c
2 changed files with 89 additions and 170 deletions

View File

@ -63,24 +63,11 @@ module AccountReports
end
def users
if @sis_format
# headers are not translated on sis_export to maintain import compatibility
headers = ['user_id', 'login_id', 'password', 'first_name', 'last_name',
'full_name', 'sortable_name', 'short_name', 'email', 'status']
else # provisioning_report
headers = []
headers << I18n.t('#account_reports.report_header_canvas_user_id', 'canvas_user_id')
headers << I18n.t('#account_reports.report_header_user__id', 'user_id')
headers << I18n.t('#account_reports.report_header_login_id', 'login_id')
headers << I18n.t('#account_reports.report_header_first_name', 'first_name')
headers << I18n.t('#account_reports.report_header_last_name', 'last_name')
headers << I18n.t('#account_reports.report_header_full_name', 'full_name')
headers << I18n.t('#account_reports.report_header_sortable_name', 'sortable_name')
headers << I18n.t('#account_reports.report_header_user_short_name', 'short_name')
headers << I18n.t('#account_reports.report_header_email', 'email')
headers << I18n.t('#account_reports.report_header_status', 'status')
headers << I18n.t('created_by_sis')
end
header_names = ['user_id', 'integration_id', 'authentication_provider_id',
'login_id', 'password', 'first_name', 'last_name',
'full_name', 'sortable_name', 'short_name', 'email', 'status']
canvas_headers = ['canvas_user_id']
headers = header_creator(header_names, canvas_headers)
users = root_account.pseudonyms.except(:preload).joins(:user).select(
"pseudonyms.id, pseudonyms.sis_user_id, pseudonyms.user_id, pseudonyms.sis_batch_id,
@ -136,19 +123,10 @@ module AccountReports
end
def accounts
if @sis_format
# headers are not translated on sis_export to maintain import compatibility
headers = ['account_id', 'parent_account_id', 'name', 'status']
else
headers = []
headers << I18n.t('#account_reports.report_header_canvas_account_id', 'canvas_account_id')
headers << I18n.t('#account_reports.report_header_account_id', 'account_id')
headers << I18n.t('#account_reports.report_header_canvas_parent_id', 'canvas_parent_id')
headers << I18n.t('#account_reports.report_header_parent_account_id', 'parent_account_id')
headers << I18n.t('#account_reports.report_header_name', 'name')
headers << I18n.t('#account_reports.report_header_status', 'status')
headers << I18n.t('created_by_sis')
end
header_names = ['account_id', 'parent_account_id', 'name', 'status']
canvas_headers = ['canvas_account_id', 'canvas_parent_id']
headers = header_creator(header_names, canvas_headers)
accounts = root_account.all_accounts.
select("accounts.*, pa.id AS parent_id,
pa.sis_source_id AS parent_sis_source_id").
@ -184,19 +162,10 @@ module AccountReports
end
def terms
if @sis_format
# headers are not translated on sis_export to maintain import compatibility
headers = ['term_id', 'name', 'status', 'start_date', 'end_date']
else
headers = []
headers << I18n.t('#account_reports.report_header_canvas_term_id', 'canvas_term_id')
headers << I18n.t('#account_reports.report_header_term__id', 'term_id')
headers << I18n.t('#account_reports.report_header_name', 'name')
headers << I18n.t('#account_reports.report_header_status', 'status')
headers << I18n.t('#account_reports.report_header_start__date', 'start_date')
headers << I18n.t('#account_reports.report_header_end__date', 'end_date')
headers << I18n.t('created_by_sis')
end
header_names = ['term_id', 'name', 'status', 'start_date', 'end_date']
canvas_headers = ['canvas_term_id']
headers = header_creator(header_names, canvas_headers)
terms = root_account.enrollment_terms
terms = terms.where.not(sis_source_id: nil) if @sis_format
terms = terms.where.not(enrollment_terms: {sis_batch_id: nil}) if @created_by_sis
@ -223,25 +192,10 @@ module AccountReports
end
def courses
if @sis_format
# headers are not translated on sis_export to maintain import compatibility
headers = ['course_id', 'short_name', 'long_name', 'account_id', 'term_id', 'status',
'start_date', 'end_date']
else
headers = []
headers << I18n.t('#account_reports.report_header_canvas_course_id', 'canvas_course_id')
headers << I18n.t('#account_reports.report_header_course__id', 'course_id')
headers << I18n.t('#account_reports.report_header_short__name', 'short_name')
headers << I18n.t('#account_reports.report_header_long__name', 'long_name')
headers << I18n.t('#account_reports.report_header_canvas_account_id', 'canvas_account_id')
headers << I18n.t('#account_reports.report_header_account_id', 'account_id')
headers << I18n.t('#account_reports.report_header_canvas_term_id', 'canvas_term_id')
headers << I18n.t('#account_reports.report_header_term__id', 'term_id')
headers << I18n.t('#account_reports.report_header_status', 'status')
headers << I18n.t('#account_reports.report_header_start__date', 'start_date')
headers << I18n.t('#account_reports.report_header_end__date', 'end_date')
headers << I18n.t('created_by_sis')
end
header_names = ['course_id', 'integration_id', 'short_name', 'long_name',
'account_id', 'term_id', 'status', 'start_date', 'end_date']
canvas_headers = ['canvas_course_id', 'canvas_account_id', 'canvas_term_id']
headers = header_creator(header_names, canvas_headers)
courses = root_account.all_courses.preload(:account, :enrollment_term)
courses = courses.where.not(courses: {sis_source_id: nil}) if @sis_format
@ -297,23 +251,11 @@ module AccountReports
end
def sections
if @sis_format
# headers are not translated on sis_export to maintain import compatibility
headers = ['section_id', 'course_id', 'name', 'status', 'start_date', 'end_date']
else
headers = []
headers << I18n.t('#account_reports.report_header_canvas_section_id', 'canvas_section_id')
headers << I18n.t('#account_reports.report_header_section__id', 'section_id')
headers << I18n.t('#account_reports.report_header_canvas_course_id', 'canvas_course_id')
headers << I18n.t('#account_reports.report_header_course__id', 'course_id')
headers << I18n.t('#account_reports.report_header_name', 'name')
headers << I18n.t('#account_reports.report_header_status', 'status')
headers << I18n.t('#account_reports.report_header_start__date', 'start_date')
headers << I18n.t('#account_reports.report_header_end__date', 'end_date')
headers << I18n.t('#account_reports.report_header_canvas_account_id', 'canvas_account_id')
headers << I18n.t('#account_reports.report_header_account_id', 'account_id')
headers << I18n.t('created_by_sis')
end
header_names = ['section_id', 'course_id', 'integration_id', 'name',
'status', 'start_date', 'end_date', 'account_id']
canvas_headers = ['canvas_section_id', 'canvas_course_id', 'canvas_account_id']
headers = header_creator(header_names, canvas_headers)
sections = root_account.course_sections.
select("course_sections.*, nxc.sis_source_id AS non_x_course_sis_id,
rc.sis_source_id AS course_sis_id, nxc.id AS non_x_course_id,
@ -383,27 +325,15 @@ module AccountReports
end
def enrollments
if @sis_format
# headers are not translated on sis_export to maintain import compatibility
headers = ['course_id', 'user_id', 'role', 'role_id', 'section_id', 'status', 'associated_user_id', 'limit_section_privileges']
else
headers = []
headers << I18n.t('#account_reports.report_header_canvas_course_id', 'canvas_course_id')
headers << I18n.t('#account_reports.report_header_course__id', 'course_id')
headers << I18n.t('#account_reports.report_header_canvas_user_id', 'canvas_user_id')
headers << I18n.t('#account_reports.report_header_user__id', 'user_id')
headers << I18n.t('#account_reports.report_header_role', 'role')
headers << I18n.t('#account_reports.report_header_role_id', 'role_id')
headers << I18n.t('#account_reports.report_header_canvas_section_id', 'canvas_section_id')
headers << I18n.t('#account_reports.report_header_section__id', 'section_id')
headers << I18n.t('#account_reports.report_header_status', 'status')
headers << I18n.t('#account_reports.report_header_canvas_associated_user_id', 'canvas_associated_user_id')
headers << I18n.t('#account_reports.report_header_associated_user_id', 'associated_user_id')
headers << I18n.t('created_by_sis')
headers << I18n.t('base_role_type')
headers << I18n.t('limit_section_privileges')
end
enrol = root_account.enrollments.
header_names = ['course_id', 'user_id', 'role', 'role_id', 'section_id',
'status', 'associated_user_id']
canvas_headers = ['canvas_course_id', 'canvas_user_id', 'canvas_section_id',
'canvas_associated_user_id']
headers = header_creator(header_names, canvas_headers)
headers << I18n.t('base_role_type')
headers << I18n.t('limit_section_privileges')
enroll = root_account.enrollments.
select("enrollments.*, courses.sis_source_id AS course_sis_id,
nxc.id AS nxc_id, nxc.sis_source_id AS nxc_sis_id,
cs.sis_source_id AS course_section_sis_id,
@ -426,28 +356,28 @@ module AccountReports
AND enrollments.type <> 'StudentViewEnrollment'")
if @include_deleted
enrol.where!("enrollments.workflow_state<>'deleted'
enroll.where!("enrollments.workflow_state<>'deleted'
OR
( pseudonyms.sis_user_id IS NOT NULL
AND enrollments.workflow_state NOT IN ('rejected', 'invited')
AND (courses.sis_source_id IS NOT NULL
OR cs.sis_source_id IS NOT NULL))")
else
enrol.where!("enrollments.workflow_state<>'deleted'
enroll.where!("enrollments.workflow_state<>'deleted'
AND enrollments.workflow_state<>'completed'
AND pseudonyms.workflow_state<>'deleted'")
end
if @sis_format
enrol = enrol.where("pseudonyms.sis_user_id IS NOT NULL
enroll = enroll.where("pseudonyms.sis_user_id IS NOT NULL
AND enrollments.workflow_state NOT IN ('rejected', 'invited', 'creation_pending')
AND (courses.sis_source_id IS NOT NULL
OR cs.sis_source_id IS NOT NULL)")
end
enrol = enrol.where.not(enrollments: {sis_batch_id: nil}) if @created_by_sis
enrol = add_course_sub_account_scope(enrol)
enrol = add_term_scope(enrol)
enroll = enroll.where.not(enrollments: {sis_batch_id: nil}) if @created_by_sis
enroll = add_course_sub_account_scope(enroll)
enroll = add_term_scope(enroll)
generate_and_run_report headers do |csv|
# the "start" parameter is purely to
@ -455,7 +385,7 @@ module AccountReports
# rather than a cursor for this iteration
# because it often is big enough that the slave
# kills it mid-run (http://www.postgresql.org/docs/9.0/static/hot-standby.html)
enrol.find_each(start: 0) do |e|
enroll.find_each(start: 0) do |e|
row = []
if e.nxc_id.nil?
row << e.course_id unless @sis_format
@ -482,22 +412,12 @@ module AccountReports
end
def groups
if @sis_format
# headers are not translated on sis_export to maintain import compatibility
headers = ['group_id', 'account_id', 'name', 'status']
else
headers = []
headers << I18n.t('#account_reports.report_header_canvas_group_id', 'canvas_group_id')
headers << I18n.t('#account_reports.report_header_group_id', 'group_id')
headers << I18n.t('#account_reports.report_header_canvas_account_id', 'canvas_account_id')
headers << I18n.t('#account_reports.report_header_account_id', 'account_id')
headers << I18n.t('#account_reports.report_header_name', 'name')
headers << I18n.t('#account_reports.report_header_status', 'status')
headers << I18n.t('created_by_sis')
headers << I18n.t('context_id')
headers << I18n.t('context_type')
headers << I18n.t('group_category_id')
end
header_names = ['group_id', 'account_id', 'name', 'status']
canvas_headers = ['canvas_group_id', 'canvas_account_id']
headers = header_creator(header_names, canvas_headers)
headers << I18n.t('context_id')
headers << I18n.t('context_type')
headers << I18n.t('group_category_id')
groups = root_account.all_groups.
select("groups.*, accounts.sis_source_id AS account_sis_id").
@ -583,18 +503,9 @@ module AccountReports
end
def group_membership
if @sis_format
# headers are not translated on sis_export to maintain import compatibility
headers = ['group_id', 'user_id', 'status']
else
headers = []
headers << I18n.t('#account_reports.report_header_canvas_group_id', 'canvas_group_id')
headers << I18n.t('#account_reports.report_header_group_id', 'group_id')
headers << I18n.t('#account_reports.report_header_canvas_user_id', 'canvas_user_id')
headers << I18n.t('#account_reports.report_header_user__id', 'user_id')
headers << I18n.t('#account_reports.report_header_status', 'status')
headers << I18n.t('created_by_sis')
end
header_names = ['group_id', 'user_id', 'status']
canvas_headers = ['canvas_group_id', 'canvas_user_id']
headers = header_creator(header_names, canvas_headers)
gm = root_account.all_groups.
select("group_id, sis_source_id, group_memberships.user_id, pseudonyms.sis_user_id AS user_sis_id,
@ -638,19 +549,11 @@ module AccountReports
end
def xlist
if @sis_format
# headers are not translated on sis_export to maintain import compatibility
headers = ['xlist_course_id', 'section_id', 'status']
else
headers = []
headers << I18n.t('#account_reports.report_header_canvas_xlist_course_id', 'canvas_xlist_course_id')
headers << I18n.t('#account_reports.report_header_xlist_course_id', 'xlist_course_id')
headers << I18n.t('#account_reports.report_header_canvas_section_id', 'canvas_section_id')
headers << I18n.t('#account_reports.report_header_section__id', 'section_id')
headers << I18n.t('#account_reports.report_header_status', 'status')
headers << I18n.t('#account_reports.report_header_canvas_nonxlist_course_id', 'canvas_nonxlist_course_id')
headers << I18n.t('#account_reports.report_header_nonxlist_course_id', 'nonxlist_course_id')
end
header_names = ['xlist_course_id', 'section_id', 'status', 'nonxlist_course_id']
canvas_headers = ['canvas_xlist_course_id', 'canvas_section_id',
'canvas_nonxlist_course_id']
headers = header_creator(header_names, canvas_headers)
@domain_root_account = root_account
xl = root_account.course_sections.
select("course_sections.*, courses.sis_source_id AS course_sis_id,
@ -732,5 +635,16 @@ module AccountReports
end
end
end
def header_creator(header_names, canvas_headers = [])
return header_names if @sis_format
header_names = header_names + canvas_headers
headers = []
header_names.each do |header_name|
headers << I18n.t("#account_reports.report_header_%{header}", "%{header}", header: header_name)
end
headers << I18n.t('created_by_sis')
headers
end
end
end

View File

@ -315,9 +315,9 @@ describe "Default Account Reports" do
parameters["users"] = true
parsed = read_report("sis_export_csv", {params: parameters, header: true, order: 0})
headers = parsed.shift
expect(headers).to eq ['user_id', 'login_id', 'password', 'first_name',
'last_name', 'full_name', 'sortable_name',
'short_name', 'email', 'status']
expect(headers).to eq ['user_id', 'integration_id','authentication_provider_id',
'login_id', 'password', 'first_name', 'last_name',
'full_name', 'sortable_name', 'short_name', 'email', 'status']
expect(parsed.length).to eq 4
expect(parsed[0]).to eq ["user_sis_id_01", "john@stclair.com", nil,
@ -384,9 +384,11 @@ describe "Default Account Reports" do
parsed = read_report("provisioning_csv", {params: parameters, order: [1, 2], header: true})
headers = parsed.shift
expect(headers).to eq ["canvas_user_id", "user_id", "login_id",
expect(headers).to eq ["user_id", "integration_id",
"authentication_provider_id", "login_id", "password",
"first_name", "last_name", "full_name",
"sortable_name", "short_name", "email", "status", "created_by_sis"]
"sortable_name", "short_name", "email", "status",
"canvas_user_id", "created_by_sis"]
expect(parsed.length).to eq 6
expect(parsed[0]).to eq [@user6.id.to_s, nil, "john@smith.com", "John",
@ -1055,7 +1057,7 @@ describe "Default Account Reports" do
expect(report.parameters['extra_text']).to eq "Term: Default Term; Reports: xlist "
parsed = parse_report(report, {header: true})
headers = parsed.shift
expect(headers).to eq ['xlist_course_id', 'section_id', 'status']
expect(headers).to eq ['xlist_course_id', 'section_id', 'status', 'nonxlist_course_id']
expect(parsed[0]).to eq ["SIS_COURSE_ID_2","english_section_1","active"]
expect(parsed.length).to eq 1
end
@ -1195,18 +1197,20 @@ describe "Default Account Reports" do
expect(parsed["accounts.csv"]).to eq [["account_id", "parent_account_id", "name", "status"]]
expect(parsed["terms.csv"]).to eq [["term_id", "name", "status", "start_date", "end_date"]]
expect(parsed["users.csv"]).to eq [['user_id', 'login_id', 'password', 'first_name',
'last_name', 'full_name', 'sortable_name',
'short_name', 'email', 'status']]
expect(parsed["courses.csv"]).to eq [["course_id", "short_name", "long_name", "account_id",
"term_id", "status", "start_date", "end_date"]]
expect(parsed["sections.csv"]).to eq [["section_id", "course_id", "name", "status",
"start_date", "end_date"]]
expect(parsed["users.csv"]).to eq [['user_id', 'integration_id', 'authentication_provider_id',
'login_id', 'password', 'first_name', 'last_name',
'full_name', 'sortable_name', 'short_name', 'email', 'status']]
expect(parsed["courses.csv"]).to eq [["course_id", "integration_id", "short_name", "long_name",
"account_id", "term_id", "status", "start_date", "end_date"]]
expect(parsed["sections.csv"]).to eq [["section_id", "course_id", "integration_id", "name", "status",
"start_date", "end_date", "account_id"]]
expect(parsed["enrollments.csv"]).to eq [["course_id", "user_id", "role", "role_id", "section_id",
"status", "associated_user_id", "limit_section_privileges"]]
expect(parsed["groups.csv"]).to eq [["group_id", "account_id", "name", "status"]]
"status", "associated_user_id", "base_role_type",
"limit_section_privileges"]]
expect(parsed["groups.csv"]).to eq [["group_id", "account_id", "name", "status", "context_id",
"context_type", "group_category_id"]]
expect(parsed["group_membership.csv"]).to eq [["group_id", "user_id", "status"]]
expect(parsed["xlist.csv"]).to eq [["xlist_course_id", "section_id", "status"]]
expect(parsed["xlist.csv"]).to eq [["xlist_course_id", "section_id", "status", "nonxlist_course_id"]]
end
it "should not return reports passed as false" do
@ -1224,15 +1228,16 @@ describe "Default Account Reports" do
expect(parsed["accounts.csv"]).to eq nil
expect(parsed["terms.csv"]).to eq [["term_id", "name", "status", "start_date", "end_date"]]
expect(parsed["users.csv"]).to eq [['user_id', 'login_id', 'password', 'first_name',
'last_name', 'full_name', 'sortable_name',
'short_name', 'email', 'status']]
expect(parsed["users.csv"]).to eq [['user_id', 'integration_id', 'authentication_provider_id',
'login_id', 'password', 'first_name', 'last_name',
'full_name', 'sortable_name', 'short_name', 'email', 'status']]
expect(parsed["courses.csv"]).to eq nil
expect(parsed["sections.csv"]).to eq nil
expect(parsed["enrollments.csv"]).to eq nil
expect(parsed["groups.csv"]).to eq [["group_id", "account_id", "name", "status"]]
expect(parsed["groups.csv"]).to eq [["group_id", "account_id", "name",
"status", "context_id", "context_type", "group_category_id"]]
expect(parsed["group_membership.csv"]).to eq [["group_id", "user_id", "status"]]
expect(parsed["xlist.csv"]).to eq [["xlist_course_id", "section_id", "status"]]
expect(parsed["xlist.csv"]).to eq [["xlist_course_id", "section_id", "status", "nonxlist_course_id"]]
end
end
end