Skip to content

Allow actor override when GitHub and BBS disabled

Luke Duncalfe requested to merge ld-override-github_bbs_disabled into master

What does this MR do and why?

This change allows an instance to selectively enable the GitHub importer or Bitbucket Server importer for a user when they are globally disabled. This is in the same vein as an MR for Direct Transfer merged in 16.5 !132431 (merged).

To override the disabled setting, the ops flags should be enabled for the user conducting the import.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

Setup:

  1. Go to /admin/application_settings/general and expand Import and export settings.
  2. Under Import sources, uncheck GitHub and Bitbucket Server.

Import GitHub QA:

  1. On GitHub, generate a GitHub PAT for yourself
  2. Try to import from GitHub via the API (see the example curl below). You will get {"errors":["github import source is disabled"]}
  3. Now enable the flag for your user: Feature.enable(:override_github_disabled, your_user)
  4. Try to import via the API, request will succeed.
  5. Verify the import worked, by visiting the project that was imported.

Import Bitbucket Server QA:

  1. Try to import from Bitbucket Server via the API (see the example curl below). You will get {"message":{"error":["bitbucket_server import source is disabled"]}}
  2. Now enable the flag for your user: Feature.enable(:override_bitbucket_server_disabled, your_user)
  3. Try to import via the API, request will succeed.
  4. Verify the import worked, by visiting the project that was imported.

Example curl to import from GitHub (imports https://github.com/lukes/test which is repo_id=743300594):

curl --request POST \
  --url "http://gdk.test:3000/api/v4/import/github" \
  --header "content-type: application/json" \
  --header "PRIVATE-TOKEN: <GITLAB_PAT>" \
  --data '{
    "personal_access_token": "<GITHUB_TOKEN>",
    "repo_id": "743300594",
    "target_namespace": "root",
    "new_name": "gh-test-import"
  }'

Example curl to import from BitBucket Server:

curl --request POST \
  --url "http://gdk.test:3000/api/v4/import/bitbucket_server" \
  --header "content-type: application/json" \
  --header "PRIVATE-TOKEN: <GITLAB_PAT>" \
  --data '{
    "bitbucket_server_url": "http://localhost:7990",
    "bitbucket_server_username": "admin",
    "personal_access_token": "<ADMIN_PASSWORD>",
    "bitbucket_server_project": "<BBS_PROJECT_CODE>",
    "bitbucket_server_repo": "<BBS_REPO_NAME>",
    "target_namespace": "root",
    "new_name": "bbs_import"
}'
Edited by Luke Duncalfe

Merge request reports