Skip to content

Add Duo Enterprise to provision service for add-ons

What does this MR do and why?

This merge request is part of the epic https://gitlab.com/groups/gitlab-org/-/epics/14341+. With this change, we extend the provision add-on service and allow it to handle Duo Enterprise add-ons. The provision service, in the end, gets used when the user synchronizes, removes, or adds a license.

The base of this change is the merge request Refactor specific ProvisionCodeSuggestionsServi... (!157967)

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.

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

How to set up and validate locally

Currently, the synchronization for purchasing Duo Enterprise add-on seats between CDot and GitLab has yet to be completed, so the validation for this merge request has to be executed on the Rails console.

  1. Create a Duo Enterprise add-on

    GitlabSubscriptions::AddOn.create!(
      description: GitlabSubscriptions::AddOn.descriptions[:duo_enterprise]
      name: 'duo_enterprise',
    )
  2. Create a purchase for the new add-on

    GitlabSubscriptions::AddOnPurchase.create!(
      add_on: GitlabSubscriptions::AddOn.last,
      expires_on: 7.days.from_now,
      organization: Organizations::Organization.first,
      purchase_xid: "A-S00000001",
      quantity: 1
    )
  3. Execute provision

    GitlabSubscriptions::AddOnPurchases::SelfManaged::ProvisionAddOnService.for_add_on(:duo_enterprise).execute
  4. As the licenses restriction object in the GitLab project doesn't have the duo_enterprise key yet, the provision service should expire the previously created add-on purchase with the date of yesterday via the GitlabSubscriptions::AddOnPurchases::SelfManaged::ExpireService . To validate this, you can use the following command:

    GitlabSubscriptions::AddOnPurchase.last.expires_on == Time.zone.yesterday

Related to #470472

Edited by Lukas Wanko

Merge request reports