Skip to content

Allow additional minute transfer for Users

Vijay Hawoldar requested to merge vij-fix-user-ci-mins-tranfers into master

What does this MR do?

When transferring the recently added Ci::Minutes::AdditionalPacks between namespaces, the service did not originally cater for namespaces which are a kind of User.

This meant the service would raise an error because user namespaces do not implement owner_ids, which is used to validate ownership between the two given namespaces.

This MR fixes the issue by using the appropriate method depending on the type of namespaces being used.

Screenshots or Screencasts (strongly suggested)

How to setup and validate locally (strongly suggested)

  1. Ensure you have a namespace with some additional minutes:
  group = Group.last
  Ci::Minutes::AdditionalPack.create(namespace: group, number_of_minutes: 1000, purchase_xid: 'testing', expires_at: Date.current + 1.year)
  1. Ensure one of your users is an owner of the group
  user = User.last
  group.add_owner(user)
  1. Attempt to transfer additional minutes between the user and the group
  admin = User.find_by_username("root")
  Ci::Minutes::AdditionalPacks::ChangeNamespaceService.new(admin, group, user.namespace).execute

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Vijay Hawoldar

Merge request reports