Add explanation rules for catches, editable over MCP
Build and deploy / build (push) Successful in 1m29s
Build and deploy / deploy (push) Successful in 21s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
TomandClaude Opus 5.5 committed 2026-11-21 11:46:22 +01:00
1 parent 4086fa3da3
commit 2437880013
37 files changed
+1867 -37

No files matched your search

@@ -21,7 +21,7 @@ public sealed class McpTokenServiceTests : IDisposable
var token = await service.CreateAsync("Claude Desktop");
token.Length.ShouldBeGreaterThan(40);
(await service.AuthenticateAsync(token)).ShouldBeTrue();
(await service.AuthenticateAsync(token)).ShouldNotBeNull();
var stored = (await _store.ListAsync()).ShouldHaveSingleItem();
stored.Name.ShouldBe("Claude Desktop");
stored.TokenHash.ShouldBe(McpTokenService.Hash(token));
@@ -35,12 +35,12 @@ public sealed class McpTokenServiceTests : IDisposable
var service = Create(environmentToken: null);
var token = await service.CreateAsync("test");
(await service.AuthenticateAsync(null)).ShouldBeFalse();
(await service.AuthenticateAsync("")).ShouldBeFalse();
(await service.AuthenticateAsync(token + "x")).ShouldBeFalse();
(await service.AuthenticateAsync(null)).ShouldBeNull();
(await service.AuthenticateAsync("")).ShouldBeNull();
(await service.AuthenticateAsync(token + "x")).ShouldBeNull();
(await _store.RevokeAsync((await _store.ListAsync())[0].Id)).ShouldBeTrue();
(await service.AuthenticateAsync(token)).ShouldBeFalse();
(await service.AuthenticateAsync(token)).ShouldBeNull();
}
[Fact]
@@ -50,9 +50,32 @@ public sealed class McpTokenServiceTests : IDisposable
var stored = await service.CreateAsync("test");
service.UsesEnvironmentToken.ShouldBeTrue();
(await service.AuthenticateAsync("fixed-token-from-environment")).ShouldBeTrue();
(await service.AuthenticateAsync(stored)).ShouldBeTrue();
(await service.AuthenticateAsync("fixed-token")).ShouldBeFalse();
(await service.AuthenticateAsync("fixed-token-from-environment")).ShouldNotBeNull();
(await service.AuthenticateAsync(stored)).ShouldNotBeNull();
(await service.AuthenticateAsync("fixed-token")).ShouldBeNull();
}
[Fact]
public async Task Write_permission_is_granted_per_token_and_can_be_withdrawn()
{
var service = Create(environmentToken: null);
var readOnly = await service.CreateAsync("read");
var writer = await service.CreateAsync("write", canWrite: true);
(await service.AuthenticateAsync(readOnly)).ShouldBe(new McpAccess("read", false));
(await service.AuthenticateAsync(writer)).ShouldBe(new McpAccess("write", true));
var id = (await _store.ListAsync()).Single(t => t.Name == "write").Id;
(await _store.SetCanWriteAsync(id, false)).ShouldBeTrue();
(await service.AuthenticateAsync(writer)).ShouldBe(new McpAccess("write", false));
}
[Fact]
public async Task Environment_token_never_has_write_permission()
{
var service = Create(environmentToken: "fixed-token-from-environment");
(await service.AuthenticateAsync("fixed-token-from-environment")).ShouldBe(new McpAccess(McpTokenService.EnvironmentTokenName, false));
}
private McpTokenService Create(string? environmentToken) =>