chore: import upstream snapshot with attribution
This commit is contained in:
+76
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using MCPForUnity.Editor.Clients;
|
||||
using MCPForUnity.Editor.Models;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MCPForUnityTests.Editor.Clients
|
||||
{
|
||||
/// <summary>
|
||||
/// Covers the regression where JsonFileMcpConfigurator.CheckStatus only recognized
|
||||
/// the "url" property and missed "serverUrl" (Antigravity/Windsurf) and "httpUrl"
|
||||
/// (Gemini CLI), so clients configured via HTTP looked unconfigured and got rewritten
|
||||
/// every startup by the auto-rewrite path.
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class CheckStatusUrlPropertyTests
|
||||
{
|
||||
private string _tempDir;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_tempDir = Path.Combine(Path.GetTempPath(), "UnityMCPTests", Guid.NewGuid().ToString("N"));
|
||||
Directory.CreateDirectory(_tempDir);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
try { if (Directory.Exists(_tempDir)) Directory.Delete(_tempDir, true); } catch { }
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CheckStatus_DetectsHttp_WhenUrlProperty()
|
||||
=> AssertHttpDetected("url");
|
||||
|
||||
[Test]
|
||||
public void CheckStatus_DetectsHttp_WhenServerUrlProperty()
|
||||
=> AssertHttpDetected("serverUrl");
|
||||
|
||||
[Test]
|
||||
public void CheckStatus_DetectsHttp_WhenHttpUrlProperty()
|
||||
=> AssertHttpDetected("httpUrl");
|
||||
|
||||
private void AssertHttpDetected(string urlProperty)
|
||||
{
|
||||
string configPath = Path.Combine(_tempDir, $"{urlProperty}.json");
|
||||
File.WriteAllText(configPath,
|
||||
"{\"mcpServers\":{\"unityMCP\":{\"" + urlProperty + "\":\"http://localhost:65535/mcp\"}}}");
|
||||
|
||||
var client = new McpClient
|
||||
{
|
||||
name = "Fake",
|
||||
windowsConfigPath = configPath,
|
||||
macConfigPath = configPath,
|
||||
linuxConfigPath = configPath,
|
||||
HttpUrlProperty = urlProperty,
|
||||
};
|
||||
var configurator = new FakeJsonConfigurator(client);
|
||||
|
||||
configurator.CheckStatus(attemptAutoRewrite: false);
|
||||
|
||||
Assert.AreNotEqual(ConfiguredTransport.Unknown, client.configuredTransport,
|
||||
$"CheckStatus must recognize the '{urlProperty}' property as an HTTP URL");
|
||||
Assert.That(
|
||||
client.configuredTransport == ConfiguredTransport.Http
|
||||
|| client.configuredTransport == ConfiguredTransport.HttpRemote,
|
||||
$"Expected HTTP/HttpRemote transport for '{urlProperty}', got {client.configuredTransport}");
|
||||
}
|
||||
|
||||
private sealed class FakeJsonConfigurator : JsonFileMcpConfigurator
|
||||
{
|
||||
public FakeJsonConfigurator(McpClient client) : base(client) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b5bc8d0b36d477e8239edff10911bba
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,45 @@
|
||||
using System.IO;
|
||||
using MCPForUnity.Editor.Clients;
|
||||
using MCPForUnity.Editor.Clients.Configurators;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MCPForUnityTests.Editor.Clients
|
||||
{
|
||||
[TestFixture]
|
||||
public class IsInstalledTests
|
||||
{
|
||||
[Test]
|
||||
public void IMcpClientConfigurator_ExposesIsInstalled()
|
||||
{
|
||||
var prop = typeof(IMcpClientConfigurator).GetProperty("IsInstalled");
|
||||
Assert.IsNotNull(prop, "IMcpClientConfigurator must expose an IsInstalled property");
|
||||
Assert.AreEqual(typeof(bool), prop.PropertyType);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void JsonClient_NotInstalled_WhenParentDirMissing()
|
||||
{
|
||||
var cursor = new CursorConfigurator();
|
||||
string parent = Path.GetDirectoryName(cursor.GetConfigPath());
|
||||
if (parent == null || !Directory.Exists(parent))
|
||||
{
|
||||
Assert.IsFalse(cursor.IsInstalled,
|
||||
"Cursor parent dir does not exist on this machine, IsInstalled must be false");
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.IsTrue(cursor.IsInstalled,
|
||||
"Cursor parent dir exists, IsInstalled must be true");
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void JsonClient_Installed_WhenParentDirExists()
|
||||
{
|
||||
var claude = new ClaudeDesktopConfigurator();
|
||||
string parent = Path.GetDirectoryName(claude.GetConfigPath());
|
||||
bool expected = parent != null && Directory.Exists(parent);
|
||||
Assert.AreEqual(expected, claude.IsInstalled);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 15e00d05358545a5955aa1c291653289
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Linq;
|
||||
using MCPForUnity.Editor.Clients;
|
||||
using MCPForUnity.Editor.Clients.Configurators;
|
||||
using MCPForUnity.Editor.Models;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MCPForUnityTests.Editor.Clients
|
||||
{
|
||||
[TestFixture]
|
||||
public class SupportedTransportsTests
|
||||
{
|
||||
[Test]
|
||||
public void IMcpClientConfigurator_ExposesSupportedTransports()
|
||||
{
|
||||
var prop = typeof(IMcpClientConfigurator).GetProperty("SupportedTransports");
|
||||
Assert.IsNotNull(prop, "Must expose SupportedTransports");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ClaudeDesktop_SupportsStdioOnly()
|
||||
{
|
||||
var claude = new ClaudeDesktopConfigurator();
|
||||
CollectionAssert.Contains(claude.SupportedTransports.ToList(), ConfiguredTransport.Stdio);
|
||||
CollectionAssert.DoesNotContain(claude.SupportedTransports.ToList(), ConfiguredTransport.Http);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Cursor_SupportsBothTransports()
|
||||
{
|
||||
var cursor = new CursorConfigurator();
|
||||
var list = cursor.SupportedTransports.ToList();
|
||||
CollectionAssert.Contains(list, ConfiguredTransport.Stdio);
|
||||
CollectionAssert.Contains(list, ConfiguredTransport.Http);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 26823824aa5cae0caa9488e9ad49bcf1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user