Self-hosted DAP: add check for online license

What does this MR do and why?

This MR updates the permissions logic regarding self-hosted models for DAP feature setting:

References

Follow up to Update policies to support Self-hosted DAP SKU ... (!215456 - merged)

Screenshots or screen recordings

Case After
DAP SKU + offline license

DAP features:

  • Self-Hosted models:
  • GitLab-managed models:

Classic features (no regressions):

  • Self-Hosted models:
  • GitLab-managed models:
DAP SKU + online license N/A
No SKU (Duo Enterprise add-on) + offline

DAP features:

  • Self-Hosted models:
  • GitLab-managed models:

Classic features (no regressions):

  • Self-Hosted models:
  • GitLab-managed models:

No SKU (Duo Enterprise add-on) + online license + beta not enabled

DAP features:

  • Self-Hosted models:
  • GitLab-managed models:

Classic features (no regressions):

  • Self-Hosted models:
  • GitLab-managed models:
No SKU (Duo Enterprise add-on) + online license + beta enabled

DAP features:

  • Self-Hosted models:
  • GitLab-managed models:

Classic features (no regressions):

  • Self-Hosted models:
  • GitLab-managed models:

How to set up and validate locally

Setup:

Duo Enterprise add-on

  • Run GITLAB_SIMULATE_SAAS=0 bundle exec 'rake gitlab:duo:setup'

Self-Hosted DAP add-on

  1. Apply this patch to update the GitLab Duo script:
diff --git a/ee/lib/gitlab/duo/developments/setup.rb b/ee/lib/gitlab/duo/developments/setup.rb
index a4f93beb6cb9..a9178adcf797 100644
--- a/ee/lib/gitlab/duo/developments/setup.rb
+++ b/ee/lib/gitlab/duo/developments/setup.rb
@@ -45,6 +45,8 @@ def create_add_on_purchases!(group: nil)
             # Core already created, nothing more needed
           when 'duo_pro'
             create_add_on_purchase!(group, :code_suggestions, 'C-12345', "Duo Pro add-on added...")
+          when 'self_hosted_dap'
+            create_add_on_purchase!(group, :self_hosted_dap, 'C-12345', "Duo Self Hosted DAP add-on added...")
           else
             # Default to enterprise
             create_add_on_purchase!(group, :duo_enterprise, 'C-98766', "Duo Enterprise add-on added...")
  1. Run GITLAB_SIMULATE_SAAS=0 bundle exec 'rake gitlab:duo:setup["self_hosted_dap"]' to create the add-on
  2. After testing, clean up by running the following in the Rails console:
GitlabSubscriptions::AddOnPurchase.by_add_on_name(:self_hosted_dap).destroy_all

Offline license

  • Update the offline_cloud_license? method in ee/app/models/license.rb

Toggle self-hosted beta features

  • Go to /admin/gitlab_duo/configuration
  • Toggle the Use beta models and features in GitLab Duo Self-Hosted
  • Save settings

Steps:

  • Run GDK on non-SAAS mode: GITLAB_SIMULATE_SAAS=0 gdk start
  • Go to the instance-level model configuration page: admin/gitlab_duo/self_hosted
  • Follow the setup steps to achieve test case and refer to screen recording table above for expected behavior

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.

Merge request reports

Loading