Use read_project_secrets to check if secrets manager CTA can link to page

What does this MR do and why?

Instead of checking ::SecretsManagement::Availability.for_project? for if we are linking the CTA to a 404 (the secrets manager is not available to the user), we should be checking can?(current_user, :read_project_secrets, project) instead since this is the destination page's own gate.

The Availability check ignores both the entitlement rules and the user's role, so this can open up a bug where the secrets manager is technically available but not accessible to the user. For example, when secrets manager is enrolled and entitlement state is trial_eligible (which can happen when the project is part of the beta-cohort, or if the add-on/trial button chain mutation only partially succeeded, such that the enrollment mutation succeeded but the trial mutation failed).

References

Bug fix for https://gitlab.com/gitlab-org/gitlab/-/work_items/627449 (refines !260653 (merged))

Screenshots or screen recordings

Before After

How to set up and validate locally

  1. Run gdk in SaaS mode and follow the validation steps in !258447 (merged)
  2. Make sure the entitlement state is trial_eligible. Add an enrollment row without starting a trial or enabling the add-on:
    group = Group.find_by_name 'group-name'
    SecretsManagement::NamespaceEnrollment.create!(namespace: group, beta: false)
  3. Visit the vulnerability page and verify that the CTA now links to the settings page

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 Mireya Andres

Merge request reports

Loading
Loading