fix: cap automatic playout refreshes

This commit is contained in:
2026-07-12 19:28:15 +09:00
parent 6e00955f1b
commit df60e09884
16 changed files with 603 additions and 37 deletions

View File

@@ -29,6 +29,7 @@ public sealed class PlayoutOptionsLoaderTests
"MBN_STOCK_PLAYOUT_RECONNECT_DELAY_MS",
"MBN_STOCK_PLAYOUT_MAXIMUM_RECONNECT_ATTEMPTS",
"MBN_STOCK_PLAYOUT_RECONNECT_ENABLED",
"MBN_STOCK_PLAYOUT_MAXIMUM_AUTOMATIC_REFRESHES_PER_TAKE_IN",
PlayoutOptionsLoader.LiveAuthorizationEnvironmentVariable,
"MBN_STOCK_PLAYOUT_TEST_SCENE_ALLOWLIST",
"MBN_STOCK_PLAYOUT_TRUSTED_LIVE_OUTPUT_ENABLED"
@@ -58,6 +59,7 @@ public sealed class PlayoutOptionsLoaderTests
Assert.Empty(options.TestSceneAllowlist);
Assert.False(options.TrustedLiveOutputEnabled);
Assert.True(options.ReconnectEnabled);
Assert.Null(options.MaximumAutomaticRefreshesPerTakeIn);
}
[Fact]
@@ -87,6 +89,7 @@ public sealed class PlayoutOptionsLoaderTests
.Set("MBN_STOCK_PLAYOUT_RECONNECT_DELAY_MS", "1505")
.Set("MBN_STOCK_PLAYOUT_MAXIMUM_RECONNECT_ATTEMPTS", "4")
.Set("MBN_STOCK_PLAYOUT_RECONNECT_ENABLED", "false")
.Set("MBN_STOCK_PLAYOUT_MAXIMUM_AUTOMATIC_REFRESHES_PER_TAKE_IN", "999")
.Set("MBN_STOCK_PLAYOUT_TEST_SCENE_ALLOWLIST", "C:\\env\\must-not-apply.t2s")
.Set("MBN_STOCK_PLAYOUT_TRUSTED_LIVE_OUTPUT_ENABLED", "false");
using var file = TemporaryJsonFile.Create(
@@ -110,7 +113,8 @@ public sealed class PlayoutOptionsLoaderTests
"processPollIntervalMilliseconds": 1000,
"reconnectDelayMilliseconds": 1000,
"maximumReconnectAttempts": 3,
"reconnectEnabled": true
"reconnectEnabled": true,
"maximumAutomaticRefreshesPerTakeIn": 1
}
""");
@@ -139,6 +143,7 @@ public sealed class PlayoutOptionsLoaderTests
Assert.Equal(1505, options.ReconnectDelayMilliseconds);
Assert.Equal(4, options.MaximumReconnectAttempts);
Assert.False(options.ReconnectEnabled);
Assert.Equal(1, options.MaximumAutomaticRefreshesPerTakeIn);
Assert.Equal(["C:\\test-scenes\\allowed.t2s"], options.TestSceneAllowlist);
Assert.True(options.TrustedLiveOutputEnabled);
}
@@ -177,6 +182,24 @@ public sealed class PlayoutOptionsLoaderTests
Assert.DoesNotContain("invalid-json", exception.Message, StringComparison.OrdinalIgnoreCase);
}
[Fact]
public void Load_StringAutomaticRefreshMaximumFailsClosed()
{
using var environment = ClearedEnvironment();
using var file = TemporaryJsonFile.Create(
"""
{
"maximumAutomaticRefreshesPerTakeIn": "1"
}
""");
var exception = Assert.Throws<PlayoutConfigurationException>(
() => PlayoutOptionsLoader.Load(file.Path));
Assert.DoesNotContain(file.Path, exception.Message, StringComparison.OrdinalIgnoreCase);
Assert.DoesNotContain("\"1\"", exception.Message, StringComparison.Ordinal);
}
[Theory]
[InlineData("MBN_STOCK_PLAYOUT_MODE", "not-a-mode")]
[InlineData("MBN_STOCK_PLAYOUT_LEGACY_BACKGROUND_KIND", "not-a-background")]