Files
wehub-resource-sync db620d33df
dotnet-build-and-test / dotnet-test-functions (push) Has been cancelled
dotnet-build-and-test / paths-filter (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Debug, windows-latest, net9.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net8.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-foundry-hosted-it (push) Has been cancelled
dotnet-build-and-test / dotnet-build-and-test-check (push) Has been cancelled
dotnet-build-and-test / Integration Test Report (push) Has been cancelled
CodeQL / Analyze (csharp) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:39:25 +08:00

41 lines
2.0 KiB
C#

// Copyright (c) Microsoft. All rights reserved.
using System;
using System.Collections.Generic;
namespace Foundry.Hosting.IntegrationTests.Fixtures;
/// <summary>
/// Provisions a hosted agent that runs the test container in <c>IT_SCENARIO=toolbox-oauth-consent</c>
/// mode. The container pre-registers a Foundry toolbox (named by <c>IT_TOOLBOX_NAME</c>) whose tool
/// source is fronted by a per-user OAuth connection. The first request that needs the tool must
/// surface an <c>oauth_consent_request</c> instead of running it.
/// </summary>
/// <remarks>
/// Prerequisite (out of band, per project): a Foundry toolbox named by <see cref="ToolboxName"/> must
/// exist in the target project and reference a tool source that returns <c>CONSENT_REQUIRED</c> for an
/// unconsented user (for example a delegated GitHub or Microsoft Graph connection). Override the
/// toolbox name with the <c>IT_TOOLBOX_NAME</c> environment variable. See the project README.
/// </remarks>
public sealed class ToolboxOAuthConsentHostedAgentFixture : HostedAgentFixture
{
private const string ToolboxNameEnvironmentVariable = "IT_TOOLBOX_NAME";
private const string DefaultToolboxName = "auth-paths-oauth-toolbox";
protected override string ScenarioName => "toolbox-oauth-consent";
/// <summary>
/// The Foundry toolbox the container pre-registers. Resolved from <c>IT_TOOLBOX_NAME</c>, falling
/// back to a default that exists in the reference project.
/// </summary>
public string ToolboxName { get; } =
Environment.GetEnvironmentVariable(ToolboxNameEnvironmentVariable) ?? DefaultToolboxName;
protected override void ConfigureEnvironment(IDictionary<string, string> environment)
{
// Pass the toolbox name into the container so Program.cs wires AddFoundryToolboxes(credential, name).
// IT_TOOLBOX_NAME is a non-reserved key (FOUNDRY_*/AGENT_* are forbidden by the platform).
environment[ToolboxNameEnvironmentVariable] = this.ToolboxName;
}
}