Skip to content

Allow guest user seat assignment

Bishwa Hang Rai requested to merge bhr/421662-allow-guest-assignment into master

What does this MR do and why?

Allow guest user seat assignment

With requirement change, we will allow seat assignment to guest users.

How to set up and validate locally

  1. Check out the branch
  2. Create a new root group namespace
  3. Setup some seed records
namespace = Namespace.last
add_on = GitlabSubscriptions::AddOn.find_or_create_by!(name: "code_suggestions") {|e| e.description = "Test"}
add_on_purchase = GitlabSubscriptions::AddOnPurchase.create!(
  add_on: add_on, namespace: namespace, expires_on: 1.month.from_now, quantity: 5, purchase_xid: 'A-S0001'
)
add_on_purchase.to_global_id.to_s # "gid://gitlab/GitlabSubscriptions::AddOnPurchase/9"
user = User.last.to_global_id.to_s # "gid://gitlab/User/85"
namespace.add_guest(user) # add the user as guest

# enable the feature flag
Feature.enable(:hamilton_seat_management)
  1. Go to graphql explorer (logged in as owner/admin): http://gdk.test:3000/-/graphql-explorer, and use following query and variables

mutation {
  userAddOnAssignmentCreate(
    input: {
      userId: "gid://gitlab/User/85",
      addOnPurchaseId: "gid://gitlab/GitlabSubscriptions::AddOnPurchase/9",
    }) {
    errors
    addOnPurchase {
      id
      purchasedQuantity
      assignedQuantity
    }
  }
}
  1. Check that response has no errors errors: []
  2. If we switch the branch to master and try to assign another guest user, it will show: "errors": ["INVALID_USER_MEMBERSHIP"]

MR acceptance checklist

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

Fixes: https://gitlab.com/gitlab-org/gitlab/-/issues/421662

Edited by Bishwa Hang Rai

Merge request reports