Initial commit to new repository

This commit is contained in:
2026-04-03 18:22:19 +09:00
commit 4458bb0f52
7672 changed files with 452440 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
using AxCopilot.Models;
using AxCopilot.Services;
using AxCopilot.Services.Agent;
using FluentAssertions;
using Xunit;
namespace AxCopilot.Tests.Services;
public class OperationModePolicyTests
{
[Fact]
public void Normalize_DefaultsToInternalWhenMissingOrUnknown()
{
OperationModePolicy.Normalize(null).Should().Be(OperationModePolicy.InternalMode);
OperationModePolicy.Normalize("").Should().Be(OperationModePolicy.InternalMode);
OperationModePolicy.Normalize("unknown").Should().Be(OperationModePolicy.InternalMode);
}
[Fact]
public void Normalize_MapsExternalMode()
{
OperationModePolicy.Normalize("external").Should().Be(OperationModePolicy.ExternalMode);
OperationModePolicy.Normalize("EXTERNAL").Should().Be(OperationModePolicy.ExternalMode);
}
[Fact]
public void IsBlockedAgentToolInInternalMode_BlocksExternalHttpAndUrlOpen()
{
OperationModePolicy.IsBlockedAgentToolInInternalMode("http_tool", "https://example.com").Should().BeTrue();
OperationModePolicy.IsBlockedAgentToolInInternalMode("open_external", "https://example.com").Should().BeTrue();
OperationModePolicy.IsBlockedAgentToolInInternalMode("open_external", @"E:\work\report.html").Should().BeFalse();
}
[Fact]
public async Task AgentContext_CheckToolPermissionAsync_BlocksRestrictedToolsInInternalMode()
{
var context = new AgentContext
{
OperationMode = OperationModePolicy.InternalMode,
Permission = "Auto"
};
var blocked = await context.CheckToolPermissionAsync("http_tool", "https://example.com");
var allowed = await context.CheckToolPermissionAsync("file_read", @"E:\work\a.txt");
blocked.Should().BeFalse();
allowed.Should().BeTrue();
}
[Fact]
public async Task AgentContext_CheckToolPermissionAsync_AllowsRestrictedToolsInExternalMode()
{
var context = new AgentContext
{
OperationMode = OperationModePolicy.ExternalMode,
Permission = "Auto"
};
var allowed = await context.CheckToolPermissionAsync("http_tool", "https://example.com");
allowed.Should().BeTrue();
}
}