Skip to content

Update virtual registry gates to check that virtual registry setting is enabled

What does this MR do and why?

This MR adds in an additional gate to check if the virtual registries setting enabled is set to true:

  • virtual registries base controller
  • Query on the group type to list virtual registries
  • Query to return a virtual registry and the upstream registry
  • Upstream create mutation
  • API shared setup
  • Package registries menu

There are existing checks that we do on the maven virtual registries endpoints (licence, dependency proxy enabled, feature flag and permissions check). This setting for enabled/disabled is something the customer will be able to control in their package and registries setting in the UI to disable virtual registries for a group.

By default it is enabled. In the model the find_for_group method, will initialize a new virtual registries setting object if one does not exist, and the default value is for enabled is true.

NOTE: There is this existing follow up issue to refactor the gates to reduce duplication. There are some tests that could do with less duplication as well. Instead of doing both in the one MR, I will do the refactor after this feature is in.

I have refactored the checks for the gates and added to the model in this MR. The reasons for this are, the performance duo report was returning comments on the usage of the find_for_group calls to the db. So I wanted to utilise the request store to cache the setting for the duration of the request. There is also another MR in review that has refactored these checks into the model, so I have followed the same pattern here.

I will leave any test refactoring for the linked issue.

References

Screenshots or screen recordings

See validation steps below for screenshots

How to set up and validate locally

Setup:

  1. Ensure the below feature flags are enabled and you have activated your EE subscription locally.
  • Feature.enable(:maven_virtual_registry)
  • Feature.enable(:ui_for_virtual_registries)
  1. The default value for the virtual registries setting enabled field is true. So nothing extra needs to be done.
  2. Ensure dependency proxy is enabled (this is also enabled by default).
  3. Ensure you have activated your EE license locally
  4. Log in to http://gdk.test:3000/twitter. Ensure you are the group owner.
  5. In another tab go to graphiql http://gdk.test:3000/-/graphql-explorer

Validate that the UI, API and GraphQL continues to work and also responds to setting

Validate package and registries menu:

1. Go to a root group, in this example `twitter` 1. Select `deploy` and you should see virtual registry listed in the menu.

Screenshot_2025-09-09_at_5.02.15_pm

  1. Go to graphiql and run the below mutation to update enabled to false.

mutation UpdateVirtualRegistriesSetting($input: UpdateVirtualRegistriesSettingInput!) {
  updateVirtualRegistriesSetting(input: $input) {
    virtualRegistriesSetting {
      enabled
    }
  }
}

{
  "input": {
    "groupPath": "twitter",
    "enabled": false
  }
}

Screenshot_2025-09-09_at_5.06.55_pm

  1. Go back to gdk.test and refresh the page. Virtual registry will no longer appear in the menu.

Screenshot_2025-09-09_at_5.08.22_pm

Validate Create registry

  1. Run the mutation in graphiql to set enabled back to true.
  2. Click on create registry
  3. Set a name and click on create registry

Screenshot_2025-09-09_at_5.25.23_pm

  1. Run mutation to switch enabled to false
  2. Click on create registry
  3. You should see a 404

Screenshot_2025-09-09_at_5.42.40_pm

Validate Edit registry

  1. Run the mutation in graphiql to set enabled back to true.
  2. Go to the list view
  3. Select edit icon next to registry or select a registry and then select edit

Screenshot_2025-09-09_at_5.47.41_pm

  1. Set enabled back to false in graphiql
  2. And click edit again and you should see a 404 page rendered

Screenshot_2025-09-09_at_5.48.12_pm

Validate virtual registries list view groups/:id/-/virtual_registries

  1. Run the mutation to set enabled to true.
  2. Click on virtual registry in the menu which takes you to groups/:id/-/virtual_registries

Screenshot_2025-09-09_at_5.13.53_pm

  1. Back in graphiql, run the mutation to set enabled to false.
  2. Go back and refresh the page, you should see a 404.

Screenshot_2025-09-09_at_5.14.59_pm

Validate virtual registries list GraphQL query

  1. Set enabled to true
  2. Go to graphiql
  3. Run the below query:
query getMavenVirtualRegistries($groupPath: ID!) {
  group(fullPath: $groupPath) {
    id
    mavenVirtualRegistries {
      nodes {
        id
        name
      }
    }
  }
}

------------

variables:

{
  "groupPath": "twitter"
}

Screenshot_2025-09-10_at_12.03.11_pm

  1. Set enabled to false and run the above query again, null will be returned

Screenshot_2025-09-10_at_12.04.38_pm

Validate get maven registry GraphQL query

  1. In graphiql, set enabled to true
  2. Get an id for a registry from the previous query to list registries
  3. Run query with the id, should return the individual registry:
query getMavenVirtualRegistry($id: VirtualRegistriesPackagesMavenRegistryID!) {
  mavenVirtualRegistry(id: $id) {
    id
    updatedAt
    name
  }
}

------

variables:
{
  "id": "gid://gitlab/VirtualRegistries::Packages::Maven::Registry/5"
}

Screenshot_2025-09-10_at_2.47.27_pm

  1. Set enabled to false
  2. Run query again, and null should be returned

Screenshot_2025-09-10_at_2.49.14_pm

Validate create maven upstream registry

1. Set enabled to true 1. Go to your list of virtual registries http://gdk.test:3000/groups/twitter/-/virtual_registries/maven 1. Click on one of them, and then select create upstream. 1. Create an upstream

Screenshot_2025-09-10_at_2.59.49_pm

  1. Go back to http://gdk.test:3000/groups/twitter/-/virtual_registries/maven
  2. Select a virtual registry again and select create upstream.
  3. Set enabled to false
  4. Complete form and then click create upstream
  5. There should be a something went wrong error

Screenshot_2025-09-10_at_3.04.49_pm

  1. Checking the network tab we'll see the below error response for the mutation

Screenshot_2025-09-10_at_3.05.08_pm

Screenshot_2025-09-10_at_3.05.17_pm

Validate get upstream registries

1. Set enabled to true 1. Go to http://gdk.test:3000/groups/twitter/-/virtual_registries/maven/ and click on the virtual registry you created the upstream in. 1. Can see upstream in ui and see successful graphql query in network tab

Screenshot_2025-09-10_at_3.15.19_pm

  1. Click on virtual registry again.
  2. Set enabled to false
  3. Refresh page and you will the 404 page.

API

GET /groups/:id/-/virtual_registries/packages/maven/registries

  1. In your browser go to http://gdk.test:3000/api/v4/groups/<your group id>/-/virtual_registries/packages/maven/registries

Screenshot_2025-09-30_at_11.17.00_am

  1. Update enabled to false and refresh page and a 404 should be returned.

Screenshot_2025-09-30_at_11.17.37_am

POST /groups/:id/-/virtual_registries/packages/maven/registries

  1. Create an access token, owner and api setting.
  2. Run this curl command:
curl --request POST \
     --header "PRIVATE-TOKEN: <your_access_token>" \
     --header "Content-Type: application/json" \
     --header "Accept: application/json" \
     --data '{"name": "my-virtual-registry", "description": "My virtual registry"}' \
     --url "https://gdk.test:3000/api/v4/groups/<your group id>/-/virtual_registries/packages/maven/registries"
  1. You should receive a 404 as enabled is still false from previous example

create-registry-not-found

  1. Enable the setting back in graphql explorer and run request again, a registry should be created.

  2. Screenshot_2025-09-30_at_11.23.14_am

GET /virtual_registries/packages/maven/registries/:id

  1. This one can be done back in the browser if you prefer. Go back to your virtual registries, select one and get the id.
  2. Run this in your browser http://gdk.test:3000/api/v4/virtual_registries/packages/maven/registries/<your registry id>

Screenshot_2025-09-30_at_11.37.28_am

  1. Update enabled to false back in GraphQL explorer and refresh page, and a 404 should be returned.

Screenshot_2025-09-30_at_11.38.03_am

PATCH /virtual_registries/packages/maven/registries/:id

  1. Run this curl command using the same access token from earlier, a 404 should be returned.
curl --request PATCH \
     --header "PRIVATE-TOKEN: <your_access_token>" \
     --header "Content-Type: application/json" \
     --data '{"name": "my-virtual-registry", "description": "My virtual registry"}' \
     --url "http://gdk.test:3000/api/v4/virtual_registries/packages/maven/registries/2"

Screenshot_2025-09-30_at_11.45.57_am

  1. Update enabled to true and run the curl command again a 200 should be returned.

Screenshot_2025-09-30_at_11.46.19_am

DELETE /virtual_registries/packages/maven/registries/:id

  1. Run the delete curl command with your registry id, registry will be deleted from list:
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" \
     --header "Accept: application/json" \
     --url "http://gdk.test:3000/api/v4/virtual_registries/packages/maven/registries/2"

Screenshot_2025-09-30_at_11.58.50_am

  1. Update enabled to false, and run curl command again and a 404 should be returned:

Screenshot_2025-09-30_at_11.59.36_am

GET /groups/:id/-/virtual_registries/packages/maven/upstreams

  1. Run this in the browser and a 404 should be returned http://gdk.test:3000/api/v4/groups/<your group id>/-/virtual_registries/packages/maven/upstreams

Screenshot_2025-09-30_at_12.02.22_pm

  1. Update enabled to true and refresh the page, and the upstreams should be returned.

Screenshot_2025-09-30_at_12.02.48_pm

POST /groups/:id/-/virtual_registries/packages/maven/upstreams/test

  1. Run the below curl command and a success true should be returned.

Screenshot_2025-09-30_at_12.05.55_pm

  1. Update enabled to false and a 404 will be returned

Screenshot_2025-09-30_at_12.06.08_pm

GET /virtual_registries/packages/maven/registries/:id/upstreams

  1. In the browser run this http://gdk.test:3000/api/v4/virtual_registries/packages/maven/registries/1/upstreams, and a 404 should be returned.

Screenshot_2025-09-30_at_12.09.07_pm

  1. Update enabled to true and refresh page and upstreams will be returned.

Screenshot_2025-09-30_at_12.09.50_pm

POST /virtual_registries/packages/maven/registries/:id/upstreams

  1. Run the below curl command and a success response should be received.

Screenshot_2025-09-30_at_12.14.32_pm

  1. Update enabled to false and a 404 should be received

Screenshot_2025-09-30_at_12.14.46_pm

GET /virtual_registries/packages/maven/upstreams/:id

  1. Using the id for the upstream from the previous POST command, run this in the browser. A 404 should be returned.

Screenshot_2025-09-30_at_12.17.14_pm

  1. Update enabled to true and refresh page and the upstream should be returned.

Screenshot_2025-09-30_at_12.17.35_pm

PATCH /virtual_registries/packages/maven/upstreams/:id

  1. Run the below curl command and a 200 response should be returned

Screenshot_2025-09-30_at_12.22.40_pm

  1. Update enabled to false, and a 404 should be returned

Screenshot_2025-09-30_at_12.22.50_pm

PATCH /virtual_registries/packages/maven/registry_upstreams/:id

  1. Run the below curl command and a 404 should be returned

Screenshot_2025-09-30_at_12.29.38_pm

  1. Update enabled to true and a 200 should be returned.

Screenshot_2025-09-30_at_12.28.53_pm

The remainder of api endpoints all have the same api shared setup included (include ::API::Concerns::VirtualRegistries::Packages::Maven::SharedSetup), so these will also return the same behaviour when enable is true or false.

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.

Related to #554069

Edited by Fiona McCawley

Merge request reports

Loading