Allow auto enable Duo Core feature setting via seat link sync
What does this MR do and why?
Prior to this change, the Duo Core features setting were always auto enabled whenever an instance was activated. This didn't cover auto enabling the setting for early activations of future dated subscriptions.
This change adds the auto enabling of the Duo Core features setting to the seat link sync to cover the early activations of future dated subscriptions. At the same time, the shared logic for updating future subscriptions, provisioning add-on purchases and updating those setting are moved to a dedicated service to maintain the logic in one place instead of in two places.
There's also a change in behavior when updating the setting. It is only updated when the current value is nil. It will no longer always be auto enabled during activations. This also align the auto enable behavior with the one for GL.com that didn't have a similar entry point for a subscription start like the SM activation.
References
https://gitlab.com/gitlab-org/gitlab/-/issues/539504+
How to set up and validate locally
Pre-requisites:
- You'll need to checkout the branch of https://gitlab.com/gitlab-org/customers-gitlab-com/-/merge_requests/12517+ if that MR hasn't been merged yet.
- Set
Ai::Setting.instance.duo_nano_features_enabledtonil:setting = Ai::Setting.instance; setting.duo_nano_features_enabled = nil; setting.save(validate: false). - Run GDK/GitLab as SM (the ENV
GITLAB_SIMULATE_SAASshould be empty).
Testing steps:
- Zuora: Create a new SM Premium or Ultimate subscription.
- ZSim: Process the Zuora callout.
- CDot: Open the Rails console.
-
CDot console: Copy the activation code:
CloudActivation.last.activation_code - GDK/GitLab: Activate your instance.
- GDK/GitLab: Open the Rails console.
-
GDK/GitLab: Verify the Duo Core features setting was enabled (value should be
true):Ai::Setting.instance.duo_nano_features_enabled(you can also verify this via the UI in the Duo settings). -
GDK/GitLab: Trigger a seat link sync and verify the setting value again to be still
true. -
GDK/GitLab: Update the setting value to
nilagain:setting = Ai::Setting.instance; setting.duo_nano_features_enabled = nil; setting.save(validate: false) -
GDK/GitLab: Trigger a seat link sync and verify the setting value is
trueagain. -
GDK/GitLab: Update the setting value to
false:setting = Ai::Setting.instance; setting.update(duo_nano_features_enabled: false) -
GDK/GitLab: Trigger a seat link sync and verify the setting value is still
false. -
GDK/GitLab: Update the setting value to
nilagain:setting = Ai::Setting.instance; setting.duo_nano_features_enabled = nil; setting.save(validate: false) - GDK/GitLab: Remove all licenses (otherwise the seat link sync will auto enable the Duo Core setting)
- Zuora: Create a new future dated SM Premium or Ultimate subscription (like 1-2 days in the future).
- ZSim: Process the Zuora callout.
-
CDot console: Copy the activation code:
CloudActivation.last.activation_code - GDK/GitLab: Activate your instance.
-
GDK/GitLab: Verify the Duo Core features setting is still
nil:Ai::Setting.instance.duo_nano_features_enabled
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.