Raccolta (M0/M2): sito di prova completo, lettori per forma, ricette su browser vero, coda degli scaricamenti, sonda con ripulitura e verifica; documenti delle ipotesi e delle prove dal vivo

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

Claude-Session: https://claude.ai/code/session_01Mzbb6zeFTjT6Rp8b92AVkA
This commit is contained in:
Claude committed 2026-10-13 17:32:35 +00:00
1 parent e2c987873b
commit 4fc5a6c0d4
74 files changed
+12689 -13

No files matched your search

@@ -0,0 +1,363 @@
using System.Collections.Concurrent;
using Febe.Browser.Targets;
using Febe.Core.Abstractions;
using Febe.Core.Collection;
using Febe.Core.Collection.Downloads;
using Febe.Core.Collection.Readers;
using Febe.Core.Collection.Recipes;
using Febe.Core.Domain;
using Febe.Core.Engine;
using Febe.Core.Storage;
using Febe.Tests.Browser.TestSupport;
using Febe.Tests.Collection.Support;
using Febe.Tests.Support;
namespace Febe.Tests.Collection;
/// <summary>Site map, recipe guards, the writer and the download queue, without a browser.</summary>
[TestClass]
public sealed class CollectionUnitTests
{
[TestMethod]
public void TheTestSiteMapBuildsAndReadsAddresses()
{
var map = SiteMap.LoadTestSite();
Assert.AreEqual("/profilo/marta.prova/", map.BuildPath(SitePages.Profile, new Dictionary<string, string> { ["username"] = "marta.prova" }));
Assert.AreEqual("/profilo/a%20b/?dopo=c%2612", map.BuildPath(SitePages.ProfileFrom, new Dictionary<string, string> { ["username"] = "a b", ["cursor"] = "c&12" }));
var story = map.Match(SitePages.StoryViewer, "/storie/marta.prova/7300105520/");
Assert.AreEqual("marta.prova", story!["username"]);
Assert.AreEqual("7300105520", story["id"]);
Assert.IsNull(map.Match(SitePages.StoryViewer, "/profilo/marta.prova/"));
Assert.IsNotNull(map.Match(SitePages.Home, "/"));
Assert.AreEqual(0, map.Missing(SitePages.All, SiteTargets.All).Count);
Assert.IsTrue(File.Exists(Path.Combine(AppContext.BaseDirectory, "config", "bersagli.prova.json")), "Editable without recompiling.");
}
[TestMethod]
public void TheInstagramMapIsASkeletonWithEveryEntryEmpty()
{
var map = SiteMap.LoadInstagram();
Assert.AreEqual("instagram", map.Site);
Assert.AreEqual(SitePages.All.Count + SiteTargets.All.Count, map.Missing(SitePages.All, SiteTargets.All).Count, "Nothing is filled in before M0.");
// The browser layer reads the same file: every target is a placeholder and is never looked up in the page.
var targets = TargetMap.LoadEmbedded("bersagli.instagram.json");
CollectionAssert.AreEquivalent(SiteTargets.All.ToArray(), targets.Targets.Keys.ToArray());
Assert.IsTrue(targets.Targets.Values.All(t => !t.IsConfigured && t.Hypothesis == "H11"));
var cdp = new FakeCdpSession(new VirtualClock());
var lookup = new TargetResolver(cdp, targets).ResolveAsync(SiteTargets.ViewerClose).GetAwaiter().GetResult();
Assert.AreEqual(TargetStatus.NotConfigured, lookup.Status);
Assert.AreEqual(0, cdp.Sent.Count, "A placeholder never reaches the page.");
StringAssert.Contains(lookup.Message, "H11");
}
[TestMethod]
public async Task RecipesRefuseToRunOnInstagramWhileTheMapOrTheReadersAreSkeletons()
{
using var temp = new TempFolder("ricette");
await using var db = await TestDatabase.OpenAsync(temp);
var clock = new VirtualClock();
var governor = new PermissiveGovernor();
var session = new TestSession((await db.Sessions.StartAsync(clock.Now)).Id);
RecipeEnvironment Environment(SiteMap map, ReaderVocabulary vocabulary) => new()
{
Driver = new UntouchableDriver(),
Capture = new CaptureCollector(new ShapeReader(vocabulary), clock),
Governor = governor,
Signals = new SignalDetector(SignalRules.LoadDefault(), new RecordingBreaker(), clock),
Storage = db,
SiteMap = map,
Clock = clock,
Random = new SeededRandom(1),
};
foreach (var kind in Enum.GetValues<RecipeKind>().Where(k => k != RecipeKind.FollowingSweep))
{
var outcome = await new RecipeRunner(Environment(SiteMap.LoadInstagram(), ReaderVocabulary.LoadTestSite()))
.RunAsync(new RecipeRequest(kind, 1), session, CancellationToken.None);
Assert.AreEqual(RecipeStatus.TargetNotFound, outcome.Status, kind.ToString());
StringAssert.Contains(outcome.Message, "mappa dei bersagli non è ancora compilata");
}
var sweep = await new RecipeRunner(Environment(SiteMap.LoadInstagram(), ReaderVocabulary.LoadTestSite()))
.RunAsync(new RecipeRequest(RecipeKind.FollowingSweep), session, CancellationToken.None);
StringAssert.Contains(sweep.Message, "pagina «home»");
var readers = await new RecipeRunner(Environment(SiteMap.LoadTestSite(), ReaderVocabulary.LoadInstagram()))
.RunAsync(new RecipeRequest(RecipeKind.FollowingSweep), session, CancellationToken.None);
Assert.AreEqual(RecipeStatus.UnrecognizedFormat, readers.Status);
StringAssert.Contains(readers.Message, "ipotesi");
Assert.AreEqual(0, governor.Requests.Count, "No permit asked, no gesture, no page.");
Assert.IsTrue((await db.Events.ListAsync(new EventQuery())).Any(e => e.Code == "mappa-incompleta"));
}
[TestMethod]
public void StoryTimingsFollowSection77()
{
var random = new SeededRandom(3);
for (var i = 0; i < 500; i++)
{
var photo = StoryTimings.Watch(random, null, 1.0);
Assert.IsTrue(photo >= TimeSpan.FromSeconds(1.8) && photo <= TimeSpan.FromSeconds(5), photo.ToString());
var video = StoryTimings.Watch(random, TimeSpan.FromSeconds(10), 1.0);
Assert.IsTrue(video >= TimeSpan.FromSeconds(4) && video <= TimeSpan.FromSeconds(10), video.ToString());
var longVideo = StoryTimings.Watch(random, TimeSpan.FromSeconds(60), 1.0);
Assert.IsTrue(longVideo <= TimeSpan.FromSeconds(15), "At most 15 s.");
var between = StoryTimings.BetweenAccounts(random, 1.0);
Assert.IsTrue(between >= TimeSpan.FromSeconds(1) && between <= TimeSpan.FromSeconds(4));
}
Assert.AreEqual(2 * StoryTimings.Watch(new SeededRandom(9), null, 1.0).Ticks, StoryTimings.Watch(new SeededRandom(9), null, 2.0).Ticks, 1, "Mood and pace multiply the waits.");
Assert.AreEqual("48.212", ItalianText.Number(48212));
Assert.AreEqual("1.000.000", ItalianText.Number(1_000_000));
Assert.AreEqual("96", ItalianText.Number(96));
}
[TestMethod]
public async Task TheWriterRecognizesImportedEntriesAndAppliesTheAccountSettings()
{
using var temp = new TempFolder("scrittore");
await using var library = await TestLibrary.CreateAsync(temp);
var db = library.Db;
var account = await db.Accounts.AddAsync(Make.Account("marta.prova", "1001") with
{
Limits = new AccountLimits { Depth = HistoryDepth.FromDate, FromDate = Make.T0.AddDays(-10), StoryVideos = false },
});
var writer = new CollectionWriter(db, library.Clock);
var imported = await db.Entries.AddAsync(new Entry
{
AccountId = account.Id,
Kind = EntryKind.Post,
PublishedAt = Make.T0.AddDays(-1),
Provenance = Provenance.Imported,
DiscoveredAt = Make.T0,
}, []);
var reader = new ShapeReader(ReaderVocabulary.LoadTestSite());
ContentItem Item(string id, DateTimeOffset at, bool video = false) => reader.Read($$"""
{"numero":"{{id}}","sigla":"S{{id}}","pubblicato":"{{at.UtcDateTime:yyyy-MM-ddTHH:mm:ssZ}}","testo":"didascalia","autore":{"numero":"1001","nome":"marta.prova"},
"{{(video ? "filmati" : "foto")}}":[{"indirizzo":"https://cdn.esempio/{{id}}.{{(video ? "mp4" : "jpg")}}","larghezza":10,"altezza":10,"audio":true}]}
""").Contents.Single();
var enriched = await writer.SaveAsync(account, Item("500", Make.T0.AddDays(-1).AddSeconds(1)), EntryKind.Post, null, CancellationToken.None);
Assert.AreEqual(SaveOutcome.Enriched, enriched.Outcome, "Same account, kind and time within two seconds (§9.5).");
var stored = await db.Entries.GetAsync(imported.Stored.Entry.Id);
Assert.AreEqual("500", stored!.InstagramId);
Assert.AreEqual("S500", stored.Code);
Assert.AreEqual(SaveOutcome.Excluded, (await writer.SaveAsync(account, Item("501", Make.T0.AddDays(-30)), EntryKind.Post, null, CancellationToken.None)).Outcome, "Older than «da una data».");
Assert.AreEqual(SaveOutcome.Excluded, (await writer.SaveAsync(account, Item("502", Make.T0), EntryKind.Tagged, null, CancellationToken.None)).Outcome, "«Post in cui è taggato» is off.");
Assert.AreEqual(SaveOutcome.Created, (await writer.SaveAsync(account, Item("503", Make.T0), EntryKind.Post, null, CancellationToken.None)).Outcome);
Assert.AreEqual(SaveOutcome.Known, (await writer.SaveAsync(account, Item("503", Make.T0), EntryKind.Post, null, CancellationToken.None)).Outcome);
var story = await writer.SaveAsync(account, Item("504", Make.T0, video: true), EntryKind.Story, null, CancellationToken.None);
var video = (await db.Media.ListByEntryAsync(story.Entry!.Id)).Single();
Assert.AreEqual(MediaState.Skipped, video.State, "«Video delle storie» is off: never downloaded.");
Assert.IsNull(video.SourceUrl);
}
[TestMethod]
public async Task TheQueueRecoversExpiredAddressesSkipsTooLargeVideosAndPutsStoriesFirst()
{
using var temp = new TempFolder("coda");
await using var library = await TestLibrary.CreateAsync(temp);
var db = library.Db;
var account = await db.Accounts.AddAsync(Make.Account("marta.prova", "1001") with { Limits = new AccountLimits { MaxVideoBytes = 1000 } });
var post = await AddAsync(db, account, "p1", EntryKind.Post, Make.Photo(), "https://cdn.esempio/scaduto.jpg");
var story = await AddAsync(db, account, "s1", EntryKind.Story, Make.Photo(), "https://cdn.esempio/storia-scaduta.jpg");
var video = await AddAsync(db, account, "v1", EntryKind.Post, Make.Video(), "https://cdn.esempio/grande.mp4");
var fine = await AddAsync(db, account, "f1", EntryKind.Story, Make.Photo(), "https://cdn.esempio/buono.jpg");
var fetcher = new FakeFetcher(uri => uri.AbsolutePath switch
{
"/scaduto.jpg" or "/storia-scaduta.jpg" => (FetchOutcome.HttpError, 403, null),
"/grande.mp4" => (FetchOutcome.Completed, 200, new byte[5000]),
_ => (FetchOutcome.Completed, 200, TestFile.PhotoBytes(3, 64, 80)),
});
var queue = new DownloadQueue(db, library.Ingest, fetcher, new FakeDataBudget(), library.Clock, new SeededRandom(1),
new DownloadOptions { StagingFolder = temp.Combine("dati", "temporanei"), MaxConcurrent = 1 });
var report = await queue.RunOnceAsync(CancellationToken.None);
Assert.AreEqual(1, report.Stored, report.ToString());
Assert.AreEqual(2, report.Expired);
Assert.AreEqual(1, report.Skipped);
CollectionAssert.AreEqual(new[] { "/storia-scaduta.jpg", "/buono.jpg" }, fetcher.Order.Take(2).ToArray(), "Stories first: they expire.");
Assert.AreEqual(MediaState.Expired, (await db.Media.ListByEntryAsync(post)).Single().State);
Assert.AreEqual(MediaState.Failed, (await db.Media.ListByEntryAsync(story)).Single().State, "No recovery for stories.");
var tasks = await db.Tasks.ListPendingAsync(10);
Assert.AreEqual(post.ToString(System.Globalization.CultureInfo.InvariantCulture), tasks.Single(t => t.Kind == EngineTaskKind.SinglePost).Payload);
var big = (await db.Media.ListByEntryAsync(video)).Single();
Assert.AreEqual(MediaState.Skipped, big.State);
StringAssert.Contains(big.LastError, "limite");
Assert.AreEqual(MediaState.Downloaded, (await db.Media.ListByEntryAsync(fine)).Single().State);
Assert.AreEqual(0, Directory.EnumerateFiles(temp.Combine("dati", "temporanei")).Count());
}
[TestMethod]
public async Task AFileIdenticalToAnImportedOneIsDiscardedAndTheImportedEntryTakesTheData()
{
using var temp = new TempFolder("doppioni");
await using var library = await TestLibrary.CreateAsync(temp);
var db = library.Db;
var account = await db.Accounts.AddAsync(Make.Account("marta.prova", "1001"));
var bytes = TestFile.PhotoBytes(11, 120, 150);
var imported = await library.SaveAsync(account, new Entry
{
AccountId = account.Id,
Kind = EntryKind.Post,
PublishedAt = Make.T0.AddDays(-3),
Provenance = Provenance.Imported,
DiscoveredAt = Make.T0,
}, [new TestFile(Make.Photo(), bytes, ".jpg")]);
var downloaded = await AddAsync(db, account, "777", EntryKind.Post, Make.Photo(), "https://cdn.esempio/stesso.jpg", caption: "dal sito");
var queue = new DownloadQueue(db, library.Ingest, new FakeFetcher(_ => (FetchOutcome.Completed, 200, bytes)), new FakeDataBudget(), library.Clock, new SeededRandom(1),
new DownloadOptions { StagingFolder = temp.Combine("dati", "temporanei") });
var report = await queue.RunOnceAsync(CancellationToken.None);
Assert.AreEqual(1, report.Duplicates, report.ToString());
Assert.IsNull(await db.Entries.GetAsync(downloaded), "The new record goes away.");
var merged = await db.Entries.GetAsync(imported.Entry.Id);
Assert.AreEqual("777", merged!.InstagramId);
Assert.AreEqual("dal sito", merged.Caption);
Assert.AreEqual(1, Directory.EnumerateFiles(library.Layout.AccountFolder(account), "*.jpg", SearchOption.AllDirectories).Count(), "One file in the library.");
}
[TestMethod]
public async Task TheQueueStopsAtTheDataBudgetAndNeverRunsMoreThanTwoAtOnce()
{
using var temp = new TempFolder("tetto");
await using var library = await TestLibrary.CreateAsync(temp);
var db = library.Db;
var account = await db.Accounts.AddAsync(Make.Account("marta.prova", "1001"));
for (var i = 0; i < 8; i++)
{
await AddAsync(db, account, $"p{i}", EntryKind.Post, Make.Photo(), $"https://cdn.esempio/{i}.jpg");
}
var fetcher = new FakeFetcher(uri => (FetchOutcome.Completed, 200, TestFile.PhotoBytes(int.Parse(uri.AbsolutePath[1..^4], System.Globalization.CultureInfo.InvariantCulture) + 20, 64, 80)))
{
Latency = TimeSpan.FromMilliseconds(30),
};
var queue = new DownloadQueue(db, library.Ingest, fetcher, new FakeDataBudget(), library.Clock, new SeededRandom(1),
new DownloadOptions { StagingFolder = temp.Combine("dati", "temporanei") });
Assert.AreEqual(8, (await queue.RunOnceAsync(CancellationToken.None)).Stored);
Assert.AreEqual(2, fetcher.MaxConcurrent, "At most two at the same time (§6.5).");
for (var i = 8; i < 12; i++)
{
await AddAsync(db, account, $"p{i}", EntryKind.Post, Make.Photo(), $"https://cdn.esempio/{i}.jpg");
}
var budget = new FakeDataBudget(bytesPerDay: 1);
var limited = new DownloadQueue(db, library.Ingest, fetcher, budget, library.Clock, new SeededRandom(1),
new DownloadOptions { StagingFolder = temp.Combine("dati", "temporanei"), MaxConcurrent = 1 });
var report = await limited.RunOnceAsync(CancellationToken.None);
Assert.IsTrue(report.BudgetReached);
Assert.AreEqual(1, report.Stored, "The budget is checked before each file.");
Assert.AreEqual(3, await db.Media.CountPendingDownloadsAsync());
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => new DownloadQueue(db, library.Ingest, fetcher, budget, library.Clock, new SeededRandom(1),
new DownloadOptions { StagingFolder = temp.Path, MaxConcurrent = 3 }));
}
private static async Task<long> AddAsync(IFebeStorage db, Account account, string id, EntryKind kind, Media media, string url, string? caption = null)
{
var entry = new Entry
{
AccountId = account.Id,
Kind = kind,
InstagramId = id,
Code = "C" + id,
PublishedAt = Make.T0.AddHours(-id.Length),
Caption = caption,
DiscoveredAt = Make.T0,
ExpiresAt = kind == EntryKind.Story ? Make.T0.AddHours(20) : null,
};
var added = await db.Entries.AddAsync(entry, [media with { SourceUrl = url, SourceSeenAt = Make.T0 }]);
return added.Stored.Entry.Id;
}
/// <summary>A file fetcher answering from a table: no network at all.</summary>
private sealed class FakeFetcher(Func<Uri, (FetchOutcome Outcome, int? Status, byte[]? Bytes)> answer) : IFileFetcher
{
private int _current;
private int _max;
public ConcurrentQueue<string> Calls { get; } = new();
public IReadOnlyList<string> Order => [.. Calls];
public TimeSpan Latency { get; init; }
public int MaxConcurrent => Volatile.Read(ref _max);
public async Task<FetchResult> FetchAsync(Uri address, Stream destination, FetchOptions? options, CancellationToken ct)
{
Calls.Enqueue(address.AbsolutePath);
var now = Interlocked.Increment(ref _current);
int seen;
while ((seen = Volatile.Read(ref _max)) < now && Interlocked.CompareExchange(ref _max, now, seen) != seen)
{
}
try
{
if (Latency > TimeSpan.Zero)
{
await Task.Delay(Latency, ct);
}
var (outcome, status, bytes) = answer(address);
if (bytes is null)
{
return new FetchResult(outcome, 0, status, "errore di prova");
}
if (options?.MaxBytes is { } max && bytes.Length > max)
{
await destination.WriteAsync(bytes.AsMemory(0, (int)max), ct);
return new FetchResult(FetchOutcome.TooLarge, max, status, "troppo grande");
}
await destination.WriteAsync(bytes, ct);
return new FetchResult(outcome, bytes.Length, status, null);
}
finally
{
Interlocked.Decrement(ref _current);
}
}
}
/// <summary>A driver that fails the test if a recipe touches it.</summary>
private sealed class UntouchableDriver : IPageDriver
{
public double WaitMultiplier => 1;
public void BeginSession(double mood)
{
}
public Task<PageLoad> OpenAsync(string path, CancellationToken ct) => throw new AssertFailedException("La ricetta ha aperto una pagina.");
public Task<string> CurrentPathAsync(CancellationToken ct) => throw new AssertFailedException("La ricetta ha letto la pagina.");
public Task<bool> IsOnSiteAsync(CancellationToken ct) => throw new AssertFailedException("La ricetta ha letto la pagina.");
public Task<TargetCheck> FindAsync(string target, IReadOnlyDictionary<string, string>? parameters, CancellationToken ct) => throw new AssertFailedException("La ricetta ha cercato un bersaglio.");
public Task<TargetCheck> ClickAsync(string target, IReadOnlyDictionary<string, string>? parameters, CancellationToken ct) => throw new AssertFailedException("La ricetta ha cliccato.");
public Task ScrollBurstAsync(CancellationToken ct) => throw new AssertFailedException("La ricetta ha scorso la pagina.");
public Task WaitAfterLoadAsync(CancellationToken ct) => Task.CompletedTask;
public Task WaitAsync(TimeSpan duration, CancellationToken ct) => Task.CompletedTask;
public Task<bool> MaybeDistractionAsync(CancellationToken ct) => Task.FromResult(false);
public Task<bool?> HasSessionCookieAsync(CancellationToken ct) => throw new AssertFailedException("La ricetta ha controllato il cookie.");
public Task RestAsync(CancellationToken ct) => Task.CompletedTask;
}
}
@@ -0,0 +1,121 @@
using System.Collections.Concurrent;
using System.Text.Json;
using Febe.Browser.Cdp;
using Febe.Browser.Gestures;
using Febe.Core.Abstractions;
using Febe.Core.Collection;
using Febe.SitoDiProva;
using Febe.Sonda;
using Febe.Tests.Collection.Support;
using Febe.Tests.Support;
namespace Febe.Tests.Collection;
/// <summary>
/// The passive probe (spec §14.5) on the local test site: the test plays Alberto (it navigates and moves the mouse),
/// the probe only listens. Then the whole M0 path: raw samples, cleaning, verification.
/// </summary>
[TestClass]
[DoNotParallelize]
public sealed class ProbeIntegrationTests
{
private static SharedChromium? s_chromium;
private static string? s_unavailable;
public TestContext TestContext { get; set; } = null!;
[ClassInitialize]
public static async Task StartAsync(TestContext context)
{
s_unavailable = SharedChromium.UnavailableReason();
if (s_unavailable is null)
{
s_chromium = await SharedChromium.StartAsync();
}
}
[ClassCleanup]
public static async Task StopAsync()
{
if (s_chromium is not null)
{
await s_chromium.DisposeAsync();
s_chromium = null;
}
}
[TestMethod]
[Timeout(60_000, CooperativeCancellation = true)]
public async Task TheProbeRecordsResponsesAndTargetsWithoutGesturesAndItsSamplesCleanUp()
{
if (s_unavailable is not null)
{
Assert.Inconclusive(s_unavailable);
}
await using var site = await TestSite.StartAsync();
using var temp = new TempFolder("sonda");
var raw = temp.Combine("grezzi");
var hosts = new HostClassifier([site.SiteHost], [site.CdnHost]);
var recording = new RecordingCdp(s_chromium!.Cdp);
await using (var probe = new ProbeRecorder(recording, hosts, raw, pollEvery: TimeSpan.FromMilliseconds(100)))
{
await probe.StartAsync();
// Alberto opens a profile and points at the «Reel» tab.
var cdp = s_chromium.Cdp;
await cdp.NavigateAsync(site.Url("/profilo/marta.prova/"));
await cdp.WaitForLoadAsync(new SystemClock(), TimeSpan.FromSeconds(10));
await Task.Delay(800);
var tab = await cdp.EvaluateAsync("(() => { const r = [...document.querySelectorAll('a[role=tab]')].find((a) => a.textContent === 'Reel').getBoundingClientRect(); return { x: r.left + r.width / 2, y: r.top + r.height / 2 }; })()");
var alberto = new HumanGestures(cdp, new SystemClock(), new SeededRandom(5));
await alberto.MoveToAsync(new PagePoint(tab.GetProperty("x").GetDouble(), tab.GetProperty("y").GetDouble()));
await Task.Delay(600);
await probe.StopAsync();
Assert.IsTrue(probe.Stats.Responses >= 1, "The profile data was recorded.");
}
Assert.IsFalse(recording.Methods.Any(m => m.StartsWith("Input.", StringComparison.Ordinal)), "The probe never performs a gesture.");
Assert.IsFalse(recording.Methods.Contains("Page.navigate"), "The probe never opens a page by itself.");
Assert.IsTrue(File.Exists(Path.Combine(raw, "LEGGIMI.txt")));
var responses = Directory.EnumerateFiles(Path.Combine(raw, "risposte")).ToList();
Assert.IsTrue(responses.Count >= 1);
using (var sample = JsonDocument.Parse(File.ReadAllText(responses[0])))
{
var url = sample.RootElement.GetProperty("descrittore").GetProperty("indirizzo").GetString()!;
Assert.IsFalse(url.Contains('?', StringComparison.Ordinal), "Never the query string.");
Assert.AreEqual("sito", sample.RootElement.GetProperty("descrittore").GetProperty("host").GetString());
Assert.IsTrue(sample.RootElement.GetProperty("corpo").TryGetProperty("profilo", out _));
}
var interactions = File.ReadAllLines(Path.Combine(raw, "interazioni.jsonl"));
Assert.IsTrue(
interactions.Any(l => l.Contains("\"sopra\"", StringComparison.Ordinal) && l.Contains("\"role\":\"tab\"", StringComparison.Ordinal) && l.Contains("Reel", StringComparison.Ordinal)),
"The hovered tab is described with role and accessible name: " + string.Join(" | ", interactions));
Assert.IsTrue(File.ReadAllText(Path.Combine(raw, "navigazioni.jsonl")).Contains("/profilo/marta.prova/", StringComparison.Ordinal));
// M0 path: clean, then verify.
var clean = temp.Combine("ripuliti");
new SampleSanitizer(hosts: hosts).SanitizeFolder(raw, clean);
var report = SampleVerifier.Verify(raw, clean);
Assert.IsTrue(report.Passed, string.Join("; ", report.Leaks.Select(l => $"{l.CleanFile} {l.Length} {l.Kind}")));
Assert.IsTrue(File.ReadLines(Path.Combine(clean, "interazioni.jsonl")).Any(l => l.Contains("\"role\":\"tab\"", StringComparison.Ordinal)), "Roles survive the cleaning.");
}
/// <summary>Forwards to the browser and records the command names (never parameters).</summary>
private sealed class RecordingCdp(ICdpSession inner) : ICdpSession
{
private readonly ConcurrentQueue<string> _methods = new();
public IReadOnlyList<string> Methods => [.. _methods];
public Task<JsonElement> SendAsync(string method, object? parameters = null, CancellationToken ct = default)
{
_methods.Enqueue(method);
return inner.SendAsync(method, parameters, ct);
}
public IDisposable On(string eventName, Action<JsonElement> handler) => inner.On(eventName, handler);
}
}
+253
View File
@@ -0,0 +1,253 @@
using System.Text.Json;
using Febe.Core.Collection;
using Febe.Core.Collection.Readers;
using Febe.Core.Domain;
namespace Febe.Tests.Collection;
/// <summary>
/// The generic reader (spec §6.4) on the cleaned samples of <c>tests/campioni/prova</c>: captured from the test site,
/// cleaned with «febe-sonda ripulisci» and checked with «febe-sonda verifica». Never real Instagram samples: there
/// are none yet (rule 10).
/// </summary>
[TestClass]
public sealed class ReaderTests
{
private static readonly ShapeReader Reader = new(ReaderVocabulary.LoadTestSite());
private static ReadResult ReadSample(string name)
{
var file = Directory.EnumerateFiles(Path.Combine(AppContext.BaseDirectory, "campioni", "prova"), $"*-{name}.json").Single();
using var document = JsonDocument.Parse(File.ReadAllText(file));
return Reader.Read(document.RootElement.GetProperty("corpo"));
}
[TestMethod]
public void APostWithSeveralFilesKeepsTheirOrderAndTheBestVersions()
{
var result = ReadSample("post-serie");
Assert.AreEqual(ReadShape.Recognized, result.Shape);
var post = result.Contents.Single();
Assert.IsTrue(post.IsComplete);
Assert.IsNotNull(post.Code);
Assert.AreEqual(3, post.Files.Count);
CollectionAssert.AreEqual(new[] { MediaKind.Photo, MediaKind.Video, MediaKind.Photo }, post.Files.Select(f => f.Kind).ToArray());
Assert.AreEqual((960, 1200), (post.Files[0].Best.Width, post.Files[0].Best.Height), "The largest image, not the first one.");
Assert.IsTrue(post.Files.All(f => f.InstagramId is not null), "Files of a series have their own identifiers.");
Assert.IsNotNull(post.Owner);
}
[TestMethod]
public void AVideoTakesTheBestRenditionWithAudioAndItsCover()
{
var video = ReadSample("post-serie").Contents.Single().Files[1];
Assert.AreEqual(MediaKind.Video, video.Kind);
Assert.AreEqual(720, video.Best.Width, "The 1080 rendition has no audio.");
Assert.AreEqual(true, video.Best.HasAudio);
Assert.AreEqual(TimeSpan.FromSeconds(2), video.Duration);
Assert.IsNotNull(video.Cover);
Assert.AreEqual(720, video.Cover.Width);
var stories = ReadSample("storie").Contents;
Assert.AreEqual(4, stories.Count);
Assert.IsTrue(stories.All(s => s.ExpiresAt > s.TakenAt));
Assert.AreEqual(1, stories.Count(s => s.Files[0].Kind == MediaKind.Video));
Assert.AreEqual(1, stories.Select(s => s.Owner!.Id).Distinct().Count(), "The author of the list is inherited by every story.");
}
[TestMethod]
public void APrivateProfileNotFollowedGivesItsStateAndNoContent()
{
var result = ReadSample("profilo-privato-non-seguito");
Assert.AreEqual(ReadShape.Recognized, result.Shape);
var profile = result.Profiles.Single();
Assert.AreEqual(true, profile.IsPrivate);
Assert.AreEqual(false, profile.IsFollowed);
Assert.AreEqual(0, result.Contents.Count);
Assert.AreEqual(false, result.Page?.HasMore);
}
[TestMethod]
public void AnEmptyPageIsEmptyNotUnknown()
{
var result = ReadSample("pagina-vuota");
Assert.AreEqual(ReadShape.Empty, result.Shape);
Assert.AreEqual(false, result.Page?.HasMore);
Assert.IsNull(result.KeyStructure);
}
[TestMethod]
public void AnUnknownShapeIsReportedWithItsKeyStructureOnly()
{
var file = Directory.EnumerateFiles(Path.Combine(AppContext.BaseDirectory, "campioni", "prova"), "*-forma-sconosciuta.json").Single();
using var document = JsonDocument.Parse(File.ReadAllText(file));
var body = document.RootElement.GetProperty("corpo");
var result = Reader.Read(body);
Assert.AreEqual(ReadShape.Unrecognized, result.Shape);
Assert.AreEqual("{risultati:{voci:[{chiave,valore,dettagli:{x,y}}]},versione}", result.KeyStructure);
foreach (var value in body.GetProperty("risultati").GetProperty("voci").EnumerateArray().Select(v => v.GetProperty("valore").GetString()!))
{
Assert.IsFalse(result.KeyStructure!.Contains(value, StringComparison.Ordinal), "No value in the event.");
}
}
[TestMethod]
public void TheHomeGivesTheConnectedAccountTheStoriesBarAndIncompleteSeries()
{
var result = ReadSample("inizio");
Assert.IsNotNull(result.Viewer, "H10 on the test site: the connected account comes with the data.");
var bar = result.Profiles.Where(p => p.LatestStoryAt is not null).ToList();
Assert.AreEqual(4, bar.Count);
Assert.AreEqual(6, result.Contents.Count);
Assert.IsTrue(result.Contents.Any(c => !c.IsComplete && c.Files.Count == 1), "A series with only its first file: incomplete.");
Assert.AreEqual(true, result.Page?.HasMore);
Assert.AreEqual(2, result.Page?.Cursor?.Length, "An opaque resume point (cleaned: same shape as «c6»).");
}
[TestMethod]
public void AProfilePageGivesPinnedPostsHighlightsAndTheNextPage()
{
var result = ReadSample("profilo-pubblico");
Assert.AreEqual(12, result.Contents.Count);
Assert.AreEqual(2, result.Contents.Count(c => c.Pinned));
Assert.IsTrue(result.Contents.Take(2).All(c => c.Pinned), "Pinned posts come first on the grid.");
CollectionAssert.AreEqual(new[] { "Qspblr", "Flvwvq" }.Select(t => t.Length).ToArray(), result.Highlights.Select(h => h.Title.Length).ToArray());
Assert.AreEqual(3, result.Page?.Cursor?.Length);
var profile = result.Profiles.First(p => p.PostCount is not null);
Assert.AreEqual(18, profile.PostCount);
Assert.IsNotNull(profile.Picture);
Assert.AreEqual(320, profile.Picture.Width, "The largest profile picture.");
}
[TestMethod]
public void AHighlightCarriesItsItemsInOrder()
{
var result = ReadSample("raccolta");
var highlight = result.Highlights.Single();
Assert.AreEqual(3, highlight.Items.Count);
Assert.IsTrue(highlight.Items.All(i => i.HighlightId == highlight.Id));
CollectionAssert.AreEqual(new[] { 0, 1, 2 }, highlight.Items.Select(i => i.Order).ToArray());
}
[TestMethod]
public void TheFollowingListAndTheTaggedTabAreRead()
{
var following = ReadSample("seguiti");
Assert.AreEqual(10, following.Profiles.Count);
Assert.AreEqual(3, following.Page?.Cursor?.Length);
var tagged = ReadSample("taggati");
Assert.AreEqual(3, tagged.Contents.Count);
Assert.AreEqual(1, tagged.Profiles.Count(p => p.PostCount is not null), "The tagged account itself.");
Assert.IsTrue(tagged.Contents.All(c => c.Owner!.Id != tagged.Profiles.First(p => p.PostCount is not null).Id), "Tagged posts belong to others.");
}
[TestMethod]
public void DatesAreReadAsIsoTextOrUnixSeconds()
{
var iso = Reader.Read("""{"numero":"1","pubblicato":"2026-10-13T08:00:00Z","foto":[{"indirizzo":"https://cdn.esempio/a.jpg","larghezza":1,"altezza":1}]}""");
var unix = Reader.Read("""{"numero":"1","pubblicato":1791878400,"foto":[{"indirizzo":"https://cdn.esempio/a.jpg","larghezza":1,"altezza":1}]}""");
var millis = Reader.Read("""{"numero":"1","pubblicato":1791878400000,"foto":[{"indirizzo":"https://cdn.esempio/a.jpg","larghezza":1,"altezza":1}]}""");
Assert.AreEqual(new DateTimeOffset(2026, 10, 13, 8, 0, 0, TimeSpan.Zero), iso.Contents.Single().TakenAt);
Assert.AreEqual(unix.Contents.Single().TakenAt, millis.Contents.Single().TakenAt);
}
[TestMethod]
public void AVideoWithoutAnyAudioRenditionTakesTheLargest()
{
var result = Reader.Read("""
{"numero":"9","pubblicato":"2026-10-13T08:00:00Z","durata":3.5,
"filmati":[{"indirizzo":"https://cdn.esempio/a.mp4","larghezza":360,"altezza":640,"audio":false},
{"indirizzo":"https://cdn.esempio/b.mp4","larghezza":720,"altezza":1280,"audio":false}]}
""");
var file = result.Contents.Single().Files.Single();
Assert.AreEqual(720, file.Best.Width);
Assert.AreEqual(TimeSpan.FromSeconds(3.5), file.Duration);
}
[TestMethod]
public void MappingGivesDomainRecords()
{
var item = ReadSample("post-serie").Contents.Single();
var now = new DateTimeOffset(2026, 10, 13, 9, 0, 0, TimeSpan.Zero);
var entry = ReadMapping.ToEntry(item, 7, EntryKind.Post, now);
Assert.AreEqual(item.Id, entry.InstagramId);
Assert.AreEqual(item.Code, entry.Code);
Assert.AreEqual(item.TakenAt, entry.PublishedAt);
Assert.IsNull(entry.ExpiresAt);
var media = ReadMapping.ToMedia(item, now);
CollectionAssert.AreEqual(new[] { 1, 2, 3 }, media.Select(m => m.Position).ToArray());
Assert.IsTrue(media.All(m => m.SourceUrl is not null && m.SourceSeenAt == now));
Assert.IsNotNull(media[1].CoverUrl);
var story = ReadSample("storie").Contents[0];
Assert.AreEqual(story.ExpiresAt, ReadMapping.ToEntry(story, 7, EntryKind.Story, now).ExpiresAt);
var tagged = ReadMapping.ToEntry(item, 7, EntryKind.Tagged, now);
Assert.AreEqual(item.Owner!.Username, tagged.AuthorUsername);
}
[TestMethod]
public void KeyStructureHidesIdentifierKeysAndValues()
{
using var document = JsonDocument.Parse("""{"elenco":{"17841400000":{"nome":"segreto"},"17841400001":{"nome":"altro"}},"conteggio":2,"lista":[]}""");
var structure = KeyStructure.Describe(document.RootElement);
Assert.AreEqual("{elenco:{#:{nome}},conteggio,lista:[]}", structure);
Assert.IsTrue(KeyStructure.LooksLikeIdentifier("17841400000"));
Assert.IsTrue(KeyStructure.LooksLikeIdentifier("a1b2c3d4e5f6a7b8c9"));
Assert.IsFalse(KeyStructure.LooksLikeIdentifier("image_versions2"));
Assert.IsFalse(KeyStructure.LooksLikeIdentifier("larghezza"));
}
[TestMethod]
public void TheShippedVocabulariesLoadAndInstagramsIsOnlyAHypothesis()
{
var test = ReaderVocabulary.LoadTestSite();
Assert.IsTrue(test.IsUsable, test.UnusableReason);
Assert.IsTrue(File.Exists(Path.Combine(AppContext.BaseDirectory, "config", "lettori.prova.json")), "Editable without recompiling.");
Assert.IsTrue(File.Exists(Path.Combine(AppContext.BaseDirectory, "config", "lettori.instagram.json")));
var instagram = ReaderVocabulary.LoadInstagram();
Assert.AreEqual(VocabularyStatus.Hypothesis, instagram.Status);
Assert.IsFalse(instagram.IsUsable);
StringAssert.Contains(instagram.UnusableReason, "ipotesi");
StringAssert.Contains(instagram.Note, "IPOTESI, DA CONFERMARE CON I CAMPIONI DI M0");
// Only the hint keys of spec §6.4: nothing invented (rule 10).
var keys = new[]
{
instagram.Content.Id, instagram.Content.Code, instagram.Content.TakenAt, instagram.Content.Caption, instagram.Content.Images,
instagram.Content.Videos, instagram.Content.Children, instagram.Content.ChildCount, instagram.Content.Owner, instagram.Content.Pinned,
instagram.Content.ExpiresAt, instagram.Content.Duration, instagram.Version.Url, instagram.Version.Width, instagram.Version.Height,
instagram.Version.HasAudio, instagram.Profile.Id, instagram.Profile.Username, instagram.Profile.DisplayName, instagram.Profile.IsPrivate,
instagram.Profile.IsFollowed, instagram.Profile.PostCount, instagram.Profile.Picture, instagram.Profile.LatestStoryAt,
instagram.Highlight.Id, instagram.Highlight.Title, instagram.Highlight.Owner, instagram.Highlight.Items,
instagram.Page.HasMore, instagram.Page.Cursor, instagram.Viewer,
}.SelectMany(k => k.Paths).Order().ToArray();
CollectionAssert.AreEqual(new[] { "carousel_media", "code", "image_versions2.candidates", "pk", "taken_at", "video_versions" }, keys);
}
[TestMethod]
[DataRow("""{ "site": "x", "content": { "id": ["a"], "colore": ["b"] } }""", DisplayName = "Unknown concepts are refused")]
[DataRow("""{ "content": {} }""", DisplayName = "The site is required")]
[DataRow("""{ "site": "x", "status": "forse" }""", DisplayName = "Unknown status")]
[DataRow("""{ "site": """, DisplayName = "Broken JSON")]
public void InvalidVocabulariesAreRefused(string json) =>
Assert.ThrowsExactly<InvalidDataException>(() => ReaderVocabulary.Parse(json, "lettori.test.json"));
[TestMethod]
public void TheCollectorKeepsReadsInOrderAndTracksPendingBodies()
{
var clock = new Febe.Tests.Browser.TestSupport.VirtualClock();
var collector = new Febe.Core.Collection.Recipes.CaptureCollector(Reader, clock);
var observer = (IResponseObserver)collector;
var descriptor = new ResponseDescriptor("r1", HostKind.Site, "http://127.0.0.1/dati", "127.0.0.1", "/dati", 200, "application/json", "Fetch", false, clock.Now);
observer.OnResponse(descriptor);
Assert.AreEqual(1, collector.Pending);
var mark = collector.Mark();
using var document = JsonDocument.Parse("""{"contenuti":[],"pagina":{"altro":false}}""");
collector.Accept(descriptor, document.RootElement);
Assert.AreEqual(0, collector.Pending);
Assert.AreEqual(ReadShape.Empty, collector.Since(mark).Single().Result.Shape);
Assert.IsNull(collector.Accept(descriptor with { HostKind = HostKind.Cdn }, document.RootElement), "Only the site's data is read.");
}
}
@@ -0,0 +1,420 @@
using Febe.Core.Abstractions;
using Febe.Core.Collection.Recipes;
using Febe.Core.Domain;
using Febe.Core.Engine;
using Febe.Core.Storage;
using Febe.SitoDiProva;
using Febe.Tests.Collection.Support;
namespace Febe.Tests.Collection;
/// <summary>
/// Every recipe of spec §6.3 against the local test site, with a real Chromium on a private Xvfb display. Never
/// Instagram. Time is compressed (a 2.2 s wait lasts about 0.2 s); the browser is shared and the tests run one at a time.
/// </summary>
[TestClass]
[DoNotParallelize]
public sealed class RecipeIntegrationTests
{
private static SharedChromium? s_chromium;
private static string? s_unavailable;
public TestContext TestContext { get; set; } = null!;
private static SharedChromium Chromium => s_chromium ?? throw new InvalidOperationException("Browser non avviato.");
[ClassInitialize]
public static async Task StartAsync(TestContext context)
{
s_unavailable = SharedChromium.UnavailableReason();
if (s_unavailable is null)
{
s_chromium = await SharedChromium.StartAsync();
}
}
[ClassCleanup]
public static async Task StopAsync()
{
if (s_chromium is not null)
{
await s_chromium.DisposeAsync();
s_chromium = null;
}
}
[TestInitialize]
public void RequireBrowser()
{
if (s_unavailable is not null)
{
Assert.Inconclusive(s_unavailable);
}
}
[TestMethod]
[Timeout(60_000, CooperativeCancellation = true)]
public async Task ProfileCheckReadsTheFirstPageSkipsPinnedPostsAndStopsAtKnownContent()
{
await using var h = await CollectionHarness.CreateAsync(Chromium);
var marta = await h.AddAccountAsync("marta.prova");
var first = await h.RunAsync(RecipeKind.ProfileCheck, marta.Id);
Assert.AreEqual(RecipeStatus.Completed, first.Status, first.Message);
Assert.AreEqual(1, first.CountedActions, "One profile opened.");
Assert.AreEqual(1, h.Governor.Granted(ActionKind.ProfileOpen));
var posts = await h.Db.Entries.ListByAccountAsync(marta.Id, new EntryListOptions { Kind = EntryKind.Post });
Assert.AreEqual(12, posts.Count, "The first page of the grid: 2 pinned and 10 recent posts.");
Assert.AreEqual(1, (await h.Db.Entries.ListByAccountAsync(marta.Id, new EntryListOptions { Kind = EntryKind.ProfilePicture })).Count);
Assert.AreEqual(13, first.NewEntries);
var highlights = await h.Db.Highlights.ListAsync(marta.Id);
CollectionAssert.AreEqual(new[] { "Estate", "Viaggi" }, highlights.Select(x => x.Title).ToArray());
var account = await h.Db.Accounts.GetAsync(marta.Id);
Assert.AreEqual("c12", account!.BackfillCursor, "The backfill resumes after the first page.");
Assert.AreEqual(18, account.PostCount);
Assert.IsTrue(first.AccountsWithStories.Contains(marta.Id), "Marta has active stories.");
// Largest image version, best video with audio, every file of the series.
var series = posts.First(p => p.Code is not null && h.Site.World.FindPost(p.Code)!.Files.Count == 3);
var files = await h.Db.Media.ListByEntryAsync(series.Id);
Assert.AreEqual(3, files.Count);
Assert.AreEqual(960, files[0].Width);
Assert.AreEqual(MediaKind.Video, files[1].Kind);
Assert.AreEqual(720, files[1].Width, "The 1080 rendition has no audio: not chosen.");
StringAssert.DoesNotMatch(files[1].SourceUrl!, new System.Text.RegularExpressions.Regex("muto"));
// A new post on top; pinned posts are known but do not stop the check before reaching it.
lock (h.Site.World.Gate)
{
h.Site.World.Publish(h.Site.World.FindByUsername("marta.prova")!, "foto", DateTimeOffset.UtcNow);
}
var second = await h.RunAsync(RecipeKind.ProfileCheck, marta.Id);
Assert.AreEqual(RecipeStatus.Completed, second.Status, second.Message);
Assert.AreEqual(1, second.NewEntries, "Only the new post.");
Assert.AreEqual(13, (await h.Db.Entries.ListByAccountAsync(marta.Id, new EntryListOptions { Kind = EntryKind.Post })).Count);
// A new profile picture: a second copy, named by the first eight hex digits of its SHA-256 once downloaded.
lock (h.Site.World.Gate)
{
h.Site.World.FindByUsername("marta.prova")!.PictureVersion++;
}
var third = await h.RunAsync(RecipeKind.ProfileCheck, marta.Id);
Assert.AreEqual(1, third.NewEntries, third.Message);
Assert.AreEqual(2, (await h.Db.Entries.ListByAccountAsync(marta.Id, new EntryListOptions { Kind = EntryKind.ProfilePicture })).Count);
}
[TestMethod]
[Timeout(60_000, CooperativeCancellation = true)]
public async Task UnreachableProfilesAreRecognizedAndNotTouched()
{
await using var h = await CollectionHarness.CreateAsync(Chromium);
var hidden = await h.AddAccountAsync("riservato.prova", withId: false);
var missing = await h.Db.Accounts.AddAsync(Account.Create("nessuno.prova", StartingPoint.EverythingAndKeepUpdated, h.Clock.Now, h.Clock.LocalZone));
var privateOutcome = await h.RunAsync(RecipeKind.ProfileCheck, hidden.Id);
Assert.AreEqual(RecipeStatus.AccountUnreachable, privateOutcome.Status, privateOutcome.Message);
var stored = await h.Db.Accounts.GetAsync(hidden.Id);
Assert.AreEqual(AccountState.Unreachable, stored!.State);
Assert.AreEqual(UnreachableReason.PrivateNotFollowed, stored.UnreachableReason);
Assert.AreEqual("1006", stored.InstagramId, "The identifier is learnt from the data.");
Assert.AreEqual(0, (await h.Db.Entries.ListByAccountAsync(hidden.Id)).Count);
var missingOutcome = await h.RunAsync(RecipeKind.ProfileCheck, missing.Id);
Assert.AreEqual(RecipeStatus.AccountUnreachable, missingOutcome.Status, missingOutcome.Message);
Assert.AreEqual(UnreachableReason.NotFound, (await h.Db.Accounts.GetAsync(missing.Id))!.UnreachableReason);
}
[TestMethod]
[Timeout(90_000, CooperativeCancellation = true)]
public async Task FollowingSweepSavesRecentPostsFlagsStoriesAndStopsAtKnownContent()
{
await using var h = await CollectionHarness.CreateAsync(Chromium);
var marta = await h.AddAccountAsync("marta.prova");
var nadia = await h.AddAccountAsync("nadia.prova");
var luca = await h.AddAccountAsync("luca.prova");
var first = await h.RunAsync(RecipeKind.FollowingSweep);
Assert.AreEqual(RecipeStatus.Completed, first.Status, first.Message);
Assert.AreEqual(1, first.CountedActions, "Only the home is counted.");
Assert.AreEqual(1, h.Governor.Granted(ActionKind.Home));
Assert.IsTrue(first.NewEntries > 0);
CollectionAssert.IsSubsetOf(new[] { marta.Id, nadia.Id, luca.Id }, first.AccountsWithStories.ToArray(), "The stories bar flags followed accounts with active stories.");
Assert.IsTrue(first.AccountsWithNewPosts.Contains(marta.Id));
var mine = await h.Db.Accounts.GetMineAsync();
Assert.AreEqual("alberto.prova", mine?.Username, "The connected account is learnt from the data (H10).");
// Series arrive incomplete in the home: saved with what came, completed later by «Post singolo».
var tasks = await h.Db.Tasks.ListPendingAsync(100);
Assert.IsTrue(tasks.Any(t => t.Kind == EngineTaskKind.SinglePost), "An incomplete series queues «Post singolo».");
var second = await h.RunAsync(RecipeKind.FollowingSweep);
Assert.AreEqual(RecipeStatus.Completed, second.Status, second.Message);
Assert.AreEqual(0, second.NewEntries, "Known content at the top: nothing new.");
Assert.IsTrue(h.Site.Control.DataRequests.Count(r => r.StartsWith("/dati/inizio", StringComparison.Ordinal)) >= 2);
}
[TestMethod]
[Timeout(90_000, CooperativeCancellation = true)]
public async Task SinglePostCompletesASeriesThatArrivedIncomplete()
{
await using var h = await CollectionHarness.CreateAsync(Chromium);
await h.AddAccountAsync("marta.prova");
await h.AddAccountAsync("luca.prova");
await h.AddAccountAsync("giulia.prova");
Assert.AreEqual(RecipeStatus.Completed, (await h.RunAsync(RecipeKind.FollowingSweep)).Status);
var task = (await h.Db.Tasks.ListPendingAsync(100)).First(t => t.Kind == EngineTaskKind.SinglePost);
var entryId = long.Parse(task.Payload!, System.Globalization.CultureInfo.InvariantCulture);
Assert.AreEqual(1, (await h.Db.Media.ListByEntryAsync(entryId)).Count);
var outcome = await h.RunAsync(RecipeKind.SinglePost, task.AccountId, entryId);
Assert.AreEqual(RecipeStatus.Completed, outcome.Status, outcome.Message);
Assert.AreEqual(1, h.Governor.Granted(ActionKind.SinglePost));
var files = await h.Db.Media.ListByEntryAsync(entryId);
Assert.AreEqual(3, files.Count, "The whole series.");
Assert.IsTrue(files.All(f => f.SourceUrl is not null && f.State == MediaState.ToDownload));
}
[TestMethod]
[Timeout(90_000, CooperativeCancellation = true)]
public async Task StoriesAreWatchedOneByOneSavedOnlyWhenShownAndTheViewerIsClosed()
{
await using var h = await CollectionHarness.CreateAsync(Chromium);
var marta = await h.AddAccountAsync("marta.prova");
var outcome = await h.RunAsync(RecipeKind.AccountStories, marta.Id);
Assert.AreEqual(RecipeStatus.Completed, outcome.Status, outcome.Message);
var stories = await h.Db.Entries.ListByAccountAsync(marta.Id, new EntryListOptions { Kind = EntryKind.Story });
Assert.AreEqual(4, stories.Count);
Assert.AreEqual(4, h.Governor.Granted(ActionKind.StoryView), "One permit per story shown.");
Assert.AreEqual(1, h.Governor.Granted(ActionKind.ProfileOpen));
Assert.IsTrue(stories.All(s => s.ExpiresAt is not null));
Assert.AreEqual("/profilo/marta.prova/", await h.CurrentPathAsync(), "The viewer was closed before it moved on to the next account.");
Assert.IsFalse(h.Site.Control.DataRequests.Any(r => r.StartsWith("/dati/storie/nadia", StringComparison.Ordinal)), "The next account was never opened.");
Assert.IsNotNull((await h.Db.Accounts.GetAsync(marta.Id))!.LastStoriesCheckAt);
}
[TestMethod]
[Timeout(90_000, CooperativeCancellation = true)]
public async Task ARefusedStoryPermitStopsInOrderAndSavesOnlyTheStoriesShown()
{
await using var h = await CollectionHarness.CreateAsync(Chromium);
var giulia = await h.AddAccountAsync("giulia.prova");
h.Governor.ReportedRemaining = 50;
h.Governor.Limit(ActionKind.StoryView, 2);
// The budget view says 2 left: fewer than ten, the stories are not even opened.
var refused = await h.RunAsync(RecipeKind.AccountStories, giulia.Id);
Assert.AreEqual(RecipeStatus.Denied, refused.Status, refused.Message);
Assert.AreEqual(0, h.Governor.Granted(ActionKind.StoryView));
// With a budget view that allows more, the Governor still refuses after two: stop in order.
await using var h2 = await CollectionHarness.CreateAsync(Chromium);
var g2 = await h2.AddAccountAsync("giulia.prova");
var governor = new LimitedButOptimisticGovernor(h2.Governor, ActionKind.StoryView, 2);
var runner = new RecipeRunner(h2.Runner.Env with { Governor = governor, Budget = null });
var outcome = await runner.RunAsync(new RecipeRequest(RecipeKind.AccountStories, g2.Id), h2.Session, CancellationToken.None);
Assert.AreEqual(RecipeStatus.Denied, outcome.Status, outcome.Message);
Assert.AreEqual(2, (await h2.Db.Entries.ListByAccountAsync(g2.Id, new EntryListOptions { Kind = EntryKind.Story })).Count, "Two shown, two saved: never the whole list received.");
StringAssert.StartsWith(await h2.CurrentPathAsync(), "/profilo/giulia.prova/", "The viewer is closed when the recipe stops.");
}
[TestMethod]
[Timeout(90_000, CooperativeCancellation = true)]
public async Task AStoryOfAnotherAccountIsNotSavedAndTheViewerIsClosed()
{
await using var h = await CollectionHarness.CreateAsync(Chromium, factor: 4);
var nadia = await h.AddAccountAsync("nadia.prova");
await h.AddAccountAsync("luca.prova");
// The viewer moves on by itself faster than the recipe watches: it reaches the next account (Luca).
h.Site.Control.StoryDuration = TimeSpan.FromMilliseconds(300);
var outcome = await h.RunAsync(RecipeKind.AccountStories, nadia.Id);
Assert.AreEqual(RecipeStatus.Completed, outcome.Status, outcome.Message);
var luca = await h.Db.Accounts.FindByUsernameAsync("luca.prova");
Assert.AreEqual(0, (await h.Db.Entries.ListByAccountAsync(luca!.Id, new EntryListOptions { Kind = EntryKind.Story })).Count, "Stories of another account are never saved.");
Assert.IsTrue((await h.Db.Entries.ListByAccountAsync(nadia.Id, new EntryListOptions { Kind = EntryKind.Story })).Count <= 3);
var events = await h.Db.Events.ListAsync(new EventQuery());
Assert.IsTrue(events.Any(e => e.Code == "visualizzatore-altro-account"), "The event is recorded.");
Assert.IsFalse((await h.CurrentPathAsync()).StartsWith("/storie/", StringComparison.Ordinal), "The viewer is closed.");
}
[TestMethod]
[Timeout(90_000, CooperativeCancellation = true)]
public async Task StoriesOpenFromTheStoriesBarWhenTheHomeIsOnScreen()
{
await using var h = await CollectionHarness.CreateAsync(Chromium);
var nadia = await h.AddAccountAsync("nadia.prova");
Assert.AreEqual(RecipeStatus.Completed, (await h.RunAsync(RecipeKind.FollowingSweep)).Status);
var opens = h.Governor.Granted(ActionKind.ProfileOpen);
var outcome = await h.RunAsync(RecipeKind.AccountStories, nadia.Id);
Assert.AreEqual(RecipeStatus.Completed, outcome.Status, outcome.Message);
Assert.AreEqual(opens, h.Governor.Granted(ActionKind.ProfileOpen), "Opened from the bar: no profile page.");
Assert.AreEqual(3, (await h.Db.Entries.ListByAccountAsync(nadia.Id, new EntryListOptions { Kind = EntryKind.Story })).Count);
Assert.AreEqual("/", await h.CurrentPathAsync(), "Back on the home, viewer closed.");
}
[TestMethod]
[Timeout(90_000, CooperativeCancellation = true)]
public async Task AHighlightReferencesAStoryAlreadySavedInsteadOfDownloadingItAgain()
{
await using var h = await CollectionHarness.CreateAsync(Chromium);
var marta = await h.AddAccountAsync("marta.prova");
Assert.AreEqual(RecipeStatus.Completed, (await h.RunAsync(RecipeKind.AccountStories, marta.Id)).Status);
string summerId;
string sharedStory;
lock (h.Site.World.Gate)
{
var summer = h.Site.World.FindByUsername("marta.prova")!.Highlights[0];
summerId = summer.Id;
sharedStory = summer.Items[2].Id;
}
var outcome = await h.RunAsync(RecipeKind.Highlight, marta.Id, highlightId: summerId);
Assert.AreEqual(RecipeStatus.Completed, outcome.Status, outcome.Message);
Assert.AreEqual(2, outcome.NewEntries, "Two new contents; the third is a story already saved (H9).");
var highlight = await h.Db.Highlights.FindAsync(marta.Id, summerId);
var items = await h.Db.Highlights.ListItemsAsync(highlight!.Id);
Assert.AreEqual(3, items.Count);
var linked = await h.Db.Entries.GetAsync(items[2].EntryId);
Assert.AreEqual(EntryKind.Story, linked!.Kind);
Assert.AreEqual(sharedStory, linked.InstagramId);
Assert.IsNull(await h.Db.Entries.FindAsync(marta.Id, EntryKind.Highlight, sharedStory));
StringAssert.StartsWith(await h.CurrentPathAsync(), "/profilo/marta.prova/", "Viewer closed after the last content.");
}
[TestMethod]
[Timeout(90_000, CooperativeCancellation = true)]
public async Task BackfillTakesOnePagePerPermitAndResumesFromTheStoredPoint()
{
await using var h = await CollectionHarness.CreateAsync(Chromium);
var luca = await h.AddAccountAsync("luca.prova");
var first = await h.RunAsync(RecipeKind.Backfill, luca.Id, maxPages: 1);
Assert.AreEqual(RecipeStatus.Completed, first.Status, first.Message);
Assert.IsFalse(first.BackfillFinished);
Assert.AreEqual(1, h.Governor.Granted(ActionKind.ProfileOpen));
Assert.AreEqual(1, h.Governor.Granted(ActionKind.BackfillPage), "The profile page, then one more page for one permit.");
Assert.AreEqual(24, (await h.Db.Entries.ListByAccountAsync(luca.Id, new EntryListOptions { Kind = EntryKind.Post })).Count);
Assert.AreEqual("c24", (await h.Db.Accounts.GetAsync(luca.Id))!.BackfillCursor);
h.Site.Control.ClearRequests();
var second = await h.RunAsync(RecipeKind.Backfill, luca.Id, maxPages: 3);
Assert.AreEqual(RecipeStatus.Completed, second.Status, second.Message);
Assert.IsTrue(second.BackfillFinished, "The beginning of the profile was reached.");
Assert.IsTrue(h.Site.Control.DataRequests[0].Contains("dopo=c24", StringComparison.Ordinal), "Resumed from the stored point: " + h.Site.Control.DataRequests[0]);
var posts = await h.Db.Entries.ListByAccountAsync(luca.Id, new EntryListOptions { Kind = EntryKind.Post });
Assert.AreEqual(40, posts.Count);
Assert.AreEqual(40, posts.Select(p => p.InstagramId).Distinct().Count());
var account = await h.Db.Accounts.GetAsync(luca.Id);
Assert.IsNotNull(account!.BackfillCompletedAt);
Assert.IsNull(account.BackfillCursor);
var third = await h.RunAsync(RecipeKind.Backfill, luca.Id);
Assert.IsTrue(third.BackfillFinished);
Assert.AreEqual(0, third.CountedActions, "A finished backfill does not touch the site.");
}
[TestMethod]
[Timeout(60_000, CooperativeCancellation = true)]
public async Task BackfillStopsWhileTooManyFilesWaitForDownload()
{
await using var h = await CollectionHarness.CreateAsync(Chromium, new RecipeOptions { MaxPendingDownloadsForBackfill = 5 });
var luca = await h.AddAccountAsync("luca.prova");
var outcome = await h.RunAsync(RecipeKind.Backfill, luca.Id, maxPages: 3);
Assert.AreEqual(RecipeStatus.Denied, outcome.Status, outcome.Message);
StringAssert.Contains(outcome.Message, "aspettano di essere scaricati");
Assert.AreEqual(12, (await h.Db.Entries.ListByAccountAsync(luca.Id, new EntryListOptions { Kind = EntryKind.Post })).Count, "Stopped after the first page.");
Assert.AreEqual(0, h.Governor.Granted(ActionKind.BackfillPage));
Assert.AreEqual("c12", (await h.Db.Accounts.GetAsync(luca.Id))!.BackfillCursor, "The resume point is kept.");
}
[TestMethod]
[Timeout(90_000, CooperativeCancellation = true)]
public async Task TaggedAndReelsTabsWorkLikeTheGrid()
{
await using var h = await CollectionHarness.CreateAsync(Chromium);
var marta = await h.AddAccountAsync("marta.prova", a => a with { ContentTypes = ContentTypes.All });
var tagged = await h.RunAsync(RecipeKind.Tagged, marta.Id);
Assert.AreEqual(RecipeStatus.Completed, tagged.Status, tagged.Message);
Assert.IsTrue(tagged.BackfillFinished);
var entries = await h.Db.Entries.ListByAccountAsync(marta.Id, new EntryListOptions { Kind = EntryKind.Tagged });
Assert.AreEqual(3, entries.Count);
Assert.IsTrue(entries.All(e => e.AuthorUsername is "luca.prova" or "paolo.prova"), "Tagged posts keep their author.");
var reels = await h.RunAsync(RecipeKind.Reels, marta.Id);
Assert.AreEqual(RecipeStatus.Completed, reels.Status, reels.Message);
var posts = await h.Db.Entries.ListByAccountAsync(marta.Id, new EntryListOptions { Kind = EntryKind.Post });
Assert.AreEqual(4, posts.Count, "Marta's four reels, stored as posts.");
// A reel found again in the grid is the same entry: the grid adds the others only.
var check = await h.RunAsync(RecipeKind.ProfileCheck, marta.Id);
Assert.AreEqual(RecipeStatus.Completed, check.Status, check.Message);
posts = await h.Db.Entries.ListByAccountAsync(marta.Id, new EntryListOptions { Kind = EntryKind.Post });
Assert.AreEqual(posts.Count, posts.Select(p => p.InstagramId).Distinct().Count());
}
[TestMethod]
[Timeout(90_000, CooperativeCancellation = true)]
public async Task TheFollowingListIsReadOverSeveralSessionsWithItsProgressKept()
{
await using var h = await CollectionHarness.CreateAsync(Chromium);
Assert.AreEqual(RecipeStatus.Completed, (await h.RunAsync(RecipeKind.FollowingSweep)).Status, "The sweep learns Alberto's account.");
var first = await h.RunAsync(RecipeKind.FollowingList, maxPages: 2);
Assert.AreEqual(RecipeStatus.Completed, first.Status, first.Message);
Assert.AreEqual("Letti 20 profili, continuo alla prossima sessione", first.Message);
Assert.IsFalse(first.BackfillFinished);
Assert.AreEqual(2, h.Governor.Granted(ActionKind.FollowingListPage));
Assert.AreEqual(20, await h.Db.Following.CountAsync());
h.Site.Control.ClearRequests();
var second = await h.RunAsync(RecipeKind.FollowingList, maxPages: 2);
Assert.AreEqual(RecipeStatus.Completed, second.Status, second.Message);
Assert.IsTrue(second.BackfillFinished, "End of the list.");
StringAssert.Contains(h.Site.Control.DataRequests[0], "dopo=c20");
var list = await h.Db.Following.ListAsync();
Assert.AreEqual(28, list.Count);
Assert.AreEqual("marta.prova", list[0].Username);
Assert.IsNull(await h.Db.Settings.GetAsync(RecipeRunner.FollowingKeys.Cursor));
}
[TestMethod]
[Timeout(90_000, CooperativeCancellation = true)]
public async Task AFollowedProfileThatChangedNameIsRecognizedByItsIdentifier()
{
await using var h = await CollectionHarness.CreateAsync(Chromium);
var marta = await h.AddAccountAsync("marta.prova");
lock (h.Site.World.Gate)
{
h.Site.World.FindByUsername("marta.prova")!.Username = "marta.nuova";
}
var outcome = await h.RunAsync(RecipeKind.FollowingSweep);
Assert.AreEqual(RecipeStatus.Completed, outcome.Status, outcome.Message);
var renamed = await h.Db.Accounts.GetAsync(marta.Id);
Assert.AreEqual("marta.nuova", renamed!.Username);
Assert.AreEqual("marta.prova", renamed.PreviousUsername);
Assert.IsTrue(renamed.Notices.HasFlag(AccountNotices.Renamed));
Assert.IsTrue((await h.Db.Events.ListAsync(new EventQuery())).Any(e => e.Code == "account-rinominato"));
}
/// <summary>A Governor whose budget view is optimistic but which refuses a category after some grants.</summary>
private sealed class LimitedButOptimisticGovernor(PermissiveGovernor inner, ActionKind kind, int grants) : IGovernor
{
private int _granted;
public Task<Permit> RequestAsync(ActionKind requested, long? accountId, CancellationToken ct)
{
if (requested == kind && Interlocked.Increment(ref _granted) > grants)
{
return Task.FromResult(Permit.Deny(requested, accountId, DenialReason.HourlyBudgetReached, "Tetto orario delle storie raggiunto (prova)."));
}
return inner.RequestAsync(requested, accountId, ct);
}
}
}
@@ -0,0 +1,213 @@
using System.Text.Json;
using System.Text.Json.Nodes;
using Febe.Core.Collection;
using Febe.Sonda;
using Febe.Tests.Support;
namespace Febe.Tests.Collection;
/// <summary>
/// Cleaning of probe samples (spec §14.5) on synthetic raw samples written by the test: invented, generic shapes
/// with made-up people. Nothing real, nothing that claims to be Instagram's format.
/// </summary>
[TestClass]
public sealed class SanitizerTests
{
private const string RawSample = """
{
"descrittore": { "indirizzo": "https://www.instagram.com/api/qualcosa/mario.rossi", "host": "sito", "stato": 200, "tipo": "application/json" },
"corpo": {
"utente": { "id": "5512345678", "nome_utente": "mario.rossi", "nome": "Mario Rossi", "privato": false, "seguiti_count": 312 },
"elementi": [
{
"id": 3187654321098765,
"taken_at": 1791878400,
"didascalia": "Cena con Lucia al lago di Garda!! 🍝",
"width": 1080, "height": 1350, "duration": 12.5,
"media_type": "image",
"url": "https://scontent-mxp1-1.cdninstagram.com/v/t51/123_456_n.jpg?stp=abc&oh=00_secret&oe=6712ABCD",
"pagina": "https://www.instagram.com/p/CxYz123/",
"visto": true,
"vuoto": null
}
],
"per_id": { "17841400123456": { "nome_utente": "lucia.bianchi" } },
"cursore": "QVFIUjBzNmFQZ0pNb2xKd2E3ZQ==",
"ripetuto": "mario.rossi"
}
}
""";
[TestMethod]
public void StructureStaysAndEveryPersonalValueIsReplaced()
{
using var temp = new TempFolder("ripulitura");
var raw = Directory.CreateDirectory(temp.Combine("grezzi")).FullName;
File.WriteAllText(Path.Combine(raw, "000001.json"), RawSample);
File.WriteAllText(Path.Combine(raw, "interazioni.jsonl"), """
{"evento":"fuoco","percorso":"/mario.rossi/","elemento":{"role":"link","ariaLabel":"Storie di mario.rossi","href":{"host":"www.instagram.com","path":"/stories/mario.rossi/"}}}
{"evento":"sopra","percorso":"/","elemento":{"role":"button","ariaLabel":"Chiudi"}}
""");
Directory.CreateDirectory(Path.Combine(raw, SampleSanitizer.BrowserProfileFolder));
File.WriteAllText(Path.Combine(raw, SampleSanitizer.BrowserProfileFolder, "Preferences.json"), """{"segreto":"cookie di sessione"}""");
var clean = temp.Combine("ripuliti");
var report = new SampleSanitizer(key: new byte[32]).SanitizeFolder(raw, clean);
Assert.AreEqual(2, report.Files, "The browser profile is never part of the samples.");
Assert.IsFalse(Directory.Exists(Path.Combine(clean, SampleSanitizer.BrowserProfileFolder)));
var cleaned = JsonNode.Parse(File.ReadAllText(Path.Combine(clean, "000001.json")))!;
var body = cleaned["corpo"]!;
var item = body["elementi"]![0]!;
// Structure and ordinary keys stay.
CollectionAssert.AreEquivalent(
new[] { "id", "taken_at", "didascalia", "width", "height", "duration", "media_type", "url", "pagina", "visto", "vuoto" },
item.AsObject().Select(p => p.Key).ToArray());
// Allowlisted fields stay: dimensions, durations, counts, type codes, dates; booleans and null always.
Assert.AreEqual(1080, item["width"]!.GetValue<int>());
Assert.AreEqual(12.5, item["duration"]!.GetValue<double>());
Assert.AreEqual(1791878400, item["taken_at"]!.GetValue<long>());
Assert.AreEqual("image", item["media_type"]!.GetValue<string>());
Assert.AreEqual(312, body["utente"]!["seguiti_count"]!.GetValue<int>());
Assert.IsTrue(item["visto"]!.GetValue<bool>());
Assert.IsNull(item["vuoto"]);
// Strings and long numbers: fake values of the same shape.
var name = body["utente"]!["nome_utente"]!.GetValue<string>();
Assert.AreNotEqual("mario.rossi", name);
Assert.AreEqual(11, name.Length);
Assert.AreEqual('.', name[5], "Punctuation keeps the shape.");
Assert.AreEqual(name, body["ripetuto"]!.GetValue<string>(), "Equal values get equal fakes: relations survive.");
var id = item["id"]!.GetValue<long>();
Assert.AreNotEqual(3187654321098765, id);
Assert.AreEqual(16, id.ToString(System.Globalization.CultureInfo.InvariantCulture).Length);
Assert.AreEqual(10, body["utente"]!["id"]!.GetValue<string>().Length);
var caption = item["didascalia"]!.GetValue<string>();
Assert.AreEqual("Cena con Lucia al lago di Garda!! 🍝".Length, caption.Length);
Assert.IsFalse(caption.Contains("Lucia", StringComparison.Ordinal));
// Addresses: only site or CDN, and the file extension.
StringAssert.StartsWith(item["url"]!.GetValue<string>(), "https://cdn.esempio/");
StringAssert.EndsWith(item["url"]!.GetValue<string>(), ".jpg");
StringAssert.StartsWith(item["pagina"]!.GetValue<string>(), "https://sito.esempio/");
StringAssert.StartsWith(cleaned["descrittore"]!["indirizzo"]!.GetValue<string>(), "https://sito.esempio/");
// Keys that look like identifiers are replaced too.
var key = body["per_id"]!.AsObject().Single().Key;
Assert.AreNotEqual("17841400123456", key);
Assert.AreEqual(14, key.Length);
var verify = SampleVerifier.Verify(raw, clean);
Assert.IsTrue(verify.Passed, string.Join("; ", verify.Leaks.Select(l => $"{l.CleanFile} {l.Length} {l.Kind}")));
Assert.IsTrue(verify.CheckedTokens > 10);
}
[TestMethod]
public void TheVerificationFailsWhenARawValueSurvivesAndDoesNotPrintIt()
{
using var temp = new TempFolder("ripulitura");
var raw = Directory.CreateDirectory(temp.Combine("grezzi")).FullName;
File.WriteAllText(Path.Combine(raw, "000001.json"), RawSample);
var clean = temp.Combine("ripuliti");
new SampleSanitizer().SanitizeFolder(raw, clean);
// Someone «fixes» a cleaned file by hand and puts a real name back.
var path = Path.Combine(clean, "000001.json");
var node = JsonNode.Parse(File.ReadAllText(path))!;
node["corpo"]!["elementi"]![0]!["didascalia"] = "nota: lucia.bianchi";
File.WriteAllText(path, node.ToJsonString());
var report = SampleVerifier.Verify(raw, clean);
Assert.IsFalse(report.Passed);
Assert.IsTrue(report.Leaks.All(l => l.CleanFile == "000001.json"));
Assert.IsTrue(report.Leaks.Any(l => l.Kind == "lettere"));
foreach (var leak in report.Leaks)
{
Assert.IsFalse(leak.ToString().Contains("lucia", StringComparison.OrdinalIgnoreCase), "Where, never what.");
}
// A raw copy is the worst case.
var copy = temp.Combine("copia");
Directory.CreateDirectory(copy);
File.Copy(Path.Combine(raw, "000001.json"), Path.Combine(copy, "000001.json"));
Assert.IsTrue(SampleVerifier.Verify(raw, copy).Leaks.Count > 5);
// A missing cleaned file fails too.
File.Delete(path);
Assert.IsFalse(SampleVerifier.Verify(raw, clean).Passed);
}
[TestMethod]
public void TheCleanFolderCannotBeInsideTheRawOne()
{
using var temp = new TempFolder("ripulitura");
var raw = Directory.CreateDirectory(temp.Combine("grezzi")).FullName;
File.WriteAllText(Path.Combine(raw, "000001.json"), "{}");
Assert.ThrowsExactly<InvalidOperationException>(() => new SampleSanitizer().SanitizeFolder(raw, Path.Combine(raw, "ripuliti")));
}
[TestMethod]
public void RawSamplesAreRefusedInsideAGitRepository()
{
using var temp = new TempFolder("sonda");
Directory.CreateDirectory(temp.Combine("progetto", ".git"));
var inside = temp.Combine("progetto", "campioni", "grezzi");
Assert.AreEqual(temp.Combine("progetto"), RepositoryGuard.FindRepository(inside));
var refused = Assert.ThrowsExactly<InvalidOperationException>(() => RepositoryGuard.EnsureOutside(inside));
StringAssert.Contains(refused.Message, "fuori dal repository");
RepositoryGuard.EnsureOutside(temp.Combine("altrove"));
// A worktree has a «.git» file instead of a folder: refused too.
Directory.CreateDirectory(temp.Combine("albero"));
File.WriteAllText(temp.Combine("albero", ".git"), "gitdir: /altrove/.git/worktrees/albero\n");
Assert.IsNotNull(RepositoryGuard.FindRepository(temp.Combine("albero", "campioni")));
}
[TestMethod]
public void TheAllowlistIsShortAndExplicit()
{
var allow = SanitizerAllowlist.Default;
Assert.AreEqual(AllowedField.Dimension, allow.FieldOf("original_width"));
Assert.AreEqual(AllowedField.Date, allow.FieldOf("expiring_at"));
Assert.AreEqual(AllowedField.Count, allow.FieldOf("comment_count"));
Assert.AreEqual(AllowedField.None, allow.FieldOf("username"));
Assert.AreEqual(AllowedField.None, allow.FieldOf("caption"));
Assert.IsTrue(allow.KeepsString("media_type", "video"));
Assert.IsFalse(allow.KeepsString("media_type", "una frase lunga con 12345 cifre"), "A code must look like a code.");
Assert.IsTrue(allow.KeepsString("pubblicato", "2026-10-13T08:00:00Z"));
Assert.IsFalse(allow.KeepsString("pubblicato", "ieri sera"));
Assert.IsFalse(allow.KeepsString("width", "1080"), "Dimensions keep numbers only.");
}
[TestMethod]
public void AddressesOutsideSiteAndCdnAreMarkedAsOther()
{
var sanitizer = new SampleSanitizer(hosts: new HostClassifier(["127.0.0.1"], ["127.0.0.2"]));
var node = sanitizer.Sanitize(JsonNode.Parse("""{"a":"http://127.0.0.2:8482/m/f1/960x1200.jpg?scad=1&firma=x","b":"http://127.0.0.1:8481/profilo/marta.prova/","c":"https://esterno.example/x.webp"}"""))!;
StringAssert.StartsWith(node["a"]!.GetValue<string>(), "https://cdn.esempio/");
StringAssert.EndsWith(node["a"]!.GetValue<string>(), ".jpg");
Assert.IsFalse(node["b"]!.GetValue<string>().Contains("prova", StringComparison.Ordinal), "A user name after a dot is not an extension.");
StringAssert.StartsWith(node["c"]!.GetValue<string>(), "https://altro.esempio/");
StringAssert.EndsWith(node["c"]!.GetValue<string>(), ".webp");
}
[TestMethod]
public void TheProbeReadsOnlyThroughAReadOnlyScript() =>
Febe.Browser.Cdp.ReadOnlyScriptGuard.EnsureReadOnly(ProbeRecorder.InteractionScript);
[TestMethod]
public void TheCleanedSamplesInTheRepositoryAreCleanedSamples()
{
// Every file of tests/campioni/prova comes out of «ripulisci»: fake addresses, no address of the test site.
foreach (var file in Directory.EnumerateFiles(Path.Combine(AppContext.BaseDirectory, "campioni", "prova"), "*.json"))
{
var text = File.ReadAllText(file);
Assert.IsFalse(text.Contains("127.0.0.", StringComparison.Ordinal), file);
Assert.IsFalse(text.Contains("prova\"", StringComparison.Ordinal), file);
using var document = JsonDocument.Parse(text);
Assert.IsTrue(document.RootElement.TryGetProperty("corpo", out _));
}
}
}
+2 -1
View File
@@ -24,7 +24,8 @@ public sealed class SignalTests
var testSite = SignalRules.LoadTestSite();
Assert.IsTrue(File.Exists(Path.Combine(AppContext.BaseDirectory, "config", "segnali.prova.json")));
Assert.AreEqual(4, testSite.Rules.Count);
Assert.AreEqual(5, testSite.Rules.Count);
Assert.IsTrue(testSite.Rules.Any(r => r.Code == "session-ended-url" && r.Level == SignalLevel.Disconnect));
}
[TestMethod]
@@ -0,0 +1,254 @@
using System.Security.Cryptography;
using Febe.Core.Abstractions;
using Febe.Core.Collection.Downloads;
using Febe.Core.Domain;
using Febe.Core.Engine;
using Febe.Core.Library;
using Febe.Core.Storage;
using Febe.SitoDiProva;
using Febe.Tests.Collection.Support;
namespace Febe.Tests.Collection;
/// <summary>
/// Stop signals (spec §7.6) and the download queue (spec §6.5) against the local test site with a real Chromium.
/// </summary>
[TestClass]
[DoNotParallelize]
public sealed class StopAndDownloadIntegrationTests
{
private static SharedChromium? s_chromium;
private static string? s_unavailable;
public TestContext TestContext { get; set; } = null!;
private static SharedChromium Chromium => s_chromium ?? throw new InvalidOperationException("Browser non avviato.");
[ClassInitialize]
public static async Task StartAsync(TestContext context)
{
s_unavailable = SharedChromium.UnavailableReason();
if (s_unavailable is null)
{
s_chromium = await SharedChromium.StartAsync();
}
}
[ClassCleanup]
public static async Task StopAsync()
{
if (s_chromium is not null)
{
await s_chromium.DisposeAsync();
s_chromium = null;
}
}
[TestInitialize]
public void RequireBrowser()
{
if (s_unavailable is not null)
{
Assert.Inconclusive(s_unavailable);
}
}
[TestMethod]
[Timeout(60_000, CooperativeCancellation = true)]
public async Task Http429StopsTheRecipeWithAThrottleSignal()
{
await using var h = await CollectionHarness.CreateAsync(Chromium);
var marta = await h.AddAccountAsync("marta.prova");
h.Site.Control.Set(StopMode.TooManyRequests);
var outcome = await h.RunAsync(RecipeKind.ProfileCheck, marta.Id);
Assert.AreEqual(RecipeStatus.StoppedBySignal, outcome.Status, outcome.Message);
var signal = h.Breaker.Signals.Single();
Assert.AreEqual(SignalLevel.Throttle, signal.Level);
Assert.AreEqual("http-429", signal.Code);
Assert.AreEqual(0, (await h.Db.Entries.ListByAccountAsync(marta.Id)).Count);
Assert.AreEqual("/profilo/marta.prova/", await h.CurrentPathAsync(), "The page is left as it is.");
}
[TestMethod]
[Timeout(60_000, CooperativeCancellation = true)]
public async Task AVerificationPageStopsEverythingAndIsLeftOnScreen()
{
await using var h = await CollectionHarness.CreateAsync(Chromium);
var marta = await h.AddAccountAsync("marta.prova");
h.Site.Control.Set(StopMode.Challenge);
var outcome = await h.RunAsync(RecipeKind.ProfileCheck, marta.Id);
Assert.AreEqual(RecipeStatus.StoppedBySignal, outcome.Status, outcome.Message);
Assert.AreEqual(SignalLevel.Challenge, h.Breaker.Signals[0].Level);
Assert.AreEqual("challenge-url", h.Breaker.Signals[0].Code);
Assert.AreEqual("/verifica", await h.CurrentPathAsync());
Assert.AreEqual(0, h.Governor.Requests.Count(r => r.Kind != ActionKind.ProfileOpen), "Nothing after the signal.");
}
[TestMethod]
[Timeout(60_000, CooperativeCancellation = true)]
public async Task AnEndedSessionIsADisconnectionAndFebeNeverTriesToComeBack()
{
await using var h = await CollectionHarness.CreateAsync(Chromium);
var marta = await h.AddAccountAsync("marta.prova");
h.Site.Control.Set(StopMode.SessionEnded);
var outcome = await h.RunAsync(RecipeKind.ProfileCheck, marta.Id);
Assert.AreEqual(RecipeStatus.StoppedBySignal, outcome.Status, outcome.Message);
Assert.AreEqual(SignalLevel.Disconnect, h.Breaker.Signals[0].Level);
Assert.AreEqual("/sessione-scaduta", await h.CurrentPathAsync());
Assert.IsFalse(await h.Driver.HasSessionCookieAsync(CancellationToken.None) ?? true, "The session cookie is gone.");
// The next recipe sees the missing cookie before touching the site.
h.Site.Control.Reset();
var next = await h.RunAsync(RecipeKind.ProfileCheck, marta.Id);
Assert.AreEqual(RecipeStatus.StoppedBySignal, next.Status, next.Message);
Assert.AreEqual(1, h.Governor.Granted(ActionKind.ProfileOpen), "No new attempt on the site.");
}
[TestMethod]
[Timeout(60_000, CooperativeCancellation = true)]
public async Task ASignalInTheMiddleOfABackfillStopsItWhereItIsKeepingWhatWasRead()
{
await using var h = await CollectionHarness.CreateAsync(Chromium);
var luca = await h.AddAccountAsync("luca.prova");
h.Site.Control.Set(StopMode.TooManyRequests, afterDataRequests: 1);
var outcome = await h.RunAsync(RecipeKind.Backfill, luca.Id, maxPages: 3);
Assert.AreEqual(RecipeStatus.StoppedBySignal, outcome.Status, outcome.Message);
Assert.AreEqual(12, (await h.Db.Entries.ListByAccountAsync(luca.Id, new EntryListOptions { Kind = EntryKind.Post })).Count, "The first page is kept.");
Assert.AreEqual("c12", (await h.Db.Accounts.GetAsync(luca.Id))!.BackfillCursor);
Assert.AreEqual(1, h.Governor.Granted(ActionKind.BackfillPage), "The permit of the page that got 429 was used; no more.");
}
[TestMethod]
[Timeout(90_000, CooperativeCancellation = true)]
public async Task ThreeEmptyPagesInARowAreAThrottleSignal()
{
await using var h = await CollectionHarness.CreateAsync(Chromium);
var marta = await h.AddAccountAsync("marta.prova");
h.Site.Control.Set(StopMode.EmptyPages);
var first = await h.RunAsync(RecipeKind.ProfileCheck, marta.Id);
var second = await h.RunAsync(RecipeKind.ProfileCheck, marta.Id);
Assert.AreEqual(RecipeStatus.Completed, first.Status, first.Message);
Assert.AreEqual(RecipeStatus.Completed, second.Status, second.Message);
Assert.AreEqual(0, h.Breaker.Signals.Count);
var third = await h.RunAsync(RecipeKind.ProfileCheck, marta.Id);
Assert.AreEqual(RecipeStatus.StoppedBySignal, third.Status, third.Message);
Assert.AreEqual("empty-pages", h.Breaker.Signals.Single().Code);
}
[TestMethod]
[Timeout(60_000, CooperativeCancellation = true)]
public async Task AnUnknownResponseShapeStopsTheRecipeWithTheKeyStructureOnly()
{
await using var h = await CollectionHarness.CreateAsync(Chromium, new Febe.Core.Collection.Recipes.RecipeOptions { DataTimeout = TimeSpan.FromSeconds(8) });
var marta = await h.AddAccountAsync("marta.prova");
h.Site.Control.Set(StopMode.UnknownFormat);
var outcome = await h.RunAsync(RecipeKind.ProfileCheck, marta.Id);
Assert.AreEqual(RecipeStatus.UnrecognizedFormat, outcome.Status, outcome.Message);
var evt = (await h.Db.Events.ListAsync(new EventQuery())).Single(e => e.Code == "formato-non-riconosciuto");
StringAssert.Contains(evt.Message, "{risposta:{voci:[{chiave,valore,dettagli:{x}}]},versione}");
Assert.IsFalse(evt.Message.Contains("formato nuovo", StringComparison.Ordinal), "Only the structure, never the values.");
Assert.IsTrue((await h.Db.Accounts.GetAsync(marta.Id))!.Notices.HasFlag(AccountNotices.UnrecognizedFormat), "«Da controllare».");
Assert.AreEqual(0, h.Breaker.Signals.Count, "A new format is not a stop signal.");
}
[TestMethod]
[Timeout(90_000, CooperativeCancellation = true)]
public async Task DownloadsArriveIntactInTheLibraryWithTheirNames()
{
await using var h = await CollectionHarness.CreateAsync(Chromium);
var nadia = await h.AddAccountAsync("nadia.prova", a => a with { Limits = a.Limits with { StoryVideos = false } });
var marta = await h.AddAccountAsync("marta.prova", a => a with { Limits = a.Limits with { StoryVideos = false } });
Assert.AreEqual(RecipeStatus.Completed, (await h.RunAsync(RecipeKind.ProfileCheck, nadia.Id)).Status);
Assert.AreEqual(RecipeStatus.Completed, (await h.RunAsync(RecipeKind.AccountStories, marta.Id)).Status);
var pending = await h.Db.Media.CountPendingDownloadsAsync();
Assert.IsTrue(pending >= 7, $"{pending} file in attesa.");
// Downloads go through the frame of the page on screen (a page of the site). From the blank rest page Chromium
// refuses local addresses (net::ERR_BLOCKED_BY_PRIVATE_NETWORK_ACCESS_CHECKS): an artefact of the local CDN on
// 127.0.0.2, to be measured with the real CDN in M0 (H7). See docs/sonda/esito.md.
var report = await h.Downloads.RunOnceAsync(CancellationToken.None);
Assert.AreEqual(0, report.Failed + report.Expired + report.Retried, report.ToString());
Assert.AreEqual(pending, report.Stored, report.ToString());
Assert.AreEqual(0, await h.Db.Media.CountPendingDownloadsAsync());
Assert.IsTrue(h.DataBudget.Used > 0, "Bytes count toward the daily data budget.");
var posts = await h.Db.Entries.ListByAccountAsync(nadia.Id, new EntryListOptions { Kind = EntryKind.Post });
foreach (var post in posts)
{
var file = (await h.Db.Media.ListByEntryAsync(post.Id)).Single();
Assert.AreEqual(MediaState.Downloaded, file.State);
var path = h.Library.Layout.FullPath(nadia, file.RelativePath!);
Assert.IsTrue(File.Exists(path), path);
StringAssert.StartsWith(file.RelativePath, $"post/{LocalCalendar.ToLocal(post.PublishedAt, h.Clock.LocalZone).Year}/");
StringAssert.EndsWith(file.RelativePath, $"_{post.Code}_1.jpg");
Assert.AreEqual(Convert.ToHexStringLower(SHA256.HashData(await File.ReadAllBytesAsync(path))), file.Sha256);
var served = h.Site.Media.Picture(h.Site.World.FindPost(post.Code!)!.Files[0].MediaKey, 960, 1200);
CollectionAssert.AreEqual(served, await File.ReadAllBytesAsync(path), "The largest version, byte for byte.");
Assert.IsNull(file.SourceUrl, "Signed addresses are dropped once the file is saved.");
}
var picture = (await h.Db.Entries.ListByAccountAsync(nadia.Id, new EntryListOptions { Kind = EntryKind.ProfilePicture })).Single();
var pictureFile = (await h.Db.Media.ListByEntryAsync(picture.Id)).Single();
StringAssert.StartsWith(pictureFile.RelativePath, "profilo/");
StringAssert.EndsWith(pictureFile.RelativePath, $"_{pictureFile.Sha256![..8]}_1.jpg", "Profile pictures are named by the first eight hex digits of their SHA-256.");
var stories = await h.Db.Entries.ListByAccountAsync(marta.Id, new EntryListOptions { Kind = EntryKind.Story });
var video = (await Task.WhenAll(stories.Select(s => h.Db.Media.ListByEntryAsync(s.Id)))).SelectMany(m => m).Single(m => m.Kind == MediaKind.Video);
Assert.AreEqual(MediaState.Skipped, video.State, "«Video delle storie» is off for Marta: never downloaded.");
Assert.IsTrue(File.Exists(Path.Combine(h.Library.Layout.AccountFolder(nadia), "_febe.jsonl")), "The account journal is written.");
Assert.AreEqual(0, Directory.EnumerateFiles(h.Temp.Combine("dati", "temporanei")).Count(), "No temporary file left behind.");
}
[TestMethod]
[Timeout(90_000, CooperativeCancellation = true)]
public async Task AnExpiredAddressIsRecoveredThroughSinglePost()
{
await using var h = await CollectionHarness.CreateAsync(Chromium);
var nadia = await h.AddAccountAsync("nadia.prova");
h.Site.Control.AddressLifetime = TimeSpan.FromSeconds(1);
Assert.AreEqual(RecipeStatus.Completed, (await h.RunAsync(RecipeKind.ProfileCheck, nadia.Id)).Status);
await Task.Delay(TimeSpan.FromSeconds(2.2));
var expired = await h.Downloads.RunOnceAsync(CancellationToken.None);
Assert.AreEqual(0, expired.Stored);
Assert.AreEqual(4, expired.Expired, "Three posts and the profile picture.");
Assert.IsTrue(h.Site.Control.CdnExpired >= 4);
var tasks = (await h.Db.Tasks.ListPendingAsync(100)).Where(t => t.Kind == EngineTaskKind.SinglePost).ToList();
Assert.AreEqual(3, tasks.Count, "One «Post singolo» per post; none for the profile picture.");
h.Site.Control.AddressLifetime = TimeSpan.FromHours(6);
foreach (var task in tasks)
{
var outcome = await h.RunAsync(RecipeKind.SinglePost, task.AccountId, long.Parse(task.Payload!, System.Globalization.CultureInfo.InvariantCulture));
Assert.AreEqual(RecipeStatus.Completed, outcome.Status, outcome.Message);
}
var recovered = await h.Downloads.RunOnceAsync(CancellationToken.None);
Assert.AreEqual(3, recovered.Stored, recovered.ToString());
var posts = await h.Db.Entries.ListByAccountAsync(nadia.Id, new EntryListOptions { Kind = EntryKind.Post });
Assert.IsTrue(posts.All(p => p.State == EntryState.Downloaded));
}
[TestMethod]
[Timeout(90_000, CooperativeCancellation = true)]
public async Task DownloadsGoOnWhileTheSiteIsStoppedByAVerification()
{
await using var h = await CollectionHarness.CreateAsync(Chromium);
var nadia = await h.AddAccountAsync("nadia.prova");
Assert.AreEqual(RecipeStatus.Completed, (await h.RunAsync(RecipeKind.ProfileCheck, nadia.Id)).Status);
h.Site.Control.Set(StopMode.Challenge);
Assert.AreEqual(RecipeStatus.StoppedBySignal, (await h.RunAsync(RecipeKind.ProfileCheck, nadia.Id)).Status);
Assert.AreEqual("/verifica", await h.CurrentPathAsync());
// The page stays on the verification: the queue downloads from the CDN without touching the site.
var report = await h.Downloads.RunOnceAsync(CancellationToken.None);
Assert.AreEqual(4, report.Stored, "Files already queued come from the CDN, not the site (spec §7.6).");
Assert.AreEqual("/verifica", await h.CurrentPathAsync(), "Still on the verification page.");
}
}
@@ -0,0 +1,121 @@
using System.Collections.Concurrent;
using Febe.Core.Abstractions;
using Febe.Core.Collection.Recipes;
using Febe.Core.Engine;
namespace Febe.Tests.Collection.Support;
/// <summary>
/// A clock that compresses time: <see cref="Delay"/> waits for real only a fraction of the requested time, and
/// <see cref="Now"/> moves on by the whole of it. Recipes against a real browser keep their order of events, but a
/// 2.2-second «wait after load» lasts a few hundred milliseconds.
/// </summary>
public sealed class CompressedClock : IClock
{
private readonly Lock _gate = new();
private TimeSpan _offset;
public CompressedClock(double factor = 10, TimeZoneInfo? zone = null)
{
Factor = factor;
LocalZone = zone ?? TimeZoneInfo.Utc;
}
public double Factor { get; }
public TimeZoneInfo LocalZone { get; }
public DateTimeOffset Now
{
get
{
lock (_gate)
{
return DateTimeOffset.UtcNow + _offset;
}
}
}
public async Task Delay(TimeSpan time, CancellationToken ct)
{
if (time <= TimeSpan.Zero)
{
ct.ThrowIfCancellationRequested();
return;
}
var real = TimeSpan.FromTicks((long)(time.Ticks / Factor));
if (real >= TimeSpan.FromMilliseconds(1))
{
await Task.Delay(real, ct).ConfigureAwait(false);
}
else
{
ct.ThrowIfCancellationRequested();
await Task.Yield();
}
lock (_gate)
{
_offset += time - real;
}
}
}
/// <summary>
/// A Governor that grants everything, records each request and can refuse a category after a number of grants
/// (to test the orderly stop of the recipes). Never used outside tests.
/// </summary>
public sealed class PermissiveGovernor : IGovernor, IBudgetView
{
private readonly ConcurrentQueue<(ActionKind Kind, long? AccountId)> _requests = new();
private readonly ConcurrentDictionary<ActionKind, int> _limits = new();
private readonly ConcurrentDictionary<ActionKind, int> _granted = new();
public IReadOnlyList<(ActionKind Kind, long? AccountId)> Requests => [.. _requests];
/// <summary>Remaining budget reported to <see cref="IBudgetView"/> when no limit is set.</summary>
public int ReportedRemaining { get; set; } = 1000;
public int Granted(ActionKind kind) => _granted.TryGetValue(kind, out var n) ? n : 0;
/// <summary>After <paramref name="grants"/> granted requests of <paramref name="kind"/>, the next ones are refused.</summary>
public void Limit(ActionKind kind, int grants) => _limits[kind] = grants;
public Task<Permit> RequestAsync(ActionKind kind, long? accountId, CancellationToken ct)
{
_requests.Enqueue((kind, accountId));
if (_limits.TryGetValue(kind, out var limit) && Granted(kind) >= limit)
{
return Task.FromResult(Permit.Deny(kind, accountId, DenialReason.HourlyBudgetReached, "Tetto orario raggiunto (prova)."));
}
_granted.AddOrUpdate(kind, 1, (_, n) => n + 1);
return Task.FromResult(Permit.Grant(kind, accountId));
}
public Task<int> RemainingAsync(ActionKind kind, long? accountId, CancellationToken ct) =>
Task.FromResult(_limits.TryGetValue(kind, out var limit) ? Math.Max(0, limit - Granted(kind)) : ReportedRemaining);
}
/// <summary>A daily data budget kept in memory.</summary>
public sealed class FakeDataBudget(long bytesPerDay = long.MaxValue / 4) : IDataBudget
{
private long _used;
public long Used => Interlocked.Read(ref _used);
public Task<long> RemainingTodayAsync(CancellationToken ct) => Task.FromResult(Math.Max(0, bytesPerDay - Used));
public Task RecordAsync(long bytes, long? accountId, CancellationToken ct)
{
Interlocked.Add(ref _used, bytes);
return Task.CompletedTask;
}
}
/// <summary>A session context for one test.</summary>
public sealed record TestSession(long SessionId = 1, double Mood = 1.0) : ISessionContext
{
public DateTimeOffset PlannedEnd { get; init; } = DateTimeOffset.MaxValue;
}
@@ -0,0 +1,207 @@
using System.Collections.Concurrent;
using Febe.Browser.Capture;
using Febe.Browser.Cdp;
using Febe.Browser.Diagnostics;
using Febe.Browser.Download;
using Febe.Browser.Hosting;
using Febe.Browser.Recipes;
using Febe.Browser.Targets;
using Febe.Core.Abstractions;
using Febe.Core.Collection;
using Febe.Core.Collection.Downloads;
using Febe.Core.Collection.Readers;
using Febe.Core.Collection.Recipes;
using Febe.Core.Domain;
using Febe.Core.Engine;
using Febe.SitoDiProva;
using Febe.Tests.Browser.TestSupport;
using Febe.Tests.Support;
namespace Febe.Tests.Collection.Support;
/// <summary>
/// One Chromium on a private Xvfb display, shared by a test class (the collection tests run one at a time).
/// </summary>
public sealed class SharedChromium : IAsyncDisposable
{
private SharedChromium(XvfbProcess xvfb, ChromiumProcessHost host, string profile, ConcurrentQueue<string> log)
{
Xvfb = xvfb;
Host = host;
Profile = profile;
Log = log;
}
public XvfbProcess Xvfb { get; }
public ChromiumProcessHost Host { get; }
public string Profile { get; }
public ConcurrentQueue<string> Log { get; }
public ICdpSession Cdp => Host.Cdp;
public static string? UnavailableReason() => RealBrowser.UnavailableReason();
public static async Task<SharedChromium> StartAsync()
{
var display = XvfbProcess.FindFreeDisplay(200, 299) ?? throw new InvalidOperationException("Nessun display libero.");
var log = new ConcurrentQueue<string>();
var browserLog = new DelegateBrowserLog((level, message, ex) => log.Enqueue($"{level}: {message} {ex?.Message}"));
var xvfb = new XvfbProcess(display, 1280, 900, log: browserLog);
await xvfb.StartAsync(CancellationToken.None);
var profile = Path.Combine(Path.GetTempPath(), "febe-raccolta-" + Guid.NewGuid().ToString("N"));
var host = new ChromiumProcessHost(
new ChromiumLaunchOptions { NoSandbox = RealBrowser.IsRoot, Environment = RealBrowser.BrowserEnvironment },
log: browserLog);
try
{
await host.StartAsync(new BrowserOptions(profile, 1280, 900, LocalTestSite.FreePort(), RealBrowser.ChromiumPath(), display), CancellationToken.None);
}
catch
{
await host.DisposeAsync();
await xvfb.DisposeAsync();
throw;
}
return new SharedChromium(xvfb, host, profile, log);
}
public async ValueTask DisposeAsync()
{
await Host.DisposeAsync();
await Xvfb.DisposeAsync();
RealBrowser.TryDelete(Profile);
}
}
/// <summary>
/// Everything one collection test needs, built fresh: the test site, the capture on the shared browser, the stop
/// signals, a library with its database, the page driver, the recipe runner and the download queue.
/// </summary>
internal sealed class CollectionHarness : IAsyncDisposable
{
private CollectionHarness(SharedChromium chromium, TestSite site, TempFolder temp, TestLibrary library, CompressedClock clock)
{
Chromium = chromium;
Site = site;
Temp = temp;
Library = library;
Clock = clock;
}
public SharedChromium Chromium { get; }
public TestSite Site { get; }
public TempFolder Temp { get; }
public TestLibrary Library { get; }
public CompressedClock Clock { get; }
public CollectionPipeline Pipeline { get; private set; } = null!;
public HostClassifier Hosts => new([Site.SiteHost], [Site.CdnHost]);
public RecordingBreaker Breaker { get; } = new();
public PermissiveGovernor Governor { get; } = new();
public FakeDataBudget DataBudget { get; } = new();
public SignalDetector Signals => Pipeline.Signals;
public CaptureCollector Capture => Pipeline.Capture;
public BrowserPageDriver Driver => Pipeline.Driver;
public RecipeRunner Runner => Pipeline.Runner;
public DownloadQueue Downloads => Pipeline.Downloads;
public Febe.Data.FebeDatabase Db => Library.Db;
/// <summary>The engine session the recipes run in (a real row: events refer to it).</summary>
public TestSession Session { get; private set; } = new();
public static async Task<CollectionHarness> CreateAsync(SharedChromium chromium, RecipeOptions? options = null, double factor = 10)
{
var site = await TestSite.StartAsync(new TestSiteOptions());
var temp = new TempFolder("raccolta");
var library = await TestLibrary.CreateAsync(temp);
var clock = new CompressedClock(factor, TestZones.Rome);
var harness = new CollectionHarness(chromium, site, temp, library, clock);
harness.Pipeline = await CollectionPipeline.StartAsync(new CollectionPipelineOptions
{
Cdp = chromium.Cdp,
Site = CollectionSite.TestSite(site.SiteHost, site.CdnHost),
Storage = library.Db,
Ingest = library.Ingest,
Governor = harness.Governor,
DataBudget = harness.DataBudget,
Breaker = harness.Breaker,
Clock = clock,
Random = new SeededRandom(20261013),
StagingFolder = temp.Combine("dati", "temporanei"),
Recipes = options ?? new RecipeOptions(),
});
harness.Session = new TestSession((await library.Db.Sessions.StartAsync(clock.Now)).Id);
await harness.SignInAsync();
return harness;
}
/// <summary>
/// What Alberto does by hand before the engine runs: opens the site once, so that its session cookie exists (the
/// test site has no login form: the first visit starts the session). Then the browser goes back to rest.
/// </summary>
public async Task SignInAsync()
{
await Chromium.Cdp.NavigateAsync(Site.Url("/benvenuto"));
await Chromium.Cdp.WaitForLoadAsync(new Febe.Core.Abstractions.SystemClock(), TimeSpan.FromSeconds(10));
await Chromium.Cdp.RestAsync();
}
/// <summary>Adds an account as Alberto would (by name, from the test site's world).</summary>
public async Task<Account> AddAccountAsync(string username, Func<Account, Account>? change = null, bool withId = true)
{
string? id;
bool followed;
lock (Site.World.Gate)
{
var site = Site.World.FindByUsername(username);
id = site?.Id;
followed = site?.FollowedByViewer ?? false;
}
var account = Account.Create(username, StartingPoint.EverythingAndKeepUpdated, Clock.Now, TestZones.Rome) with
{
InstagramId = withId ? id : null,
IsFollowed = followed,
};
return await Db.Accounts.AddAsync(change is null ? account : change(account));
}
public Task<RecipeOutcome> RunAsync(RecipeKind kind, long? accountId = null, long? entryId = null, string? highlightId = null, int? maxPages = null) =>
Runner.RunAsync(new RecipeRequest(kind, accountId, entryId, highlightId, maxPages), Session, CancellationToken.None);
public Task<string> CurrentPathAsync() => Driver.CurrentPathAsync(CancellationToken.None);
public async ValueTask DisposeAsync()
{
await Pipeline.DisposeAsync();
try
{
await Chromium.Cdp.RestAsync();
}
catch (Exception ex) when (ex is CdpCommandException or BrowserUnavailableException or CdpDisconnectedException)
{
}
await Site.DisposeAsync();
await Library.DisposeAsync();
Temp.Dispose();
}
}
@@ -0,0 +1,298 @@
{
"descrittore": {
"indirizzo": "https://sito.esempio/76vtw613mz1q79w5",
"host": "sito",
"stato": 200,
"tipo": "application/json",
"risorsa": "Fetch",
"nome": "jhglrd"
},
"corpo": {
"io": {
"numero": "8955",
"nome": "hlzthnx.jnxdk"
},
"barra": [
{
"numero": "5555",
"nome": "ndkwq.shzgd",
"nome_visibile": "Pxkjk gx xrfpm",
"riservato": false,
"seguito": true,
"pubblicazioni": 18,
"ritratto": [
{
"indirizzo": "https://cdn.esempio/23wh5n049rr81521.jpg",
"larghezza": 160,
"altezza": 160
},
{
"indirizzo": "https://cdn.esempio/h46r930r17f94226.jpg",
"larghezza": 320,
"altezza": 320
}
],
"ultima_storia": "2026-10-13T15:11:20Z"
},
{
"numero": "5966",
"nome": "mkntl.vqwhn",
"nome_visibile": "Rjlvk dh bknnh",
"riservato": false,
"seguito": true,
"pubblicazioni": 3,
"ritratto": [
{
"indirizzo": "https://cdn.esempio/064248847xjl13s4.jpg",
"larghezza": 160,
"altezza": 160
},
{
"indirizzo": "https://cdn.esempio/8w293gphn3jlm641.jpg",
"larghezza": 320,
"altezza": 320
}
],
"ultima_storia": "2026-10-13T14:16:20Z"
},
{
"numero": "0256",
"nome": "lcfs.gwcfg",
"nome_visibile": "Pnhm ll rrhml",
"riservato": false,
"seguito": true,
"pubblicazioni": 40,
"ritratto": [
{
"indirizzo": "https://cdn.esempio/4z7l3q070rf331lb.jpg",
"larghezza": 160,
"altezza": 160
},
{
"indirizzo": "https://cdn.esempio/j793r3nmp3m7j334.jpg",
"larghezza": 320,
"altezza": 320
}
],
"ultima_storia": "2026-10-13T13:28:20Z"
},
{
"numero": "6473",
"nome": "jscnhk.hsjhd",
"nome_visibile": "Gjcpzg pz xxrgj",
"riservato": true,
"seguito": true,
"pubblicazioni": 6,
"ritratto": [
{
"indirizzo": "https://cdn.esempio/2dx14g1d9l3p3q74.jpg",
"larghezza": 160,
"altezza": 160
},
{
"indirizzo": "https://cdn.esempio/g7g12rt483170931.jpg",
"larghezza": 320,
"altezza": 320
}
],
"ultima_storia": "2026-10-13T12:29:20Z"
}
],
"contenuti": [
{
"numero": "3302689957",
"sigla": "8rcvdWt",
"pubblicato": "2026-10-10T14:48:20Z",
"testo": "Vcl dhzqkwhc jzp qhjbrnjb z shldz (zrlhx 432)",
"fissato": false,
"autore": {
"numero": "5555",
"nome": "ndkwq.shzgd"
},
"filmati": [
{
"indirizzo": "https://cdn.esempio/0d6d26g8r5935972.mp4",
"larghezza": 360,
"altezza": 640,
"audio": true
},
{
"indirizzo": "https://cdn.esempio/x34032202148491c.mp4",
"larghezza": 720,
"altezza": 1280,
"audio": true
},
{
"indirizzo": "https://cdn.esempio/83w592bg386k8609.mp4",
"larghezza": 1080,
"altezza": 1920,
"audio": false
}
],
"foto": [
{
"indirizzo": "https://cdn.esempio/90qk240653054970.jpg",
"larghezza": 360,
"altezza": 640
},
{
"indirizzo": "https://cdn.esempio/v7gs5c4676403p19.jpg",
"larghezza": 720,
"altezza": 1280
}
],
"durata": 2
},
{
"numero": "5977241902",
"sigla": "kkjHtrm",
"pubblicato": "2026-10-09T17:18:20Z",
"testo": "Kdf lbrnqkhp jgp rlndgtxfhz c lpftbkpg (jwsvd 617)",
"fissato": false,
"autore": {
"numero": "5966",
"nome": "mkntl.vqwhn"
},
"foto": [
{
"indirizzo": "https://cdn.esempio/bz06230s32v5302j.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/d4nh46r5232dm305.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/g287z3d071z69416.jpg",
"larghezza": 240,
"altezza": 300
}
]
},
{
"numero": "8040221611",
"sigla": "B7hR3PV",
"pubblicato": "2026-10-09T02:06:20Z",
"testo": "Zmx kdcdxtxd qsh czsmsbj r drzg (hvzlw 775)",
"fissato": false,
"autore": {
"numero": "5555",
"nome": "ndkwq.shzgd"
},
"foto": [
{
"indirizzo": "https://cdn.esempio/1718b0k40tg62335.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/67qg4t1f22l1l42d.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/c64ktw348d4p7n5d.jpg",
"larghezza": 240,
"altezza": 300
}
]
},
{
"numero": "5713768118",
"sigla": "rChwmFc",
"pubblicato": "2026-10-08T18:19:20Z",
"testo": "Jvt gvtcxpmj kph gwclq d wxksn (ztvfv 460)",
"fissato": false,
"autore": {
"numero": "6473",
"nome": "jscnhk.hsjhd"
},
"foto": [
{
"indirizzo": "https://cdn.esempio/0tj7n92s2t48021m.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/00st4z0v3lh55b8m.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/gpgkr6087n24455l.jpg",
"larghezza": 240,
"altezza": 300
}
]
},
{
"numero": "5060179360",
"sigla": "1D2tpsn",
"pubblicato": "2026-10-08T10:57:20Z",
"testo": "Dzm zbvgfxtg hmt szkmh k kpxhmjjbj (vjcrg 561)",
"fissato": false,
"autore": {
"numero": "0256",
"nome": "lcfs.gwcfg"
},
"foto": [
{
"indirizzo": "https://cdn.esempio/7z3z1l84nx9027lp.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/7d53931df99139s8.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/gf06gf6q767b2961.jpg",
"larghezza": 240,
"altezza": 300
}
]
},
{
"numero": "6686720181",
"sigla": "TqwwCvG",
"pubblicato": "2026-10-07T10:47:20Z",
"testo": "Dqr cldxlrdk lxc nwlszbwr v blhfr (mtqhp 671)",
"fissato": false,
"autore": {
"numero": "5555",
"nome": "ndkwq.shzgd"
},
"parti": [
{
"numero": "4391148625",
"foto": [
{
"indirizzo": "https://cdn.esempio/zhzj06v06q4p7746.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/r85287t3l0f8937z.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/1z5tdb2994zbq0h0.jpg",
"larghezza": 240,
"altezza": 300
}
]
}
],
"parti_totali": 3
}
],
"pagina": {
"altro": true,
"dopo": "w3"
}
}
}
@@ -0,0 +1,637 @@
{
"descrittore": {
"indirizzo": "https://sito.esempio/52bf0789xw73302n",
"host": "sito",
"stato": 200,
"tipo": "application/json",
"risorsa": "Fetch",
"nome": "hpccwvk-zvcgqkrc"
},
"corpo": {
"profilo": {
"numero": "5555",
"nome": "ndkwq.shzgd",
"nome_visibile": "Pxkjk gx xrfpm",
"riservato": false,
"seguito": true,
"pubblicazioni": 18,
"ritratto": [
{
"indirizzo": "https://cdn.esempio/23wh5n049rr81521.jpg",
"larghezza": 160,
"altezza": 160
},
{
"indirizzo": "https://cdn.esempio/h46r930r17f94226.jpg",
"larghezza": 320,
"altezza": 320
}
],
"ultima_storia": "2026-10-13T15:11:20Z"
},
"raccolte": [
{
"numero": "3688348931",
"titolo": "Wxmngt",
"autore": {
"numero": "5555",
"nome": "ndkwq.shzgd"
},
"copertina": {
"indirizzo": "https://cdn.esempio/1z6s13040g7z0691.jpg",
"larghezza": 160,
"altezza": 284
}
},
{
"numero": "3331216123",
"titolo": "Jpjhhx",
"autore": {
"numero": "5555",
"nome": "ndkwq.shzgd"
},
"copertina": {
"indirizzo": "https://cdn.esempio/0p2jfc2b0263j919.jpg",
"larghezza": 160,
"altezza": 284
}
}
],
"contenuti": [
{
"numero": "0550913031",
"sigla": "jdd5w0f",
"pubblicato": "2026-09-28T00:28:20Z",
"testo": "Snz qfprnqzz zvp tcrltrwh k kgxq (hnnrv 634)",
"fissato": true,
"autore": {
"numero": "5555",
"nome": "ndkwq.shzgd"
},
"foto": [
{
"indirizzo": "https://cdn.esempio/9948hlb7bb0ltqd3.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/28sh466jsc774p89.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/655qhv6z280782j5.jpg",
"larghezza": 240,
"altezza": 300
}
]
},
{
"numero": "6157292435",
"sigla": "8lHWJPg",
"pubblicato": "2026-09-21T16:40:20Z",
"testo": "Tbv mrfdlhmf lml nwrrdhnz k mnszp (gnglb 25)",
"fissato": true,
"autore": {
"numero": "5555",
"nome": "ndkwq.shzgd"
},
"parti": [
{
"numero": "1552522150",
"foto": [
{
"indirizzo": "https://cdn.esempio/3vf1c1n1mk43w89b.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/2221008r9z272t9h.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/5333k8w0996b3979.jpg",
"larghezza": 240,
"altezza": 300
}
]
},
{
"numero": "4565425648",
"filmati": [
{
"indirizzo": "https://cdn.esempio/64tm3nnd6nq4940q.mp4",
"larghezza": 360,
"altezza": 640,
"audio": true
},
{
"indirizzo": "https://cdn.esempio/074212n7q00c2r00.mp4",
"larghezza": 720,
"altezza": 1280,
"audio": true
},
{
"indirizzo": "https://cdn.esempio/ms25598364j44g7b.mp4",
"larghezza": 1080,
"altezza": 1920,
"audio": false
}
],
"foto": [
{
"indirizzo": "https://cdn.esempio/89663vt1nm66h24r.jpg",
"larghezza": 360,
"altezza": 640
},
{
"indirizzo": "https://cdn.esempio/6m70rr25412np086.jpg",
"larghezza": 720,
"altezza": 1280
}
],
"durata": 2
},
{
"numero": "8323338275",
"foto": [
{
"indirizzo": "https://cdn.esempio/k80njbg871fwg77b.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/c383cwr827pz18w4.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/415h8k26359x102r.jpg",
"larghezza": 240,
"altezza": 300
}
]
}
],
"parti_totali": 3
},
{
"numero": "3302689957",
"sigla": "8rcvdWt",
"pubblicato": "2026-10-10T14:48:20Z",
"testo": "Vcl dhzqkwhc jzp qhjbrnjb z shldz (zrlhx 432)",
"fissato": false,
"autore": {
"numero": "5555",
"nome": "ndkwq.shzgd"
},
"filmati": [
{
"indirizzo": "https://cdn.esempio/0d6d26g8r5935972.mp4",
"larghezza": 360,
"altezza": 640,
"audio": true
},
{
"indirizzo": "https://cdn.esempio/x34032202148491c.mp4",
"larghezza": 720,
"altezza": 1280,
"audio": true
},
{
"indirizzo": "https://cdn.esempio/83w592bg386k8609.mp4",
"larghezza": 1080,
"altezza": 1920,
"audio": false
}
],
"foto": [
{
"indirizzo": "https://cdn.esempio/90qk240653054970.jpg",
"larghezza": 360,
"altezza": 640
},
{
"indirizzo": "https://cdn.esempio/v7gs5c4676403p19.jpg",
"larghezza": 720,
"altezza": 1280
}
],
"durata": 2
},
{
"numero": "8040221611",
"sigla": "B7hR3PV",
"pubblicato": "2026-10-09T02:06:20Z",
"testo": "Zmx kdcdxtxd qsh czsmsbj r drzg (hvzlw 775)",
"fissato": false,
"autore": {
"numero": "5555",
"nome": "ndkwq.shzgd"
},
"foto": [
{
"indirizzo": "https://cdn.esempio/1718b0k40tg62335.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/67qg4t1f22l1l42d.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/c64ktw348d4p7n5d.jpg",
"larghezza": 240,
"altezza": 300
}
]
},
{
"numero": "6686720181",
"sigla": "TqwwCvG",
"pubblicato": "2026-10-07T10:47:20Z",
"testo": "Dqr cldxlrdk lxc nwlszbwr v blhfr (mtqhp 671)",
"fissato": false,
"autore": {
"numero": "5555",
"nome": "ndkwq.shzgd"
},
"parti": [
{
"numero": "4391148625",
"foto": [
{
"indirizzo": "https://cdn.esempio/zhzj06v06q4p7746.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/r85287t3l0f8937z.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/1z5tdb2994zbq0h0.jpg",
"larghezza": 240,
"altezza": 300
}
]
},
{
"numero": "9823770084",
"filmati": [
{
"indirizzo": "https://cdn.esempio/wnr19826v154499b.mp4",
"larghezza": 360,
"altezza": 640,
"audio": true
},
{
"indirizzo": "https://cdn.esempio/q9v6mwrtbsv0xdw9.mp4",
"larghezza": 720,
"altezza": 1280,
"audio": true
},
{
"indirizzo": "https://cdn.esempio/d9fgg81s94s0764w.mp4",
"larghezza": 1080,
"altezza": 1920,
"audio": false
}
],
"foto": [
{
"indirizzo": "https://cdn.esempio/48f0c0s2bkx7d256.jpg",
"larghezza": 360,
"altezza": 640
},
{
"indirizzo": "https://cdn.esempio/715z79k6z3004ss1.jpg",
"larghezza": 720,
"altezza": 1280
}
],
"durata": 2
},
{
"numero": "8883127657",
"foto": [
{
"indirizzo": "https://cdn.esempio/dfn95518270592f7.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/5095893x3k0780c6.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/t5ks39vq5zc981h8.jpg",
"larghezza": 240,
"altezza": 300
}
]
}
],
"parti_totali": 3
},
{
"numero": "6321126038",
"sigla": "jC81Q1b",
"pubblicato": "2026-10-05T23:37:20Z",
"testo": "Ndr grbgdxxd lkj jbbgxntjq b frtphxbh (tmpxs 590)",
"fissato": false,
"autore": {
"numero": "5555",
"nome": "ndkwq.shzgd"
},
"foto": [
{
"indirizzo": "https://cdn.esempio/6qr19112751l69r3.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/44172102cn8s1g9j.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/bsw10n29mr3g3c8q.jpg",
"larghezza": 240,
"altezza": 300
}
]
},
{
"numero": "7876082571",
"sigla": "xGp6LQj",
"pubblicato": "2026-10-04T07:09:20Z",
"testo": "Cch bbgmbhxr tml htbzj c nzpjxvjnxp (ktqpr 025)",
"fissato": false,
"autore": {
"numero": "5555",
"nome": "ndkwq.shzgd"
},
"foto": [
{
"indirizzo": "https://cdn.esempio/h3157zk405828529.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/fxcw0h67d1w013q8.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/cpb269088h89ckq1.jpg",
"larghezza": 240,
"altezza": 300
}
]
},
{
"numero": "0363675401",
"sigla": "FLPGT73",
"pubblicato": "2026-10-02T19:34:20Z",
"testo": "Tww fjftnpqq wrn rbzpm p bbpgtk (qwmhj 275)",
"fissato": false,
"autore": {
"numero": "5555",
"nome": "ndkwq.shzgd"
},
"filmati": [
{
"indirizzo": "https://cdn.esempio/70257lc16jzmv587.mp4",
"larghezza": 360,
"altezza": 640,
"audio": true
},
{
"indirizzo": "https://cdn.esempio/g3s36fpb68s4j118.mp4",
"larghezza": 720,
"altezza": 1280,
"audio": true
},
{
"indirizzo": "https://cdn.esempio/zp1t83g6hb6r284v.mp4",
"larghezza": 1080,
"altezza": 1920,
"audio": false
}
],
"foto": [
{
"indirizzo": "https://cdn.esempio/37f247ft8t2z24tv.jpg",
"larghezza": 360,
"altezza": 640
},
{
"indirizzo": "https://cdn.esempio/3303cgh77jx8t0w2.jpg",
"larghezza": 720,
"altezza": 1280
}
],
"durata": 2
},
{
"numero": "6106657355",
"sigla": "hjffss2",
"pubblicato": "2026-10-01T04:31:20Z",
"testo": "Cvc qwvcppph prp bsdrxxjv h zqfzqmh (fggll 021)",
"fissato": false,
"autore": {
"numero": "5555",
"nome": "ndkwq.shzgd"
},
"foto": [
{
"indirizzo": "https://cdn.esempio/66978h1mbz738419.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/b67r858s5x24bzff.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/hm173vf286gvjv37.jpg",
"larghezza": 240,
"altezza": 300
}
]
},
{
"numero": "7932098954",
"sigla": "j6rFHQP",
"pubblicato": "2026-09-29T15:10:20Z",
"testo": "Vxf hhgcppgv pwr wbrfjjnn c qvqk (cqtkz 783)",
"fissato": false,
"autore": {
"numero": "5555",
"nome": "ndkwq.shzgd"
},
"parti": [
{
"numero": "9313115541",
"foto": [
{
"indirizzo": "https://cdn.esempio/91492575z3r074n2.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/8d14mm694fq3csjr.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/ws694k42w7j109qd.jpg",
"larghezza": 240,
"altezza": 300
}
]
},
{
"numero": "7013138795",
"filmati": [
{
"indirizzo": "https://cdn.esempio/150k4k3j9wrx002j.mp4",
"larghezza": 360,
"altezza": 640,
"audio": true
},
{
"indirizzo": "https://cdn.esempio/80r054t7451679xl.mp4",
"larghezza": 720,
"altezza": 1280,
"audio": true
},
{
"indirizzo": "https://cdn.esempio/52777993sq4k5fqh.mp4",
"larghezza": 1080,
"altezza": 1920,
"audio": false
}
],
"foto": [
{
"indirizzo": "https://cdn.esempio/d3744z6wh03sk9s9.jpg",
"larghezza": 360,
"altezza": 640
},
{
"indirizzo": "https://cdn.esempio/5318z833z608945f.jpg",
"larghezza": 720,
"altezza": 1280
}
],
"durata": 2
},
{
"numero": "3338324319",
"foto": [
{
"indirizzo": "https://cdn.esempio/8ft1345rlt407k64.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/404fs3nw5wwd894h.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/8975t5cpc6283cj0.jpg",
"larghezza": 240,
"altezza": 300
}
]
}
],
"parti_totali": 3
},
{
"numero": "7580432133",
"sigla": "57FWWCj",
"pubblicato": "2026-09-26T10:32:20Z",
"testo": "Gvw rccrfrsb wkq fzkf w qvqrtnzs (pwjsk 33)",
"fissato": false,
"autore": {
"numero": "5555",
"nome": "ndkwq.shzgd"
},
"foto": [
{
"indirizzo": "https://cdn.esempio/2cg52f5r39bghv81.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/080qn88f2r477k51.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/n65p6024s3lf1097.jpg",
"larghezza": 240,
"altezza": 300
}
]
},
{
"numero": "1418527932",
"sigla": "k4C1jws",
"pubblicato": "2026-09-24T19:24:20Z",
"testo": "Dgq tqbnskfk tkg zntpm t ghdbr (whghc 553)",
"fissato": false,
"autore": {
"numero": "5555",
"nome": "ndkwq.shzgd"
},
"filmati": [
{
"indirizzo": "https://cdn.esempio/fkdvr64wwvt45870.mp4",
"larghezza": 360,
"altezza": 640,
"audio": true
},
{
"indirizzo": "https://cdn.esempio/315q378h2j2kc438.mp4",
"larghezza": 720,
"altezza": 1280,
"audio": true
},
{
"indirizzo": "https://cdn.esempio/17tr0k4c93c2x8s1.mp4",
"larghezza": 1080,
"altezza": 1920,
"audio": false
}
],
"foto": [
{
"indirizzo": "https://cdn.esempio/9p6rh8r2p59b4rm1.jpg",
"larghezza": 360,
"altezza": 640
},
{
"indirizzo": "https://cdn.esempio/7lk12bk36tw2x771.jpg",
"larghezza": 720,
"altezza": 1280
}
],
"durata": 2
}
],
"pagina": {
"altro": true,
"dopo": "n17"
}
}
}
@@ -0,0 +1,386 @@
{
"descrittore": {
"indirizzo": "https://sito.esempio/rm07847qj48b3072",
"host": "sito",
"stato": 200,
"tipo": "application/json",
"risorsa": "Fetch",
"nome": "jmjzbwb-dgmhpn-zzhdhcwbwj"
},
"corpo": {
"contenuti": [
{
"numero": "4502918696",
"sigla": "dMjn3v6",
"pubblicato": "2026-09-15T12:11:20Z",
"testo": "Trj ghqgmknx xmp qdlhqxnw m thmntff (xcgpp 682)",
"fissato": false,
"autore": {
"numero": "0256",
"nome": "lcfs.gwcfg"
},
"foto": [
{
"indirizzo": "https://cdn.esempio/4n88hwj0x9g1b141.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/gx1566hm0b487358.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/h19402tsmm64h1w1.jpg",
"larghezza": 240,
"altezza": 300
}
]
},
{
"numero": "8765793363",
"sigla": "2mFPBfG",
"pubblicato": "2026-09-13T14:49:20Z",
"testo": "Rnn hmkpgplk bfn lkdglvd w zppfl (ntgxt 056)",
"fissato": false,
"autore": {
"numero": "0256",
"nome": "lcfs.gwcfg"
},
"foto": [
{
"indirizzo": "https://cdn.esempio/2176j6p843x8415k.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/9nlv8pt4c85691cl.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/0t098j299t1j1044.jpg",
"larghezza": 240,
"altezza": 300
}
]
},
{
"numero": "0874654136",
"sigla": "3ccFRmS",
"pubblicato": "2026-09-11T15:10:20Z",
"testo": "Mnx dnqppdzf wmm lxsxr q xtdzv (fmgsp 444)",
"fissato": false,
"autore": {
"numero": "0256",
"nome": "lcfs.gwcfg"
},
"foto": [
{
"indirizzo": "https://cdn.esempio/40r4q9138s675d7r.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/60p0673c2h42fmvs.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/0m57r379b1tc211p.jpg",
"larghezza": 240,
"altezza": 300
}
]
},
{
"numero": "3324924951",
"sigla": "Tvmhgpb",
"pubblicato": "2026-09-09T17:57:20Z",
"testo": "Zvr jgvnlfmw trc hlzzw j ktwjs (tdnvx 482)",
"fissato": false,
"autore": {
"numero": "0256",
"nome": "lcfs.gwcfg"
},
"filmati": [
{
"indirizzo": "https://cdn.esempio/4c93295d27f61210.mp4",
"larghezza": 360,
"altezza": 640,
"audio": true
},
{
"indirizzo": "https://cdn.esempio/kt97k7rk4802h475.mp4",
"larghezza": 720,
"altezza": 1280,
"audio": true
},
{
"indirizzo": "https://cdn.esempio/n390f17c7p1h4p6l.mp4",
"larghezza": 1080,
"altezza": 1920,
"audio": false
}
],
"foto": [
{
"indirizzo": "https://cdn.esempio/6z08483011j5h6c7.jpg",
"larghezza": 360,
"altezza": 640
},
{
"indirizzo": "https://cdn.esempio/2611l36636120380.jpg",
"larghezza": 720,
"altezza": 1280
}
],
"durata": 2
},
{
"numero": "5525237871",
"sigla": "6fw0qb2",
"pubblicato": "2026-09-07T19:28:20Z",
"testo": "Skn wwdhxkfr kmc dhssbjmjxs x swhdmkxl (bqqqv 876)",
"fissato": false,
"autore": {
"numero": "0256",
"nome": "lcfs.gwcfg"
},
"foto": [
{
"indirizzo": "https://cdn.esempio/j2k75j49l79bjh8m.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/l190x2hw6444j45n.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/54wp51n3108k7612.jpg",
"larghezza": 240,
"altezza": 300
}
]
},
{
"numero": "3506125164",
"sigla": "w4NmPhQ",
"pubblicato": "2026-09-05T21:52:20Z",
"testo": "Crr krvpbfrc cps wsqfvsgflw p txmcncjg (pwwnb 023)",
"fissato": false,
"autore": {
"numero": "0256",
"nome": "lcfs.gwcfg"
},
"foto": [
{
"indirizzo": "https://cdn.esempio/91jg371b71ff4035.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/htpgr2xf9cc1dfm7.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/249j349vplkfk424.jpg",
"larghezza": 240,
"altezza": 300
}
]
},
{
"numero": "7747667947",
"sigla": "WNKBMWR",
"pubblicato": "2026-09-04T00:02:20Z",
"testo": "Ggk rbzswhvr qcx tmgf h lbvm (dgqlp 118)",
"fissato": false,
"autore": {
"numero": "0256",
"nome": "lcfs.gwcfg"
},
"foto": [
{
"indirizzo": "https://cdn.esempio/zv1d386z67w7nwlp.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/c3x03056k9926jh7.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/053dnmkv3239v2k9.jpg",
"larghezza": 240,
"altezza": 300
}
]
},
{
"numero": "7784024018",
"sigla": "FtRGXMW",
"pubblicato": "2026-09-02T02:28:20Z",
"testo": "Xcf ktkdbxtn dxj dddvd t jblnj (bzskb 889)",
"fissato": false,
"autore": {
"numero": "0256",
"nome": "lcfs.gwcfg"
},
"foto": [
{
"indirizzo": "https://cdn.esempio/485181h51lg19p0k.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/j3439ckkps53fw56.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/zhcdmwk908d2c09j.jpg",
"larghezza": 240,
"altezza": 300
}
]
},
{
"numero": "7393153212",
"sigla": "zT6sJjr",
"pubblicato": "2026-08-31T02:42:20Z",
"testo": "Jwd jqdpbfnw zzm zcpv b xgftbnj (rnkqj 107)",
"fissato": false,
"autore": {
"numero": "0256",
"nome": "lcfs.gwcfg"
},
"foto": [
{
"indirizzo": "https://cdn.esempio/428w24271h77j75d.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/70607m5x574394xr.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/5rnq242tj9596137.jpg",
"larghezza": 240,
"altezza": 300
}
]
},
{
"numero": "7891992286",
"sigla": "1QLdfRR",
"pubblicato": "2026-08-29T05:59:20Z",
"testo": "Chd xjtrnvbv jdk cnsqrvtb r nzqf (xdsbn 982)",
"fissato": false,
"autore": {
"numero": "0256",
"nome": "lcfs.gwcfg"
},
"foto": [
{
"indirizzo": "https://cdn.esempio/6p5479gc02jj6s0z.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/7t7hr2mr58zrtf7m.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/1013303rt707407w.jpg",
"larghezza": 240,
"altezza": 300
}
]
},
{
"numero": "7565829130",
"sigla": "Z4P6dHK",
"pubblicato": "2026-08-27T07:43:20Z",
"testo": "Ckn pbpfcqxc lxs xqrqplpm c kjnkq (bpjls 661)",
"fissato": false,
"autore": {
"numero": "0256",
"nome": "lcfs.gwcfg"
},
"filmati": [
{
"indirizzo": "https://cdn.esempio/18w20s1c506f3z80.mp4",
"larghezza": 360,
"altezza": 640,
"audio": true
},
{
"indirizzo": "https://cdn.esempio/5t91m91223j97b0t.mp4",
"larghezza": 720,
"altezza": 1280,
"audio": true
},
{
"indirizzo": "https://cdn.esempio/6c61570xt4s0v1f4.mp4",
"larghezza": 1080,
"altezza": 1920,
"audio": false
}
],
"foto": [
{
"indirizzo": "https://cdn.esempio/j4719937j47xfg3v.jpg",
"larghezza": 360,
"altezza": 640
},
{
"indirizzo": "https://cdn.esempio/57gsn441s4l10892.jpg",
"larghezza": 720,
"altezza": 1280
}
],
"durata": 2
},
{
"numero": "8103152571",
"sigla": "GSj6xlF",
"pubblicato": "2026-08-25T10:12:20Z",
"testo": "Zdh vdqbdgxp dsb blvb w hsss (sgblz 068)",
"fissato": false,
"autore": {
"numero": "0256",
"nome": "lcfs.gwcfg"
},
"foto": [
{
"indirizzo": "https://cdn.esempio/5p54377549062d10.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/067mt8003l6638jb.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/s9bz0ddl476trsh1.jpg",
"larghezza": 240,
"altezza": 300
}
]
}
],
"pagina": {
"altro": true,
"dopo": "n20"
}
}
}
@@ -0,0 +1,37 @@
{
"descrittore": {
"indirizzo": "https://sito.esempio/25602tp1p503hv93",
"host": "sito",
"stato": 200,
"tipo": "application/json",
"risorsa": "Fetch",
"nome": "kknqvzl-pmtgtmr-cbw-xsbdtqn"
},
"corpo": {
"profilo": {
"numero": "1230",
"nome": "trhhflpwk.jghjf",
"nome_visibile": "Zrlmvdb mnhrfpzzv",
"riservato": true,
"seguito": false,
"pubblicazioni": 5,
"ritratto": [
{
"indirizzo": "https://cdn.esempio/f453n389229j08cz.jpg",
"larghezza": 160,
"altezza": 160
},
{
"indirizzo": "https://cdn.esempio/hg23k452n6kq3h26.jpg",
"larghezza": 320,
"altezza": 320
}
]
},
"contenuti": [],
"pagina": {
"altro": false,
"dopo": null
}
}
}
@@ -0,0 +1,102 @@
{
"descrittore": {
"indirizzo": "https://sito.esempio/121076l2w14dpln2",
"host": "sito",
"stato": 200,
"tipo": "application/json",
"risorsa": "Fetch",
"nome": "cvzv-qdpsp"
},
"corpo": {
"contenuto": {
"numero": "6686720181",
"sigla": "TqwwCvG",
"pubblicato": "2026-10-07T10:47:20Z",
"testo": "Dqr cldxlrdk lxc nwlszbwr v blhfr (mtqhp 671)",
"fissato": false,
"autore": {
"numero": "5555",
"nome": "ndkwq.shzgd"
},
"parti": [
{
"numero": "4391148625",
"foto": [
{
"indirizzo": "https://cdn.esempio/zhzj06v06q4p7746.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/r85287t3l0f8937z.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/1z5tdb2994zbq0h0.jpg",
"larghezza": 240,
"altezza": 300
}
]
},
{
"numero": "9823770084",
"filmati": [
{
"indirizzo": "https://cdn.esempio/wnr19826v154499b.mp4",
"larghezza": 360,
"altezza": 640,
"audio": true
},
{
"indirizzo": "https://cdn.esempio/q9v6mwrtbsv0xdw9.mp4",
"larghezza": 720,
"altezza": 1280,
"audio": true
},
{
"indirizzo": "https://cdn.esempio/d9fgg81s94s0764w.mp4",
"larghezza": 1080,
"altezza": 1920,
"audio": false
}
],
"foto": [
{
"indirizzo": "https://cdn.esempio/48f0c0s2bkx7d256.jpg",
"larghezza": 360,
"altezza": 640
},
{
"indirizzo": "https://cdn.esempio/715z79k6z3004ss1.jpg",
"larghezza": 720,
"altezza": 1280
}
],
"durata": 2
},
{
"numero": "8883127657",
"foto": [
{
"indirizzo": "https://cdn.esempio/dfn95518270592f7.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/5095893x3k0780c6.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/t5ks39vq5zc981h8.jpg",
"larghezza": 240,
"altezza": 300
}
]
}
],
"parti_totali": 3
}
}
}
@@ -0,0 +1,139 @@
{
"descrittore": {
"indirizzo": "https://sito.esempio/31632f51p8cn7scw",
"host": "sito",
"stato": 200,
"tipo": "application/json",
"risorsa": "Fetch",
"nome": "bfqhxs"
},
"corpo": {
"autore": {
"numero": "5555",
"nome": "ndkwq.shzgd"
},
"storie": [
{
"numero": "4701597641",
"pubblicato": "2026-10-13T06:38:20Z",
"scade": "2026-10-14T06:38:20Z",
"autore": {
"numero": "5555",
"nome": "ndkwq.shzgd"
},
"foto": [
{
"indirizzo": "https://cdn.esempio/189q0t5632714fcc.jpg",
"larghezza": 360,
"altezza": 640
},
{
"indirizzo": "https://cdn.esempio/84vw8n35zdb64378.jpg",
"larghezza": 720,
"altezza": 1280
},
{
"indirizzo": "https://cdn.esempio/9780fl4p0980442k.jpg",
"larghezza": 180,
"altezza": 320
}
]
},
{
"numero": "8905852591",
"pubblicato": "2026-10-13T08:11:20Z",
"scade": "2026-10-14T08:11:20Z",
"autore": {
"numero": "5555",
"nome": "ndkwq.shzgd"
},
"foto": [
{
"indirizzo": "https://cdn.esempio/w7985ff6p815t616.jpg",
"larghezza": 360,
"altezza": 640
},
{
"indirizzo": "https://cdn.esempio/442c758js6s5c5g8.jpg",
"larghezza": 720,
"altezza": 1280
},
{
"indirizzo": "https://cdn.esempio/8b5g5nz283v48333.jpg",
"larghezza": 180,
"altezza": 320
}
]
},
{
"numero": "9513884481",
"pubblicato": "2026-10-13T11:36:20Z",
"scade": "2026-10-14T11:36:20Z",
"autore": {
"numero": "5555",
"nome": "ndkwq.shzgd"
},
"filmati": [
{
"indirizzo": "https://cdn.esempio/9687063g7904270w.mp4",
"larghezza": 360,
"altezza": 640,
"audio": true
},
{
"indirizzo": "https://cdn.esempio/vz310z8chrr5887w.mp4",
"larghezza": 720,
"altezza": 1280,
"audio": true
},
{
"indirizzo": "https://cdn.esempio/j36755t64qh1nr74.mp4",
"larghezza": 1080,
"altezza": 1920,
"audio": false
}
],
"foto": [
{
"indirizzo": "https://cdn.esempio/67803n38j6cmsv0t.jpg",
"larghezza": 360,
"altezza": 640
},
{
"indirizzo": "https://cdn.esempio/75l2gb30f0cl5p06.jpg",
"larghezza": 720,
"altezza": 1280
}
],
"durata": 2
},
{
"numero": "0613682151",
"pubblicato": "2026-10-13T15:11:20Z",
"scade": "2026-10-14T15:11:20Z",
"autore": {
"numero": "5555",
"nome": "ndkwq.shzgd"
},
"foto": [
{
"indirizzo": "https://cdn.esempio/24j4tt8d6358rq8m.jpg",
"larghezza": 360,
"altezza": 640
},
{
"indirizzo": "https://cdn.esempio/8vz4w53dnb9h7mzh.jpg",
"larghezza": 720,
"altezza": 1280
},
{
"indirizzo": "https://cdn.esempio/n0kl9g2379mz0x14.jpg",
"larghezza": 180,
"altezza": 320
}
]
}
],
"successivo": "mkntl.vqwhn"
}
}
@@ -0,0 +1,119 @@
{
"descrittore": {
"indirizzo": "https://sito.esempio/w0nrzbg537370cb3",
"host": "sito",
"stato": 200,
"tipo": "application/json",
"risorsa": "Fetch",
"nome": "wxrhhwml"
},
"corpo": {
"raccolta": {
"numero": "3688348931",
"titolo": "Wxmngt",
"autore": {
"numero": "5555",
"nome": "ndkwq.shzgd"
},
"copertina": {
"indirizzo": "https://cdn.esempio/1z6s13040g7z0691.jpg",
"larghezza": 160,
"altezza": 284
},
"contenuti": [
{
"numero": "2445846299",
"pubblicato": "2026-08-14T16:39:20Z",
"autore": {
"numero": "5555",
"nome": "ndkwq.shzgd"
},
"foto": [
{
"indirizzo": "https://cdn.esempio/6rc62lqn469700xh.jpg",
"larghezza": 360,
"altezza": 640
},
{
"indirizzo": "https://cdn.esempio/k468864wzj19p0db.jpg",
"larghezza": 720,
"altezza": 1280
},
{
"indirizzo": "https://cdn.esempio/04hf78n7pbl9325t.jpg",
"larghezza": 180,
"altezza": 320
}
]
},
{
"numero": "5569978446",
"pubblicato": "2026-08-15T16:39:20Z",
"autore": {
"numero": "5555",
"nome": "ndkwq.shzgd"
},
"filmati": [
{
"indirizzo": "https://cdn.esempio/4722w5smm74z9hz4.mp4",
"larghezza": 360,
"altezza": 640,
"audio": true
},
{
"indirizzo": "https://cdn.esempio/jw574n5630s84300.mp4",
"larghezza": 720,
"altezza": 1280,
"audio": true
},
{
"indirizzo": "https://cdn.esempio/4s85629r8141ks8z.mp4",
"larghezza": 1080,
"altezza": 1920,
"audio": false
}
],
"foto": [
{
"indirizzo": "https://cdn.esempio/1574h2s0m88rlrbp.jpg",
"larghezza": 360,
"altezza": 640
},
{
"indirizzo": "https://cdn.esempio/zrpbb8n47gc9n793.jpg",
"larghezza": 720,
"altezza": 1280
}
],
"durata": 2
},
{
"numero": "8905852591",
"pubblicato": "2026-10-13T08:11:20Z",
"autore": {
"numero": "5555",
"nome": "ndkwq.shzgd"
},
"foto": [
{
"indirizzo": "https://cdn.esempio/w7985ff6p815t616.jpg",
"larghezza": 360,
"altezza": 640
},
{
"indirizzo": "https://cdn.esempio/442c758js6s5c5g8.jpg",
"larghezza": 720,
"altezza": 1280
},
{
"indirizzo": "https://cdn.esempio/8b5g5nz283v48333.jpg",
"larghezza": 180,
"altezza": 320
}
]
}
]
},
"successiva": "3331216123"
}
}
@@ -0,0 +1,222 @@
{
"descrittore": {
"indirizzo": "https://sito.esempio/71kp36c44gt303c7",
"host": "sito",
"stato": 200,
"tipo": "application/json",
"risorsa": "Fetch",
"nome": "jvbzzgh"
},
"corpo": {
"seguiti": [
{
"numero": "5555",
"nome": "ndkwq.shzgd",
"nome_visibile": "Pxkjk gx xrfpm",
"riservato": false,
"seguito": true,
"pubblicazioni": 18,
"ritratto": [
{
"indirizzo": "https://cdn.esempio/23wh5n049rr81521.jpg",
"larghezza": 160,
"altezza": 160
},
{
"indirizzo": "https://cdn.esempio/h46r930r17f94226.jpg",
"larghezza": 320,
"altezza": 320
}
],
"ultima_storia": "2026-10-13T15:11:20Z"
},
{
"numero": "0256",
"nome": "lcfs.gwcfg",
"nome_visibile": "Pnhm ll rrhml",
"riservato": false,
"seguito": true,
"pubblicazioni": 40,
"ritratto": [
{
"indirizzo": "https://cdn.esempio/4z7l3q070rf331lb.jpg",
"larghezza": 160,
"altezza": 160
},
{
"indirizzo": "https://cdn.esempio/j793r3nmp3m7j334.jpg",
"larghezza": 320,
"altezza": 320
}
],
"ultima_storia": "2026-10-13T13:28:20Z"
},
{
"numero": "6473",
"nome": "jscnhk.hsjhd",
"nome_visibile": "Gjcpzg pz xxrgj",
"riservato": true,
"seguito": true,
"pubblicazioni": 6,
"ritratto": [
{
"indirizzo": "https://cdn.esempio/2dx14g1d9l3p3q74.jpg",
"larghezza": 160,
"altezza": 160
},
{
"indirizzo": "https://cdn.esempio/g7g12rt483170931.jpg",
"larghezza": 320,
"altezza": 320
}
],
"ultima_storia": "2026-10-13T12:29:20Z"
},
{
"numero": "5966",
"nome": "mkntl.vqwhn",
"nome_visibile": "Rjlvk dh bknnh",
"riservato": false,
"seguito": true,
"pubblicazioni": 3,
"ritratto": [
{
"indirizzo": "https://cdn.esempio/064248847xjl13s4.jpg",
"larghezza": 160,
"altezza": 160
},
{
"indirizzo": "https://cdn.esempio/8w293gphn3jlm641.jpg",
"larghezza": 320,
"altezza": 320
}
],
"ultima_storia": "2026-10-13T14:16:20Z"
},
{
"numero": "4360",
"nome": "gbbqw42.qjqvw",
"nome_visibile": "Jxbnh 58",
"riservato": false,
"seguito": true,
"pubblicazioni": 2,
"ritratto": [
{
"indirizzo": "https://cdn.esempio/185g630w73pm8qb5.jpg",
"larghezza": 160,
"altezza": 160
},
{
"indirizzo": "https://cdn.esempio/93738g757779h7x1.jpg",
"larghezza": 320,
"altezza": 320
}
]
},
{
"numero": "5845",
"nome": "qkgtd09.jnbfh",
"nome_visibile": "Tqhln 85",
"riservato": false,
"seguito": true,
"pubblicazioni": 2,
"ritratto": [
{
"indirizzo": "https://cdn.esempio/9ghvw5b8p31779tx.jpg",
"larghezza": 160,
"altezza": 160
},
{
"indirizzo": "https://cdn.esempio/32kdp8z37682n43g.jpg",
"larghezza": 320,
"altezza": 320
}
]
},
{
"numero": "0742",
"nome": "zthfc56.hxksl",
"nome_visibile": "Mmvnh 98",
"riservato": false,
"seguito": true,
"pubblicazioni": 2,
"ritratto": [
{
"indirizzo": "https://cdn.esempio/z7p7k0l49g62h926.jpg",
"larghezza": 160,
"altezza": 160
},
{
"indirizzo": "https://cdn.esempio/z732184kw81703m1.jpg",
"larghezza": 320,
"altezza": 320
}
]
},
{
"numero": "7782",
"nome": "bbxkn53.dlqhb",
"nome_visibile": "Wdtth 40",
"riservato": false,
"seguito": true,
"pubblicazioni": 2,
"ritratto": [
{
"indirizzo": "https://cdn.esempio/32r3671m28vr9l97.jpg",
"larghezza": 160,
"altezza": 160
},
{
"indirizzo": "https://cdn.esempio/g6z59qm27pl17vp1.jpg",
"larghezza": 320,
"altezza": 320
}
]
},
{
"numero": "0332",
"nome": "wdkxc49.gpzzf",
"nome_visibile": "Xjnln 58",
"riservato": false,
"seguito": true,
"pubblicazioni": 1,
"ritratto": [
{
"indirizzo": "https://cdn.esempio/j7458l2d453xc2f5.jpg",
"larghezza": 160,
"altezza": 160
},
{
"indirizzo": "https://cdn.esempio/043g3ct0dl8ql053.jpg",
"larghezza": 320,
"altezza": 320
}
]
},
{
"numero": "5233",
"nome": "bxpwf28.lpxgw",
"nome_visibile": "Fdcrb 54",
"riservato": false,
"seguito": true,
"pubblicazioni": 2,
"ritratto": [
{
"indirizzo": "https://cdn.esempio/05z80g63354fk580.jpg",
"larghezza": 160,
"altezza": 160
},
{
"indirizzo": "https://cdn.esempio/dm6692953m69h184.jpg",
"larghezza": 320,
"altezza": 320
}
]
}
],
"pagina": {
"altro": true,
"dopo": "b44"
}
}
}
@@ -0,0 +1,185 @@
{
"descrittore": {
"indirizzo": "https://sito.esempio/52bf0789xw73302n",
"host": "sito",
"stato": 200,
"tipo": "application/json",
"risorsa": "Fetch",
"nome": "ptghjwf"
},
"corpo": {
"profilo": {
"numero": "5555",
"nome": "ndkwq.shzgd",
"nome_visibile": "Pxkjk gx xrfpm",
"riservato": false,
"seguito": true,
"pubblicazioni": 18,
"ritratto": [
{
"indirizzo": "https://cdn.esempio/23wh5n049rr81521.jpg",
"larghezza": 160,
"altezza": 160
},
{
"indirizzo": "https://cdn.esempio/h46r930r17f94226.jpg",
"larghezza": 320,
"altezza": 320
}
],
"ultima_storia": "2026-10-13T15:11:20Z"
},
"contenuti": [
{
"numero": "5623873993",
"sigla": "WTpK5ph",
"pubblicato": "2026-10-06T06:11:20Z",
"testo": "Knv hpkndmqd ckk vrjhdfbj s nrlmw (vmfsw 899)",
"fissato": false,
"autore": {
"numero": "3279",
"nome": "pngtg.ssrsw"
},
"parti": [
{
"numero": "2154030015",
"foto": [
{
"indirizzo": "https://cdn.esempio/xw15jw99215k6s15.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/42g6sj65125p89rb.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/875vcm3snm538188.jpg",
"larghezza": 240,
"altezza": 300
}
]
},
{
"numero": "9740023776",
"filmati": [
{
"indirizzo": "https://cdn.esempio/1485283h3b05k9tc.mp4",
"larghezza": 360,
"altezza": 640,
"audio": true
},
{
"indirizzo": "https://cdn.esempio/sxv0m43lj14wd889.mp4",
"larghezza": 720,
"altezza": 1280,
"audio": true
},
{
"indirizzo": "https://cdn.esempio/1dmrmv791m9007s2.mp4",
"larghezza": 1080,
"altezza": 1920,
"audio": false
}
],
"foto": [
{
"indirizzo": "https://cdn.esempio/kb36573f64w317x7.jpg",
"larghezza": 360,
"altezza": 640
},
{
"indirizzo": "https://cdn.esempio/36321504p7fg335j.jpg",
"larghezza": 720,
"altezza": 1280
}
],
"durata": 2
},
{
"numero": "3234632840",
"foto": [
{
"indirizzo": "https://cdn.esempio/n46l1278wfk79b2c.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/2x67172s63r718nd.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/192l2721z70s2g76.jpg",
"larghezza": 240,
"altezza": 300
}
]
}
],
"parti_totali": 3
},
{
"numero": "7748249981",
"sigla": "9JJblgk",
"pubblicato": "2026-10-02T19:34:20Z",
"testo": "Qbn qllcxhlb gct kvscl q bcgn (mwqmg 612)",
"fissato": false,
"autore": {
"numero": "0256",
"nome": "lcfs.gwcfg"
},
"foto": [
{
"indirizzo": "https://cdn.esempio/l543l25vm9l51z8w.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/7228grh30hd9xx21.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/95hh432j47ks718t.jpg",
"larghezza": 240,
"altezza": 300
}
]
},
{
"numero": "7021565448",
"sigla": "ZcgM0pZ",
"pubblicato": "2026-09-21T05:03:20Z",
"testo": "Pvk jjgbdjnz dtb qwjmv q rlhw (clvpq 144)",
"fissato": false,
"autore": {
"numero": "0256",
"nome": "lcfs.gwcfg"
},
"foto": [
{
"indirizzo": "https://cdn.esempio/5lp63c52f971n3b6.jpg",
"larghezza": 480,
"altezza": 600
},
{
"indirizzo": "https://cdn.esempio/998wbk3t50b977rb.jpg",
"larghezza": 960,
"altezza": 1200
},
{
"indirizzo": "https://cdn.esempio/kw1r90cs5fq4223h.jpg",
"larghezza": 240,
"altezza": 300
}
]
}
],
"pagina": {
"altro": false,
"dopo": null
}
}
}
@@ -0,0 +1,17 @@
{
"descrittore": {
"indirizzo": "https://sito.esempio/rm07847qj48b3072",
"host": "sito",
"stato": 200,
"tipo": "application/json",
"risorsa": "Fetch",
"nome": "qxzhzr-rkwks"
},
"corpo": {
"contenuti": [],
"pagina": {
"altro": false,
"dopo": null
}
}
}
@@ -0,0 +1,33 @@
{
"descrittore": {
"indirizzo": "https://sito.esempio/nt7w77859pc7037c",
"host": "sito",
"stato": 200,
"tipo": "application/json",
"risorsa": "Fetch",
"nome": "nwsgk-dmvmwznjphl"
},
"corpo": {
"risultati": {
"voci": [
{
"chiave": "T9k6M1g0",
"valore": "lcxrgkjp lq zwtnv mhv gjdmlb prvlmkc mmvtddf",
"dettagli": {
"x": 12,
"y": 7
}
},
{
"chiave": "N9x7S6t2",
"valore": "gb xxcxfnm jhvdttdq",
"dettagli": {
"x": 3,
"y": 4
}
}
]
},
"versione": 3
}
}
@@ -0,0 +1,28 @@
# Campioni ripuliti del sito di prova
Risposte JSON del **sito di prova locale** (`tools/Febe.SitoDiProva`), non di Instagram. Servono alle prove dei
lettori (`tests/Febe.Tests/Collection/ReaderTests.cs`) e hanno fatto lo stesso percorso che faranno i campioni veri
di M0 (specifica §14.5):
1. campioni grezzi scritti **fuori dal repository**, nel formato della sonda (descrittore + corpo):
`febe-sito-di-prova campioni --cartella <cartella temporanea>`; il campione `forma-sconosciuta` è stato scritto
a mano nella stessa cartella per avere una forma che nessun lettore conosce;
2. ripulitura: `febe-sonda ripulisci --da <grezzi> --a tests/Febe.Tests/campioni/prova --sito 127.0.0.1 --cdn 127.0.0.2`;
3. verifica: `febe-sonda verifica --grezzi <grezzi> --ripuliti tests/Febe.Tests/campioni/prova` → «Verifica superata».
Per questo nomi, didascalie, identificativi, cursori e indirizzi sono valori finti della stessa forma: le prove
controllano forme, dimensioni, date e conteggi, non i valori.
| File | Che cosa contiene |
|---|---|
| `000001-inizio` | pagina iniziale: account collegato, barra delle storie, prima pagina dei post dei seguiti (serie incomplete) |
| `000002-profilo-pubblico` | profilo pubblico seguito: post fissati in cima, raccolte, prima pagina della griglia |
| `000003-profilo-pagina-successiva` | pagina successiva della griglia (scorrimento) |
| `000004-profilo-privato-non-seguito` | profilo privato non seguito: stato, nessun contenuto |
| `000005-post-serie` | post singolo con tre file (foto, video con e senza audio, foto) |
| `000006-storie` | elenco completo delle storie di un account, con un video |
| `000007-raccolta` | raccolta in evidenza con i suoi contenuti |
| `000008-seguiti` | prima pagina dell'elenco dei seguiti |
| `000009-taggati` | scheda «Taggati» di un profilo |
| `000010-pagina-vuota` | pagina di dati vuota |
| `000011-forma-sconosciuta` | risposta di forma sconosciuta |