aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorfmarcac <188743521+fmarcac@users.noreply.github.com>2026-09-05 15:06:37 +0200
committerfmarcac <188743521+fmarcac@users.noreply.github.com>2026-09-05 15:06:37 +0200
commit7ce911a40145fce2600ba3ce042b82f7cb97d7f7 (patch)
tree5c5b24f8a3b7c0720d1e8d4a566d51c3154ad8d8 /tests
parente356fe9146bb4c62226e9c5108bfa9bf17171f68 (diff)
Clamp client reported ping in SyncPlay groups
Diffstat (limited to 'tests')
-rw-r--r--tests/Jellyfin.Server.Implementations.Tests/SyncPlay/WaitingGroupStateTests.cs32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/Jellyfin.Server.Implementations.Tests/SyncPlay/WaitingGroupStateTests.cs b/tests/Jellyfin.Server.Implementations.Tests/SyncPlay/WaitingGroupStateTests.cs
index 1e2467b3fc..0cccd5d4ca 100644
--- a/tests/Jellyfin.Server.Implementations.Tests/SyncPlay/WaitingGroupStateTests.cs
+++ b/tests/Jellyfin.Server.Implementations.Tests/SyncPlay/WaitingGroupStateTests.cs
@@ -53,6 +53,34 @@ public class WaitingGroupStateTests
$"expected a resume delay of at least {group.DefaultPing} ms, got {scheduledDelay.TotalMilliseconds} ms");
}
+ [Theory]
+ [InlineData(4_000_000_000L)]
+ [InlineData(1_000_000_000_000_000L)]
+ [InlineData(long.MaxValue)]
+ [InlineData(-1L)]
+ public void UpdatePing_ClientReportsAnUnusablePing_IsClampedAndCannotStallTheGroup(long reportedPing)
+ {
+ var harness = new GroupHarness();
+ var group = harness.Group;
+
+ group.UpdatePing(harness.First, reportedPing);
+
+ Assert.InRange(group.GetHighestPing(), 0, group.MaxPing);
+
+ // The reported ping is scaled into the group's resume point, so an unclamped value either
+ // pushes playback months out or overflows the arithmetic outright.
+ var state = new PlayingGroupState(NullLoggerFactory.Instance);
+ var before = DateTime.UtcNow;
+ state.HandleRequest(
+ new UnpauseGroupRequest(),
+ group,
+ GroupStateType.Paused,
+ harness.First,
+ CancellationToken.None);
+
+ Assert.InRange(group.LastActivity - before, TimeSpan.Zero, TimeSpan.FromMinutes(1));
+ }
+
private sealed class GroupHarness
{
public GroupHarness()
@@ -73,6 +101,10 @@ public class WaitingGroupStateTests
.Setup(m => m.SendSyncPlayCommand(It.IsAny<string>(), It.IsAny<SendCommand>(), It.IsAny<CancellationToken>()))
.Returns(Task.CompletedTask);
+ sessionManager
+ .Setup(m => m.SendSyncPlayGroupUpdate(It.IsAny<string>(), It.IsAny<GroupUpdate<GroupStateUpdate>>(), It.IsAny<CancellationToken>()))
+ .Returns(Task.CompletedTask);
+
Group = new SyncPlayGroup(
NullLoggerFactory.Instance,
userManager.Object,