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:

  1. 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.
  2. Set Ai::Setting.instance.duo_nano_features_enabled to nil: setting = Ai::Setting.instance; setting.duo_nano_features_enabled = nil; setting.save(validate: false).
  3. Run GDK/GitLab as SM (the ENV GITLAB_SIMULATE_SAAS should be empty).

Testing steps:

  1. Zuora: Create a new SM Premium or Ultimate subscription.
  2. ZSim: Process the Zuora callout.
  3. CDot: Open the Rails console.
  4. CDot console: Copy the activation code: CloudActivation.last.activation_code
  5. GDK/GitLab: Activate your instance.
  6. GDK/GitLab: Open the Rails console.
  7. 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).
  8. GDK/GitLab: Trigger a seat link sync and verify the setting value again to be still true.
  9. GDK/GitLab: Update the setting value to nil again: setting = Ai::Setting.instance; setting.duo_nano_features_enabled = nil; setting.save(validate: false)
  10. GDK/GitLab: Trigger a seat link sync and verify the setting value is true again.
  11. GDK/GitLab: Update the setting value to false: setting = Ai::Setting.instance; setting.update(duo_nano_features_enabled: false)
  12. GDK/GitLab: Trigger a seat link sync and verify the setting value is still false.
  13. GDK/GitLab: Update the setting value to nil again: setting = Ai::Setting.instance; setting.duo_nano_features_enabled = nil; setting.save(validate: false)
  14. GDK/GitLab: Remove all licenses (otherwise the seat link sync will auto enable the Duo Core setting)
  15. Zuora: Create a new future dated SM Premium or Ultimate subscription (like 1-2 days in the future).
  16. ZSim: Process the Zuora callout.
  17. CDot console: Copy the activation code: CloudActivation.last.activation_code
  18. GDK/GitLab: Activate your instance.
  19. 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.

Edited by Corinna Gogolok

Merge request reports

Loading