Files
Claude aff81dfac9 Collegamento e motore: correzioni regole-1, regole-2, regole-6, websec-1, websec-5, websec-6, engine-1, engine-2, sched-1
Pagine aperte da Alberto non sono segnali (regole-1); cookie perso fuori sessione = disconnessione (regole-2); pagina a riposo quando Alberto lascia il browser (regole-6); la lease di «Accedi»/«Usa il browser» finisce da sola dopo 2 minuti senza vista remota né finestra (websec-1); ping con scadenza sulla vista remota (websec-5); aperture della vista remota serializzate (websec-6); orologio virtuale senza fine anticipata (engine-1); la sincronizzazione della coda non duplica il compito in corso (engine-2); raccolte in evidenza programmate (sched-1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_01Mzbb6zeFTjT6Rp8b92AVkA
2026-10-14 00:21:13 +00:00

41 lines
2.1 KiB
C#

using Febe.Core.Abstractions;
using Febe.Core.Collection;
using Febe.Tests.Browser.TestSupport;
namespace Febe.Tests.Collection;
/// <summary>
/// Rule 7 of §2 against §7.6: the pages Alberto opens while he drives and no session runs — the login of «Accedi a
/// Instagram», a verification he completes — are not the page «going back to the login»; Instagram's own answers
/// (status, text) still are signals.
/// </summary>
[TestClass]
public sealed class SignalOwnershipTests
{
[TestMethod]
public void PathRulesAreNotSignalsWhileThePageIsAlbertos()
{
var clock = new VirtualClock();
var breaker = new RecordingBreaker();
var albertos = true;
var detector = new SignalDetector(SignalRules.LoadDefault(), breaker, clock, TimeSpan.Zero) { UserOwnsPage = () => albertos };
NavigationDescriptor Nav(string path) => new(HostKind.Site, "https://www.instagram.com" + path, "www.instagram.com", path, clock.Now);
ResponseDescriptor Document(string path, int status) =>
new("1", HostKind.Site, "https://www.instagram.com" + path, "www.instagram.com", path, status, "text/html", "Document", true, clock.Now);
Assert.IsNull(detector.ObserveNavigation(Nav("/accounts/login/")));
Assert.IsNull(detector.ObserveNavigation(Nav("/challenge/AbC123/")));
Assert.IsNull(detector.ObserveResponse(Document("/accounts/login/", 200)));
Assert.IsEmpty(breaker.Signals);
// Instagram's own answers keep counting: a 429 is a 429 whoever loaded the page.
Assert.AreEqual(SignalLevel.Throttle, detector.ObserveResponse(Document("/accounts/login/", 429))?.Level);
Assert.IsFalse(detector.ObserveSessionCookie(false) is null, "the recipes' cookie check is not a path rule");
// The engine's page (Alberto not at the browser, or a session running): the same addresses are signals.
albertos = false;
Assert.AreEqual(SignalLevel.Disconnect, detector.ObserveNavigation(Nav("/accounts/login/"))?.Level);
Assert.AreEqual(SignalLevel.Challenge, detector.ObserveResponse(Document("/challenge/AbC123/", 200))?.Level);
}
}