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
- disables sending provisioned_member_access_granted_email
- enables sending member_access_granted_email to users, regardless they are provisioned or not
See #388410 (closed) description for details and for "why?".
How to set up and validate locally
- Familiarize with the Enterprise User definition to understand what context you should prepare in your GitLab instance for testing
- Enable
enterprise_users_automatic_claim
FF. Guide: https://docs.gitlab.com/ee/administration/feature_flags.html#enable-or-disable-the-feature - Make sure the GitLab instance simulates or a SaaS instance since Enterprise Users is a SaaS feature.
- Create a top-level paid group with Premium subscription as a minimum
- Set up a verified domain for the group, docs: https://docs.gitlab.com/ee/user/enterprise_user/#set-up-a-verified-domain
- 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
- Confirm that
Groups::EnterpriseUsers::AssociateWorker
has been scheduled and completed for the newly created user - Add this user to the group's members if they are not added automatically
- Confirm that the user hasn't received provisioned_member_access_granted_email
- Confirm that the user has received member_access_granted_email
- Confirm that the user has received user_associated_with_enterprise_group_email
- Additionally, you can check logs.
'Associated the user with the enterprise group'
log entry should be added with the context data, likeuser_id
andgroup_id
- 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