Implementation for SEP-2243 Http Standardization (#1553)

Co-authored-by: Tarek Mahmoud Sayed <tarekms@microsoft.com>
Co-authored-by: Tarek Mahmoud Sayed <tarekms@ntdev.microsoft.com>
Co-authored-by: Tarek Mahmoud Sayed <10833894+tarekgh@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Mike Kistler 2026-05-14 17:39:37 -05:00 • committed by GitHub
commit b8c4d951ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -0,0 +1,59 @@
using ModelContextProtocol.Server;
namespace ModelContextProtocol.Tests.Server;
public class McpHeaderAttributeTests
{
[Theory]
[InlineData("Region")]
[InlineData("TenantId")]
[InlineData("Priority")]
[InlineData("X-Custom")]
public void Constructor_ValidHeaderName_Succeeds(string name)
{
var attr = new McpHeaderAttribute(name);
Assert.Equal(name, attr.Name);
}
[Fact]
public void Constructor_NameWithSpace_Throws()
{
Assert.Throws<ArgumentException>(() => new McpHeaderAttribute("My Region"));
}
[Fact]
public void Constructor_NameWithColon_Throws()
{
Assert.Throws<ArgumentException>(() => new McpHeaderAttribute("Region:Primary"));
}
[Fact]
public void Constructor_NullName_Throws()
{
Assert.ThrowsAny<ArgumentException>(() => new McpHeaderAttribute(null!));
}
[Fact]
public void Constructor_EmptyName_Throws()
{
Assert.ThrowsAny<ArgumentException>(() => new McpHeaderAttribute(""));
}
[Fact]
public void Constructor_WhitespaceName_Throws()
{
Assert.ThrowsAny<ArgumentException>(() => new McpHeaderAttribute(" "));
}
[Fact]
public void Constructor_NameWithControlCharacter_Throws()
{
Assert.Throws<ArgumentException>(() => new McpHeaderAttribute("Region\t1"));
}
[Fact]
public void Constructor_NameWithNonAscii_Throws()
{
Assert.Throws<ArgumentException>(() => new McpHeaderAttribute("Région"));
}
}