Skip to content

Associate new users to enterprise group if they meet the condition

What does this MR do and why?

Related to #388410 (closed)

This MR initiates the Enterprise Users Automatic Claim Process for newly created users.

This change is under enterprise_users_automatic_claim FF.

Additionally, enabling enterprise_users_automatic_claim FF

See #388410 (closed) description for details and for "why?".

How to set up and validate locally

  1. Familiarize with the Enterprise User definition to understand what context you should prepare in your GitLab instance for testing
  2. Enable enterprise_users_automatic_claim FF. Guide: https://docs.gitlab.com/ee/administration/feature_flags.html#enable-or-disable-the-feature
  3. Make sure the GitLab instance simulates or a SaaS instance since Enterprise Users is a SaaS feature.
  4. Create a top-level paid group with Premium subscription as a minimum
  5. Set up a verified domain for the group, docs: https://docs.gitlab.com/ee/user/enterprise_user/#set-up-a-verified-domain
  6. Create new provisioned by the group user on the GitLab instance with email that has the verified domain from the previous step by using SCIM or SAML flow
  7. Confirm that Groups::EnterpriseUsers::AssociateWorker has been scheduled and completed for the newly created user
  8. Add this user to the group's members if they are not added automatically
  9. Confirm that the user hasn't received provisioned_member_access_granted_email
  10. Confirm that the user has received member_access_granted_email
  11. Confirm that the user has received user_associated_with_enterprise_group_email
  12. Additionally, you can check logs. 'Associated the user with the enterprise group' log entry should be added with the context data, like user_id and group_id
  13. You can also check from the rails console User.find_by(email: 'EMAIL-HERE').user_detail.enterprise_group_id attribute. Its value should be the same as the group's id

Since the Enterprise User definition consists of lots of items, we could reproduce lots of cases. You can read the specs https://gitlab.com/gitlab-org/gitlab/-/blob/af58ea0f4110b277120e8c45cbcc59d70c8a5ed9/ee/spec/services/groups/enterprise_users/associate_service_spec.rb for detail.

Edited by Bogdan Denkovych

Merge request reports

Loading