Skip to content
Snippets Groups Projects

Add Import Source Users to GraphQL

Merged Rodrigo Tomonari requested to merge rodrigo/add-import-user-source-graphql into master
1 unresolved thread

What does this MR do and why?

Add resolver to return all import source users associated with a namespace

Add mutations to manage import source users

  • Cancel reassignment
  • Reassign
  • Keep as placeholder

Related to: #457066 (closed)

SQL queries

Raw SQL
SELECT
    "import_source_users".*
FROM
    "import_source_users"
WHERE
    "import_source_users"."namespace_id" = 1
ORDER BY
    "import_source_users"."id" DESC
LIMIT 101
Query plan

https://console.postgres.ai/gitlab/gitlab-production-main/sessions/29382/commands/91420

 Limit  (cost=0.01..0.02 rows=1 width=218) (actual time=0.043..0.043 rows=0 loops=1)
   Buffers: shared hit=3
   I/O Timings: read=0.000 write=0.000
   ->  Sort  (cost=0.01..0.02 rows=1 width=218) (actual time=0.041..0.042 rows=0 loops=1)
         Sort Key: import_source_users.id DESC
         Sort Method: quicksort  Memory: 25kB
         Buffers: shared hit=3
         I/O Timings: read=0.000 write=0.000
         ->  Seq Scan on public.import_source_users  (cost=0.00..0.00 rows=1 width=218) (actual time=0.008..0.009 rows=0 loops=1)
               Filter: (import_source_users.namespace_id = 9970)
               Rows Removed by Filter: 0
               I/O Timings: read=0.000 write=0.000

Time: 0.995 ms  
  - planning: 0.880 ms  
  - execution: 0.115 ms  
    - I/O read: 0.000 ms  
    - I/O write: 0.000 ms  
  
Shared buffers:  
  - hits: 3 (~24.00 KiB) from the buffer pool  
  - reads: 0 from the OS file cache, including disk I/O  
  - dirtied: 0  
  - writes: 0  

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.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Edited by Rodrigo Tomonari

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Rodrigo Tomonari
  • Luke Duncalfe
  • Luke Duncalfe
  • Luke Duncalfe
  • Luke Duncalfe
  • Luke Duncalfe
  • Luke Duncalfe
  • Luke Duncalfe
  • Luke Duncalfe removed review request for @.luke

    removed review request for @.luke

  • Sam Word mentioned in merge request !156352 (merged)

    mentioned in merge request !156352 (merged)

  • added 1 commit

    • 4a9e16a7 - Apply 15 suggestion(s) to 5 file(s)

    Compare with previous version

  • added 4 commits

    • 23fbd606 - Transform current_user in a keyword argument
    • 6b4c4e35 - Change authorization specs
    • a2b14526 - Rename mutation and events from assign to reassign
    • 9950f723 - Use import type enum

    Compare with previous version

  • Rodrigo Tomonari requested review from @.luke

    requested review from @.luke

  • mentioned in issue #468506 (closed)

  • mentioned in issue #468437 (closed)

  • Luke Duncalfe approved this merge request

    approved this merge request

  • added pipelinetier-2 label and removed pipelinetier-1 label

    • Resolved by Rodrigo Tomonari

      Before you set this MR to auto-merge

      This merge request will progress on pipeline tiers until it reaches the last tier: pipelinetier-3. We will trigger a new pipeline for each transition to a higher tier.

      Before you resolve this discussion, please check the following:

      • You are the last maintainer of this merge request
      • The latest pipeline for this merge request is pipelinetier-3 (You can find which tier it is in the pipeline name)
      • This pipeline is recent enough (created in the last 8 hours)

      If all the criteria above apply, please resolve this discussion and the set auto-merge for this merge request.

      See pipeline tiers and merging a merge request for more details.

  • Luke Duncalfe requested review from @eread

    requested review from @eread

  • Luke Duncalfe requested review from @l.rosa and @jnutt and removed review request for @.luke

    requested review from @l.rosa and @jnutt and removed review request for @.luke

  • Evan Read removed review request for @eread

    removed review request for @eread

  • :tools: Generated by gitlab_quality-test_tooling.


    :snail: Slow tests detected in this merge request. These slow tests might be related to this merge request's changes.

    Click to expand
    Job File Name Duration Expected duration
    #7167445443 spec/features/admin/users/users_spec.rb#L177 Admin::Users GET /admin/users when blocking/unblocking a user shows confirmation and allows blocking and unblocking 66.57 s < 50.13 s
    #7173915548 spec/features/admin/users/users_spec.rb#L177 Admin::Users GET /admin/users when blocking/unblocking a user shows confirmation and allows blocking and unblocking 66.53 s < 50.13 s
    #7175248768 spec/features/admin/users/users_spec.rb#L177 Admin::Users GET /admin/users when blocking/unblocking a user shows confirmation and allows blocking and unblocking 66.48 s < 50.13 s
    #7176593683 spec/features/admin/users/users_spec.rb#L177 Admin::Users GET /admin/users when blocking/unblocking a user shows confirmation and allows blocking and unblocking 66.79 s < 50.13 s
    #7182591752 spec/features/admin/users/users_spec.rb#L177 Admin::Users GET /admin/users when blocking/unblocking a user shows confirmation and allows blocking and unblocking 66.79 s < 50.13 s
    #7183496661 spec/features/admin/users/users_spec.rb#L177 Admin::Users GET /admin/users when blocking/unblocking a user shows confirmation and allows blocking and unblocking 66.43 s < 50.13 s
    #7194752893 spec/features/admin/users/users_spec.rb#L177 Admin::Users GET /admin/users when blocking/unblocking a user shows confirmation and allows blocking and unblocking 68.19 s < 50.13 s
    #7194953840 spec/features/admin/users/users_spec.rb#L177 Admin::Users GET /admin/users when blocking/unblocking a user shows confirmation and allows blocking and unblocking 66.08 s < 50.13 s
    #7196061203 spec/features/admin/users/users_spec.rb#L177 Admin::Users GET /admin/users when blocking/unblocking a user shows confirmation and allows blocking and unblocking 65.98 s < 50.13 s
    #7197779249 spec/features/admin/users/users_spec.rb#L177 Admin::Users GET /admin/users when blocking/unblocking a user shows confirmation and allows blocking and unblocking 65.16 s < 50.13 s
    #7202418613 spec/features/admin/users/users_spec.rb#L177 Admin::Users GET /admin/users when blocking/unblocking a user shows confirmation and allows blocking and unblocking 65.75 s < 50.13 s
    #7203822796 spec/features/admin/users/users_spec.rb#L177 Admin::Users GET /admin/users when blocking/unblocking a user shows confirmation and allows blocking and unblocking 66.37 s < 50.13 s
  • A deleted user added rspec:slow test detected label
  • E2E Test Result Summary

    allure-report-publisher generated test report!

    e2e-test-on-gdk: :white_check_mark: test report for 5ab04427

    expand test summary
    +------------------------------------------------------------------+
    |                          suites summary                          |
    +-------------+--------+--------+---------+-------+-------+--------+
    |             | passed | failed | skipped | flaky | total | result |
    +-------------+--------+--------+---------+-------+-------+--------+
    | Create      | 126    | 0      | 11      | 0     | 137   | ✅     |
    | Verify      | 36     | 0      | 2       | 0     | 38    | ✅     |
    | Plan        | 60     | 0      | 2       | 0     | 62    | ✅     |
    | Data Stores | 27     | 0      | 4       | 0     | 31    | ✅     |
    | Govern      | 65     | 0      | 0       | 0     | 65    | ✅     |
    | Release     | 5      | 0      | 0       | 0     | 5     | ✅     |
    | Analytics   | 2      | 0      | 0       | 0     | 2     | ✅     |
    | Package     | 19     | 0      | 12      | 0     | 31    | ✅     |
    | Monitor     | 8      | 0      | 0       | 0     | 8     | ✅     |
    | Fulfillment | 1      | 0      | 0       | 0     | 1     | ✅     |
    | Manage      | 0      | 0      | 1       | 0     | 1     | ➖     |
    +-------------+--------+--------+---------+-------+-------+--------+
    | Total       | 349    | 0      | 32      | 0     | 381   | ✅     |
    +-------------+--------+--------+---------+-------+-------+--------+

    e2e-test-on-cng: :x: test report for 5ab04427

    expand test summary
    +------------------------------------------------------------------+
    |                          suites summary                          |
    +-------------+--------+--------+---------+-------+-------+--------+
    |             | passed | failed | skipped | flaky | total | result |
    +-------------+--------+--------+---------+-------+-------+--------+
    | Package     | 23     | 0      | 15      | 0     | 38    | ✅     |
    | Create      | 135    | 0      | 15      | 0     | 150   | ✅     |
    | Govern      | 77     | 0      | 9       | 0     | 86    | ✅     |
    | Plan        | 78     | 1      | 11      | 0     | 90    | ❌     |
    | Data Stores | 30     | 0      | 13      | 0     | 43    | ✅     |
    | Monitor     | 8      | 0      | 12      | 0     | 20    | ✅     |
    | Verify      | 53     | 0      | 13      | 0     | 66    | ✅     |
    | Analytics   | 2      | 0      | 0       | 0     | 2     | ✅     |
    | Fulfillment | 2      | 0      | 24      | 0     | 26    | ✅     |
    | Secure      | 2      | 1      | 2       | 1     | 5     | ❌     |
    | ModelOps    | 0      | 0      | 1       | 0     | 1     | ➖     |
    | Configure   | 0      | 0      | 3       | 0     | 3     | ➖     |
    | Release     | 5      | 0      | 1       | 0     | 6     | ✅     |
    | Ai-powered  | 0      | 0      | 1       | 0     | 1     | ➖     |
    | Growth      | 0      | 0      | 2       | 0     | 2     | ➖     |
    | Manage      | 2      | 0      | 8       | 0     | 10    | ✅     |
    +-------------+--------+--------+---------+-------+-------+--------+
    | Total       | 417    | 2      | 130     | 1     | 549   | ❌     |
    +-------------+--------+--------+---------+-------+-------+--------+

    e2e-package-and-test: :x: test report for 5ab04427

    expand test summary
    +-------------------------------------------------------------+
    |                       suites summary                        |
    +--------+--------+--------+---------+-------+-------+--------+
    |        | passed | failed | skipped | flaky | total | result |
    +--------+--------+--------+---------+-------+-------+--------+
    | Manage | 29     | 1      | 15      | 1     | 45    | ❌     |
    | Create | 276    | 4      | 30      | 6     | 310   | ❌     |
    | Plan   | 8      | 0      | 0       | 0     | 8     | ✅     |
    | Govern | 4      | 0      | 0       | 0     | 4     | ✅     |
    +--------+--------+--------+---------+-------+-------+--------+
    | Total  | 317    | 5      | 45      | 7     | 367   | ❌     |
    +--------+--------+--------+---------+-------+-------+--------+
  • added 2 commits

    • b0a80e53 - Fix under coverage specs
    • 426d02c1 - Change import source type description

    Compare with previous version

  • Rodrigo Tomonari reset approvals from @.luke by pushing to the branch

    reset approvals from @.luke by pushing to the branch

  • James Nutt
  • James Nutt
  • James Nutt
  • James Nutt
  • James Nutt
  • James Nutt
  • James Nutt
  • James Nutt
  • James Nutt
  • James Nutt
  • Leonardo da Rosa
  • added 1 commit

    • fdbf57fa - Apply 2 suggestion(s) to 2 file(s)

    Compare with previous version

  • Rodrigo Tomonari changed the description

    changed the description

  • added 1 commit

    Compare with previous version

  • James Nutt
  • James Nutt
  • James Nutt approved this merge request

    approved this merge request

  • James Nutt requested review from @.luke and removed review request for @jnutt

    requested review from @.luke and removed review request for @jnutt

  • added 1 commit

    • 0fa4b618 - Apply code review suggestions

    Compare with previous version

  • Rodrigo Tomonari reset approvals from @jnutt by pushing to the branch

    reset approvals from @jnutt by pushing to the branch

  • added 1 commit

    Compare with previous version

  • Rodrigo Tomonari requested review from @eread

    requested review from @eread

  • Leonardo da Rosa approved this merge request

    approved this merge request

  • requested review from @DylanGriffith

  • Leonardo da Rosa removed review request for @l.rosa

    removed review request for @l.rosa

  • Luke Duncalfe approved this merge request

    approved this merge request

  • Evan Read
  • Evan Read
  • Evan Read
  • Evan Read
  • Evan Read
  • Evan Read
  • Evan Read removed review request for @eread

    removed review request for @eread

  • Dylan Griffith approved this merge request

    approved this merge request

  • added databaseapproved label and removed databasereviewed label

  • Dylan Griffith removed review request for @DylanGriffith

    removed review request for @DylanGriffith

  • added 1 commit

    • 2b596f7f - Apply 5 suggestion(s) to 1 file(s)

    Compare with previous version

  • Rodrigo Tomonari reset approvals from @DylanGriffith, @.luke, and @l.rosa by pushing to the branch

    reset approvals from @DylanGriffith, @.luke, and @l.rosa by pushing to the branch

  • added 1 commit

    • e5b47fa0 - Add import_source_users to Graphql

    Compare with previous version

  • Rodrigo Tomonari requested review from @eread

    requested review from @eread

  • added 1 commit

    • 5601bd69 - Add import_source_users to Graphql

    Compare with previous version

  • Evan Read
  • Evan Read approved this merge request

    approved this merge request

  • Evan Read removed review request for @eread

    removed review request for @eread

  • added 1 commit

    • 4e654d9d - Apply 1 suggestion(s) to 1 file(s)

    Compare with previous version

  • Dylan Griffith approved this merge request

    approved this merge request

  • added 1 commit

    Compare with previous version

  • Rodrigo Tomonari resolved all threads

    resolved all threads

  • Rodrigo Tomonari reset approvals from @eread by pushing to the branch

    reset approvals from @eread by pushing to the branch

  • James Nutt approved this merge request

    approved this merge request

  • requested review from @alexbuijs

  • Alex Buijs
  • Alex Buijs approved this merge request

    approved this merge request

  • Alex Buijs removed review request for @alexbuijs

    removed review request for @alexbuijs

  • added pipelinetier-3 label and removed pipelinetier-2 label

  • Rodrigo Tomonari resolved all threads

    resolved all threads

  • Rodrigo Tomonari resolved all threads

    resolved all threads

  • James Nutt enabled automatic add to merge train when the pipeline for f9e8ed9f succeeds

    enabled automatic add to merge train when the pipeline for f9e8ed9f succeeds

  • James Nutt added this merge request to the merge train at position 2

    added this merge request to the merge train at position 2

  • merged

  • Hello @rodrigo.tomonari :wave:

    The database team is looking for ways to improve the database review process and we would love your help!

    If you'd be open to someone on the database team reaching out to you for a chat, or if you'd like to leave some feedback asynchronously, just post a reply to this comment mentioning:

    @gitlab-org/database-team

    And someone will be by shortly!

    Thanks for your help! :heart:

    This message was generated automatically. You're welcome to improve it.

  • added workflowstaging label and removed workflowcanary label

  • mentioned in issue #477423 (closed)

  • 15 loads: Types::UserType,
    16 description: 'Global ID of the assignee user.'
    17
    18 field :import_source_user,
    19 Types::Import::SourceUserType,
    20 null: true,
    21 description: "Mapping of a user on source instance to a user on destination instance after mutation."
    22
    23 authorize :admin_import_source_user
    24
    25 def resolve(args)
    26 if Feature.disabled?(:bulk_import_user_mapping, current_user)
    27 raise_resource_not_available_error! '`bulk_import_user_mapping` feature flag is disabled.'
    28 end
    29
    30 import_source_user = authorized_find!(id: args[:id])
    • @rodrigo.tomonari I don't see any authorization to ensure that the namespace admin can only send reassignment emails to source users created in their own namespace. Am I missing something? return error_invalid_permissions unless current_user.can?(:admin_import_source_user, import_source_user) is the only authorization code I could find in reassign_service.rb below, which only authorizes the admin, not the recipient.

      /cc @wortschi

    • @ameyadarshan, the authorization is being performed twice, once at the GraphQL mutation level and once at the service level. In both cases the rule admin_import_source_user is used.

      If you analyze the condition of the rule, you will see that the user needs to be able to administrate the import_source_user.namespace (@subject.namespace)

    • Please register or sign in to reply
  • Please register or sign in to reply
    Loading