Skip to content

Commit f883121

Browse files
author
Tarek Mahmoud Sayed
committed
Skip SEP-2243 conformance tests until scenarios are available in package
The http-standard-headers, http-custom-headers, http-invalid-tool-headers, http-header-validation, and http-custom-header-server-validation scenarios are not yet published in @modelcontextprotocol/conformance. Gate these tests on HasSep2243Scenarios which checks for package version >= 0.2.0.
1 parent 72e8e6e commit f883121

3 files changed

Lines changed: 42 additions & 1 deletion

File tree

tests/Common/Utils/NodeHelpers.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,44 @@ public static bool IsNodeInstalled()
167167
}
168168
}
169169

170+
/// <summary>
171+
/// Checks whether the SEP-2243 conformance scenarios are available by reading
172+
/// the conformance package version from the repo's package.json.
173+
/// The http-standard-headers, http-custom-headers, http-invalid-tool-headers,
174+
/// http-header-validation, and http-custom-header-server-validation scenarios
175+
/// require a conformance package version that includes SEP-2243 support.
176+
/// </summary>
177+
public static bool HasSep2243Scenarios()
178+
{
179+
try
180+
{
181+
var repoRoot = FindRepoRoot();
182+
var packageJsonPath = Path.Combine(repoRoot, "package.json");
183+
if (!File.Exists(packageJsonPath))
184+
{
185+
return false;
186+
}
187+
188+
var json = System.Text.Json.JsonDocument.Parse(File.ReadAllText(packageJsonPath));
189+
if (json.RootElement.TryGetProperty("dependencies", out var deps) &&
190+
deps.TryGetProperty("@modelcontextprotocol/conformance", out var versionElement))
191+
{
192+
var versionStr = versionElement.GetString();
193+
if (versionStr is not null && Version.TryParse(versionStr, out var version))
194+
{
195+
// SEP-2243 scenarios are expected in conformance package >= 0.2.0
196+
return version >= new Version(0, 2, 0);
197+
}
198+
}
199+
200+
return false;
201+
}
202+
catch
203+
{
204+
return false;
205+
}
206+
}
207+
170208
private static ProcessStartInfo NpmStartInfo(string arguments, string workingDirectory)
171209
{
172210
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))

tests/ModelContextProtocol.AspNetCore.Tests/ClientConformanceTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class ClientConformanceTests
1616

1717
// Public static property required for SkipUnless attribute
1818
public static bool IsNodeInstalled => NodeHelpers.IsNodeInstalled();
19+
public static bool HasSep2243Scenarios => NodeHelpers.HasSep2243Scenarios();
1920

2021
public ClientConformanceTests(ITestOutputHelper output)
2122
{
@@ -62,7 +63,7 @@ public async Task RunConformanceTest(string scenario)
6263
}
6364

6465
// HTTP Standardization (SEP-2243)
65-
[Theory(Skip = "Node.js is not installed. Skipping client conformance tests.", SkipUnless = nameof(IsNodeInstalled))]
66+
[Theory(Skip = "SEP-2243 conformance scenarios not yet available.", SkipUnless = nameof(HasSep2243Scenarios))]
6667
[InlineData("http-standard-headers")]
6768
[InlineData("http-custom-headers")]
6869
[InlineData("http-invalid-tool-headers")]

tests/ModelContextProtocol.AspNetCore.Tests/ServerConformanceTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ public async Task RunPendingConformanceTest_ServerSsePolling()
139139
public async Task RunConformanceTest_HttpHeaderValidation()
140140
{
141141
Assert.SkipWhen(!NodeHelpers.IsNodeInstalled(), "Node.js is not installed. Skipping conformance tests.");
142+
Assert.SkipWhen(!NodeHelpers.HasSep2243Scenarios(), "SEP-2243 conformance scenarios not yet available.");
142143

143144
var result = await RunConformanceTestsAsync($"server --url {fixture.ServerUrl} --scenario http-header-validation");
144145

@@ -150,6 +151,7 @@ public async Task RunConformanceTest_HttpHeaderValidation()
150151
public async Task RunConformanceTest_HttpCustomHeaderServerValidation()
151152
{
152153
Assert.SkipWhen(!NodeHelpers.IsNodeInstalled(), "Node.js is not installed. Skipping conformance tests.");
154+
Assert.SkipWhen(!NodeHelpers.HasSep2243Scenarios(), "SEP-2243 conformance scenarios not yet available.");
153155

154156
var result = await RunConformanceTestsAsync($"server --url {fixture.ServerUrl} --scenario http-custom-header-server-validation");
155157

0 commit comments

Comments
 (0)