Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 29 additions & 19 deletions src/Coralph.Tests/PermissionPolicyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public async Task HandleAsync_NoRestrictions_Approves()

var result = await policy.HandleAsync(request, CreateInvocation());

Assert.Equal("approved", result.Kind);
AssertApproved(result);
}

[Fact]
Expand All @@ -26,7 +26,7 @@ public async Task HandleAsync_DenyListMatch_Denies()

var result = await policy.HandleAsync(request, CreateInvocation());

Assert.Equal("denied-interactively-by-user", result.Kind);
AssertDeniedByRules(result);
}

[Fact]
Expand All @@ -38,7 +38,7 @@ public async Task HandleAsync_DenyListNoMatch_Approves()

var result = await policy.HandleAsync(request, CreateInvocation());

Assert.Equal("approved", result.Kind);
AssertApproved(result);
}

[Fact]
Expand All @@ -50,7 +50,7 @@ public async Task HandleAsync_AllowListMatch_Approves()

var result = await policy.HandleAsync(request, CreateInvocation());

Assert.Equal("approved", result.Kind);
AssertApproved(result);
}

[Fact]
Expand All @@ -62,7 +62,7 @@ public async Task HandleAsync_AllowListNoMatch_Denies()

var result = await policy.HandleAsync(request, CreateInvocation());

Assert.Equal("denied-interactively-by-user", result.Kind);
AssertDeniedByRules(result);
}

[Fact]
Expand All @@ -74,7 +74,7 @@ public async Task HandleAsync_DenyTakesPrecedenceOverAllow()

var result = await policy.HandleAsync(request, CreateInvocation());

Assert.Equal("denied-interactively-by-user", result.Kind);
AssertDeniedByRules(result);
}

[Fact]
Expand All @@ -86,7 +86,7 @@ public async Task HandleAsync_WildcardDeny_DeniesAll()

var result = await policy.HandleAsync(request, CreateInvocation());

Assert.Equal("denied-interactively-by-user", result.Kind);
AssertDeniedByRules(result);
}

[Fact]
Expand All @@ -98,7 +98,7 @@ public async Task HandleAsync_WildcardAllow_ApprovesAll()

var result = await policy.HandleAsync(request, CreateInvocation());

Assert.Equal("approved", result.Kind);
AssertApproved(result);
}

[Fact]
Expand All @@ -110,7 +110,7 @@ public async Task HandleAsync_PrefixWildcardMatch_Approves()

var result = await policy.HandleAsync(request, CreateInvocation());

Assert.Equal("approved", result.Kind);
AssertApproved(result);
}

[Fact]
Expand All @@ -122,7 +122,7 @@ public async Task HandleAsync_PrefixWildcardNoMatch_Denies()

var result = await policy.HandleAsync(request, CreateInvocation());

Assert.Equal("denied-interactively-by-user", result.Kind);
AssertDeniedByRules(result);
}

[Fact]
Expand All @@ -134,7 +134,7 @@ public async Task HandleAsync_CaseInsensitiveMatch_Approves()

var result = await policy.HandleAsync(request, CreateInvocation());

Assert.Equal("approved", result.Kind);
AssertApproved(result);
}

[Fact]
Expand All @@ -146,7 +146,7 @@ public async Task HandleAsync_CommaSeparatedAllowList_Approves()

var result = await policy.HandleAsync(request, CreateInvocation());

Assert.Equal("approved", result.Kind);
AssertApproved(result);
}

[Fact]
Expand All @@ -158,7 +158,7 @@ public async Task HandleAsync_CommaSeparatedDenyList_Denies()

var result = await policy.HandleAsync(request, CreateInvocation());

Assert.Equal("denied-interactively-by-user", result.Kind);
AssertDeniedByRules(result);
}

[Fact]
Expand All @@ -170,7 +170,7 @@ public async Task HandleAsync_EmptyKind_NoAllowList_Approves()

var result = await policy.HandleAsync(request, CreateInvocation());

Assert.Equal("approved", result.Kind);
AssertApproved(result);
}

[Fact]
Expand All @@ -182,7 +182,7 @@ public async Task HandleAsync_NullKind_NoAllowList_Approves()

var result = await policy.HandleAsync(request, CreateInvocation());

Assert.Equal("approved", result.Kind);
AssertApproved(result);
}

[Fact]
Expand All @@ -194,7 +194,7 @@ public async Task HandleAsync_WhitespaceInEntries_Normalized()

var result = await policy.HandleAsync(request, CreateInvocation());

Assert.Equal("approved", result.Kind);
AssertApproved(result);
}

[Fact]
Expand All @@ -206,7 +206,7 @@ public async Task HandleAsync_NullEntriesInList_Skipped()

var result = await policy.HandleAsync(request, CreateInvocation());

Assert.Equal("approved", result.Kind);
AssertApproved(result);
}

[Fact]
Expand All @@ -218,7 +218,7 @@ public async Task HandleAsync_MultipleRulesInDenyList_FirstMatchWins()

var result = await policy.HandleAsync(request, CreateInvocation());

Assert.Equal("denied-interactively-by-user", result.Kind);
AssertDeniedByRules(result);
}

[Fact]
Expand All @@ -230,14 +230,24 @@ public async Task HandleAsync_PrefixMatchCaseInsensitive_Approves()

var result = await policy.HandleAsync(request, CreateInvocation());

Assert.Equal("approved", result.Kind);
AssertApproved(result);
}

private static PermissionRequest CreateRequest(string kind)
{
return new PermissionRequest { Kind = kind };
}

private static void AssertApproved(PermissionRequestResult result)
{
Assert.Equal(PermissionRequestResultKind.Approved, result.Kind);
}

private static void AssertDeniedByRules(PermissionRequestResult result)
{
Assert.Equal(PermissionRequestResultKind.DeniedByRules, result.Kind);
}

private static PermissionInvocation CreateInvocation()
{
return new PermissionInvocation();
Expand Down
6 changes: 3 additions & 3 deletions src/Coralph.Tests/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
},
"GitHub.Copilot.SDK": {
"type": "Transitive",
"resolved": "0.1.29",
"contentHash": "CpzIZwcuo4vyn+Z5vKSKECkcAiF4K01kgBNlJYd9LmIh+dpBh0nFjemjY2MgMNoH8qu1rKqM+V8WNUzv1RZGAQ==",
"resolved": "0.1.32",
"contentHash": "NztOyKvGrepwNqRB+rcywN5wC2kYLMgzZx86T/5IAYW8G0lkTMMKuCY+3UsHGx4aja6zkpQfclI6P2s2XtBRYw==",
"dependencies": {
"Microsoft.Extensions.AI.Abstractions": "10.2.0",
"Microsoft.Extensions.Logging.Abstractions": "10.0.2",
Expand Down Expand Up @@ -377,7 +377,7 @@
"coralph": {
"type": "Project",
"dependencies": {
"GitHub.Copilot.SDK": "[0.1.29, )",
"GitHub.Copilot.SDK": "[0.1.32, )",
"Hex1b": "[0.83.0, )",
"Microsoft.Extensions.Configuration.Json": "[8.0.0, )",
"Microsoft.Extensions.Options.ConfigurationExtensions": "[8.0.0, )",
Expand Down
2 changes: 1 addition & 1 deletion src/Coralph/Coralph.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="GitHub.Copilot.SDK" Version="0.1.30" />
<PackageReference Include="GitHub.Copilot.SDK" Version="0.1.32" />
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test project's packages.lock.json was not updated — it still references GitHub.Copilot.SDK version 0.1.29 in two places (transitive dependency at line 44 and project reference at line 380 of src/Coralph.Tests/packages.lock.json), while the main project now uses 0.1.32. Since RestorePackagesWithLockFile is enabled in Directory.Build.props, the committed lock file will be stale and inconsistent with the actual resolved dependency graph. Run dotnet restore to regenerate src/Coralph.Tests/packages.lock.json and include it in this PR.

Suggested change
<PackageReference Include="GitHub.Copilot.SDK" Version="0.1.32" />
<PackageReference Include="GitHub.Copilot.SDK" Version="0.1.29" />

Copilot uses AI. Check for mistakes.
<PackageReference Include="Hex1b" Version="0.83.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
Expand Down
4 changes: 2 additions & 2 deletions src/Coralph/PermissionPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ internal Task<PermissionRequestResult> HandleAsync(PermissionRequest request, Pe

var decision = EvaluateDecision(candidates, out var matchedRule);
var resultKind = decision == PermissionDecision.Allow
? "approved"
: "denied-interactively-by-user";
? PermissionRequestResultKind.Approved
: PermissionRequestResultKind.DeniedByRules;

EmitDecision(kind, toolName, candidates, decision, matchedRule);

Expand Down
12 changes: 6 additions & 6 deletions src/Coralph/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"net10.0": {
"GitHub.Copilot.SDK": {
"type": "Direct",
"requested": "[0.1.30, )",
"resolved": "0.1.30",
"contentHash": "fdk5Tvm1+9nQEQIqbvPn0KsVMus46aps/RLTXy2FkbrsNFfzEXo1gHCz6GchPHn4P7BShnxa8DxYrcUwjL0e0w==",
"requested": "[0.1.32, )",
"resolved": "0.1.32",
"contentHash": "NztOyKvGrepwNqRB+rcywN5wC2kYLMgzZx86T/5IAYW8G0lkTMMKuCY+3UsHGx4aja6zkpQfclI6P2s2XtBRYw==",
"dependencies": {
"Microsoft.Extensions.AI.Abstractions": "10.2.0",
"Microsoft.Extensions.Logging.Abstractions": "10.0.2",
Expand Down Expand Up @@ -50,9 +50,9 @@
},
"Microsoft.NET.ILLink.Tasks": {
"type": "Direct",
"requested": "[10.0.3, )",
"resolved": "10.0.3",
"contentHash": "0B6nZyCHWXnvmlB559oduOspVdNOnpNXPjhpWVMovLPAsDVG7A4jJR9rzECf67JUzxP8/ee/wA8clwIzJcWNFA=="
"requested": "[10.0.0, )",
"resolved": "10.0.0",
"contentHash": "kICGrGYEzCNI3wPzfEXcwNHgTvlvVn9yJDhSdRK+oZQy4jvYH529u7O0xf5ocQKzOMjfS07+3z9PKRIjrFMJDA=="
},
"Serilog": {
"type": "Direct",
Expand Down