Skip to content

Add CSV export for import source users

James Nutt requested to merge jnutt/export-user-mapping into master

What does this MR do and why?

Add CSV export for import source users

This MR adds a CSV export endpoint for the import source user records associated with the provided namespace.

This change is currently behind the :importer_user_mapping feature flag.

Related issue: #455901

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

This route will be accessible from the UI in the future, but for now it should be accessed directly.

  1. Enable the :importer_user_mapping feature flag.
  2. Create a selection of Import::SourceUser records.
user = User.first
toolbox = Group.find_by(path: 'toolbox')
flight = Group.find_by(path: 'flightjs')

# Template source user
template = Import::SourceUser.new(
  placeholder_user: user,
  reassign_to_user: user,
  status: 1,
  source_hostname: "example.com",
  import_type: "github",
  reassigned_by_user: user
)

# Create 10 source users on the toolbox group.
1.upto(10) do |num|
  new = template.dup
  new.namespace = toolbox
  new.source_username = "tb#{num}",
  new.source_name = "Toolbox User #{num}",
  new.source_user_identifier = "tbuid#{num}",
  new.save!
end

# Create 10 more source users on the flightjs group.
11.upto(20) do |num|
  new = template.dup
  new.namespace = flight
  new.source_username = "fl#{num}",
  new.source_name = "Flight User #{num}",
  new.source_user_identifier = "fluid#{num}",
  new.save!
end
  1. Download the CSV for the toolbox group.
http://gdk.test:3000/groups/toolbox/-/group_members/bulk_reassignment_file
  1. Confirm that the toolbox users are present in the spreadsheet and the flightjs users are not.
Edited by James Nutt

Merge request reports