Adding GraphQL mutations to trigger Allowlist Autopopulation processes

What does this MR do and why?

As part of https://gitlab.com/gitlab-org/gitlab/-/issues/47854+, this MR adds GraphQL mutations for the autopopulate and clearAutopopulation services that are used to generate and clear the allowlist entries. Designs are detailed here: #509883 (closed).

References

Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.

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.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

  1. Create sample authorization log records in the rails console:

    project = Project.first
    project2 = Project.second
    project3 = Project.third
    
    Ci::JobToken::Authorization.create(accessed_project: project, origin_project: project2, last_authorized_at: 1.day.ago)
    Ci::JobToken::Authorization.create(accessed_project: project, origin_project: project3, last_authorized_at: 1.day.ago)
  2. Ensure two records have been created:

    Ci::JobToken::Authorization.all
  3. Ensure no ProjectScopeLinks exist for the given project:

    Ci::JobToken::ProjectScopeLink.where(source_project: project)
  4. Run the autopopulate mutation in graphiql:

    mutation CiJobTokenScopeAutopopulateAllowlist($projectPath: ID!) {
      ciJobTokenScopeAutopopulateAllowlist(input: { projectPath:$projectPath }){
        status
        errors
      }
    }

    Note: Should be the path of whatever project is locally. For me it was toolbox/gitlab-smoke-tests

    {
      "projectPath": "toolbox/gitlab-smoke-tests"
    }
  5. Ensure that 2 ProjectScopeLinks now exist for the given project:

    Ci::JobToken::ProjectScopeLink.where(source_project: project)
  6. Run the autopopulation clear mutation in graphiql:

    mutation CiJobTokenScopeClearAllowlistAutopopulations($projectPath: ID!) {
      ciJobTokenScopeClearAllowlistAutopopulations(input: { projectPath:$projectPath }){
        status
        errors
      }
    }
    {
      "projectPath": "toolbox/gitlab-smoke-tests"
    }
  7. Ensure no ProjectScopeLinks exist anymore for the given project:

    Ci::JobToken::ProjectScopeLink.where(source_project: project)
Edited by Darby Frey

Merge request reports

Loading