test(mcp): environment, redaction and end to end through the core

The TZ test checks TZ is absent on Windows: the process policy never sets TZ there (process-environment-hook spec §3). Spec testing bullet and plan updated to match.
This commit is contained in:
EugeneTes
2026-09-26 20:54:20 +02:00
parent 2c5d5dfcb4
commit 963301efc4
5 changed files with 250 additions and 2 deletions

View File

@@ -4010,7 +4010,9 @@ public class McpEnvironmentTests
{
await using var host = new McpTestHost(Fake(FakeMcp.Server("env")));
var env = await ServerEnvironmentAsync(host, TimeZoneInfo.FindSystemTimeZoneById("Asia/Tokyo"));
Assert.Equal("Asia/Tokyo", env["TZ"]);
// The policy skips TZ on Windows, where the OS doesn't use it (process-environment-hook spec §3).
if (OperatingSystem.IsWindows()) Assert.False(env.ContainsKey("TZ"));
else Assert.Equal("Asia/Tokyo", env["TZ"]);
}
private sealed class SpawnWatcher : IExtension

View File

@@ -365,7 +365,7 @@ No test touches the network, npm or a real browser.
- environment (`FAKE_MCP_MODE=env`, a tool that returns its environment): with `OPENAI_API_KEY` and `GITHUB_TOKEN`
in the injected host snapshot, neither reaches the server; a server `env` entry `GITHUB_TOKEN: ${env:GITHUB_TOKEN}`
delivers it (explicit beats the deny-list); discovery and the session process agree; `TZ` is the session's zone
for the session process;
for the session process (on Unix; the policy never sets `TZ` on Windows, so there the test checks it's absent);
- results: text, image → `ImageContent`, oversized image replaced, `isError` → error tool result with content,
output truncation note;
- redaction, end to end through the core: the `env` tool's output with a `GITHUB_TOKEN` configured as a secret