Skip to content

Allow group transfers to go over free user cap

Doug Stull requested to merge 417728-allow-transfer-group-to-work into master

What does this MR do and why?

Allow group transfers to go over the free user cap limit when the group/subgroup-to-be-tranferred qualifies for free user cap. See issue this is solving in #417728 (closed) and the reproduction steps below.

We needed to fix the issue of a transferred group being owner-less in conditions described in #417728 (closed) and detailed in the approach to fix that in #417728 (comment 1467451207)

Approach in this MR was to be as targeted as possible to ee only(where free user cap exists) and SaaS(by checking free user cap eligibility). This enables us to explain-through-code to future readers of the code why this was done a bit better and keeps us from leaking ee concerns into foss or non group member areas.

Screenshots or screen recordings

page Before After
redirection after clicking transfer as non-admin Screenshot_2023-07-13_at_9.16.20_AM Screenshot_2023-07-13_at_9.20.25_AM
group members page after transfer as admin(or non admin for after) Screenshot_2023-07-13_at_8.59.36_AM Screenshot_2023-07-13_at_9.20.40_AM

How to set up and validate locally

  1. Enable free user cap and free user cap on new namespaces in bundle exec rails c
    Feature.enable(:free_user_cap)
    Feature.enable(:free_user_cap_new_namespaces)
  2. Setup initial application settings in bundle exec rails c (false initially so we can get over the user cap limit)
    ApplicationSetting.first.update(dashboard_limit_enabled: false, dashboard_limit: 5, dashboard_enforcement_limit: 5)
  3. Simulate Saas and restart GDK
  4. Log in as a non-admin(admin could be used too, but will not see the not-found page on transfer which is ok, would then just have to validate members on the transferred group)
  5. Create a new top-level private group
  6. Create a private subgroup in that group.
  7. Go to the members page of that subgroup and in the search switch to searching for direct membership type.
  8. Remove the only direct membership there(should be your logged in account)
  9. Go back to that subgroup and verify there are no more direct memberships(should be an inherited one of your logged in account)
  10. Create a new private project in that subgroup. Note: Visibility of private shouldn't matter here, just doing that here to match group.
  11. Add at least 6 members to that project(can be any role).
  12. Turn on the free user cap in the application settings in bundle exec rails c.
    ApplicationSetting.first.update(dashboard_limit_enabled: true)
  13. Reload the page and verify you see the danger alert on the subgroup level. Note: this may take a few minutes to destroy cache and become effective.
  14. On the subgroup, go to the > Settings -> General -> Advanced -> Transfer Group
  15. In Select parent group, select No parent group and click Transfer group
  16. On the newly tranferred-to-top-level group, go to the group members and verify your logged in account is a owner and that you see the read-only danger alert about being over free user limit.
  17. Compare this experience to master branch if desired(should see the not-found page as a non admin after clicking Transfer group and as admin you'd have access to the subgroup and could verify there are no group members on the newly transferred group)

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #417728 (closed)

Edited by Doug Stull

Merge request reports