Skip to content

Use Trusted Publishing for CloudTest E2E Test execution - #141

Merged
pranathibora14 merged 4 commits into
mainfrom
prabora/replace-api-keys-with-oidc
Oct 5, 2026
Merged

pranathibora14 merged 4 commits into
mainfrom
prabora/replace-api-keys-with-oidc

Conversation

@pranathibora14

Copy link
Copy Markdown
Contributor

Updates CloudTest E2E tests to use managed-identity trusted publishing instead of a stored API key.

Uses Azure.Identity.ManagedIdentityCredential to acquire an Entra token with the CloudTest VM’s identity and exchange it with Gallery for a short-lived publishing key. Authentication happens during test fixture initialization, and the key is shared in memory without being written to configuration or logs.

CloudTest has no static-key fallback, while local execution continues to support manually supplied API keys.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The managed-identity request uses an invalid bare resource scope instead of the required /.default scope.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Adds managed-identity trusted publishing for CloudTest while retaining API keys for local runs.

Changes:

  • Exchanges Entra tokens for short-lived Gallery publishing keys.
  • Initializes and shares authentication through test fixtures.
  • Adds configuration validation and provider tests.
File Description
E2EPublishingKeyProviderTests.cs Tests acquisition, validation, concurrency, and failures.
Test .csproj Includes the new provider tests.
TestSettings.cs Loads trusted-publishing settings and initializes keys.
E2EPublishingKeyProvider.cs Implements managed-identity token exchange.
TrustedPublishingSettings.cs Defines deployment authentication settings.
GalleryConfiguration.cs Centralizes service URL selection.
CommonFixture.cs Initializes publishing authentication.
GalleryClient.cs Uses centralized Gallery URL selection.
AssemblyInfo.cs Exposes internals to tests.
Source .csproj Adds source files and Azure Identity dependency.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

try
{
var credential = _createCredential(clientId.ToString());
var request = new TokenRequestContext(new[] { context.ResourceUri });

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Azure.Identity 1.12.0 supports a bare resource URI for managed identity. Its IMDS implementation calls ScopesToResource(), which strips /.default when present and otherwise passes the resource through unchanged.

Comment thread src/NuGet.Services.EndToEnd/Support/E2EPublishingKeyProvider.cs Outdated
Comment thread src/NuGet.Services.EndToEnd/Support/E2EPublishingKeyProvider.cs
Comment thread src/NuGet.Services.EndToEnd/Support/E2EPublishingKeyProvider.cs Outdated
agr
agr previously approved these changes Oct 2, 2026
@pranathibora14 pranathibora14 reopened this Oct 5, 2026
@pranathibora14
pranathibora14 merged commit dfbc176 into main Oct 5, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants