forked from admin/VolcanicAgenticCore
- log an unknown stored zone once even when the tool description reads it first - serialise the flow's token write with /calendar_disconnect under the flow gate - a cancelled or expired pending flow is cleared, not re-sent or shown - chat keys anchor with \z so a trailing newline is hashed - a timeMax date includes that whole day (spec updated) - dispose the flow's CancellationTokenSource, drop ConnectFlow.Token, Begin is a plain write - GoogleCalendarOptions.IsConfigured replaces the host's copy of the rule; StoredToken is internal - test BotSetupService's menu through DI, tokens absent from tool results - Telegram.Tests csproj reference placed as in telegram-message-context; ChatHost passes calendar by name - docs: per-event timeZone, both config sources for /calendar_*
35 lines
1.1 KiB
C#
35 lines
1.1 KiB
C#
using System.Security.Cryptography;
|
|
using System.Text;
|
|
using Volcanic.AgenticCore.Extensions.GoogleCalendar;
|
|
|
|
namespace Volcanic.AgenticCore.Extensions.Tests.GoogleCalendar;
|
|
|
|
public class ChatKeysTests
|
|
{
|
|
[Theory]
|
|
[InlineData("telegram-111111111")]
|
|
[InlineData("a.b_c-D9")]
|
|
public void A_safe_scope_is_its_own_key(string scope) => Assert.Equal(scope, ChatKeys.For(scope));
|
|
|
|
[Theory]
|
|
[InlineData("a/b")]
|
|
[InlineData("..")]
|
|
[InlineData(".")]
|
|
[InlineData("")]
|
|
[InlineData("has space")]
|
|
[InlineData("c:\\x")]
|
|
[InlineData("telegram-1\n")] // a trailing newline: '$' alone would accept it
|
|
public void An_unsafe_scope_maps_to_a_hashed_key(string scope)
|
|
{
|
|
var expected = "scope-" + Convert.ToHexStringLower(SHA256.HashData(Encoding.UTF8.GetBytes(scope)))[..16];
|
|
Assert.Equal(expected, ChatKeys.For(scope));
|
|
}
|
|
|
|
[Fact]
|
|
public void A_scope_longer_than_100_characters_is_hashed()
|
|
{
|
|
Assert.Equal(new string('a', 100), ChatKeys.For(new string('a', 100)));
|
|
Assert.StartsWith("scope-", ChatKeys.For(new string('a', 101)));
|
|
}
|
|
}
|