test(api): pin the Duo Agent Platform auth contract

What does this MR do and why?

Adds a contract test for how GitLab Duo Agent Platform workloads authenticate glab.

Those workloads install the glab version pinned in gitlab-org/gitlab and set it up without glab auth login:

  • GlabSetup#config_file_command (ee/lib/gitlab/duo_workflow/glab_setup.rb) writes config.yml with is_oauth2: 'true', client_id: bypass, and no token.
  • StartWorkflowService (ee/app/services/ai/duo_workflows/start_workflow_service.rb) passes the Doorkeeper OAuth token through GITLAB_TOKEN, together with GLAB_IS_OAUTH2=true, inside a CI job.

glab 1.111.0 started sending that token as Private-Token (#8482 (closed)). Nothing caught it automatically. It was found by hand while bumping the pin (gitlab!247970 (merged)). The monolith specs don't run the binary, and TestNewClientFromConfig_OAuthFlagProvenance covers the flag combinations in general rather than this setup.

Renovate now opens the pin bumps on a weekly schedule (gitlab-org/frontend/renovate-gitlab-bot!1771 (merged)). So this test reproduces DAP's config and environment and asserts glab sends Authorization: Bearer to the right API base URL. It covers four host setups: default port, non-default port, relative URL root, and HTTP.

How to set up and validate locally

go test ./internal/api/ -run DuoAgentPlatformContract -count=1 -v

To check that it catches the 1.111.0 regression, make isEnvironmentOAuth2 always false in internal/api/client.go. Every case then fails with Private-Token instead of Authorization.

🤖 Generated with Claude Code

Edited by Jay McCure

Merge request reports

Loading
Loading