Skip to content

Update Service account subscription check to include Gold subscription

What does this MR do and why?

Update Service account subscription check to include Gold subscription

  • EE ultimate? checks for both Ultimate and Gold Plan
  • Added related tests

Related to: https://gitlab.com/gitlab-org/gitlab/-/issues/570339

Changelog: added
EE: true

References

Main issue: https://gitlab.com/gitlab-org/gitlab/-/issues/570339

Screenshots or screen recordings

Before After
image image

Additional evidences

[ gstg ] production> org = Namespace.find(9970)
=> #<Group id:9970 @gitlab-org>
[ gstg ] production> org.name
=> "GitLab.org"
[ gstg ] production> org.gitlab_subscription.hosted_plan&.name
=> "gold"
[ gstg ] production> org.gitlab_subscription.seats
=> 0
[ gstg ] production> com.provisioned_users.service_account.count
=> 0

[ gstg ] production> com = Namespace.find(6543)
=> #<Group id:6543 @gitlab-com>
[ gstg ] production> com.name
=> "GitLab.com"
[ gstg ] production> com.gitlab_subscription.hosted_plan&.name
=> "gold"
[ gstg ] production> com.gitlab_subscription.seats
=> 0
[ gstg ] production> com.provisioned_users.service_account.count
=> 0

How to set up and validate locally

Via UI

  • Set application to run as SaaS (export GITLAB_SIMULATE_SAAS=1)
  • Create a new Group
  • Assign a Gold subscription
  • Within the new group, go to Settings -> Service Account
  • Try create a new Service Account

Without the fix: 400 Bad request - No more seats are available to create Service Account User error.
With the fix the service account is created correctly.

See screenshots.

Via API

  • Create group access token with: api scope, owner role
  • Ensure Allow top-level group owners to create Service accounts. is set under Admin -> Settings -> General -> Account and Limit -> "Service account creation"
curl --request POST \
  --header "PRIVATE-TOKEN: <your group access token>" \
  --header "Content-Type: application/json" \
  --data '{"name":"My Service Account","username":"service_account_via_api"}' \
  "http://gdk.test:3000/api/v4/groups/123/service_accounts"
{"id":94,"username":"service_account_via_api","public_email":null,"name":"My Service Account","email":"service_account_group_123_1fc43606c78253429894aed9bd9c9b98@noreply.gdk.test"}%

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 Daniele Bracciani

Merge request reports

Loading