Skip to content

Refactor specific ProvisionCodeSuggestionsService to general ProvisionAddOnService

What does this MR do and why?

In preparation for being able to provision the Duo Enterprise add-on, we refactor the GitlabSubscription::AddOnPurchases::SelfManaged::ProvisionCodeSuggestionsService to GitlabSubscription::AddOnPurchases::SelfManaged::ProvisionAddOnService which will then be able to provision the code_suggestion and the new duo_enterprise add-on. An example of future usage could be:

license.duo_add_ons_included.each do |add_on|
   GitlabSubscription::AddOnPurchases::SelfManaged::ProvisionAddOnService.for_add_on(add_on).execute
end

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.

How to set up and validate locally

Requirements

  • Local GitLab and CDot instance
  • Experience purchasing licenses at CDot

Testing

This refactoring shouldn't change any behavior. To test that the provision service for the code suggestion add-on is still working, there are three codes paths to test:

  1. Start your GitLab instance with export GITLAB_SIMULATE_SAAS=0
  2. Purchase a self-managed ultimate license at your local CDot installation and add it to your GitLab instance.
  3. First path to test:
    1. Go to http://localhost:3000/admin/code_suggestions and check the amount of GitLab Duo Pro seats you purchased
    2. Go to http://localhost:5000/ and purchase another GitLab Duo Pro seat for the currently activated subscription/license.
    3. Go to http://localhost:3000/admin/subscription and click on the refresh button next to Last sync
    4. Check on http://localhost:3000/admin/code_suggestions that a CTA for purchasing Duo Pro seats gets displayed or that a 404 gets raised
  4. Second path to test:
    1. Go to http://localhost:3000/admin/code_suggestions and check the amount of GitLab Duo Pro seats you purchased
    2. Go to http://localhost:3000/admin/subscription and click on Remove license
    3. Check on http://localhost:3000/admin/code_suggestions that the number of GitLab Duo Pro has gone to zero
  5. Third path to test:
    1. Add Duo Pro seats to your subscription at CDot.
    2. Remove all existing licenses at your GitLab instances.
    3. Go to http://localhost:3000/admin/subscription and paste your purchased license activation code and click Activate
    4. Check on http://localhost:3000/admin/code_suggestions that the Duo Pro seats got synchronized and the site is not raising a 404

Related to #470073

Edited by Lukas Wanko

Merge request reports

Loading