fix(card-master): wire EnableServing kill switch in controller + add to config-section test

This commit is contained in:
gamer147
2026-06-12 12:52:06 -04:00
parent b4a279ef0c
commit d0d6a6916c
2 changed files with 13 additions and 3 deletions

View File

@@ -1,4 +1,6 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using SVSim.Database.Models.Config;
using SVSim.Database.Services;
using SVSim.EmulatedEntrypoint.Models.Dtos.Requests.ImmutableData; using SVSim.EmulatedEntrypoint.Models.Dtos.Requests.ImmutableData;
using SVSim.EmulatedEntrypoint.Models.Dtos.Responses.ImmutableData; using SVSim.EmulatedEntrypoint.Models.Dtos.Responses.ImmutableData;
using SVSim.EmulatedEntrypoint.Services; using SVSim.EmulatedEntrypoint.Services;
@@ -13,10 +15,12 @@ namespace SVSim.EmulatedEntrypoint.Controllers;
public class ImmutableDataController : SVSimController public class ImmutableDataController : SVSimController
{ {
private readonly ICardMasterPayloadProvider _provider; private readonly ICardMasterPayloadProvider _provider;
private readonly IGameConfigService _config;
public ImmutableDataController(ICardMasterPayloadProvider provider) public ImmutableDataController(ICardMasterPayloadProvider provider, IGameConfigService config)
{ {
_provider = provider; _provider = provider;
_config = config;
} }
/// <summary> /// <summary>
@@ -32,6 +36,11 @@ public class ImmutableDataController : SVSimController
// 500 not 503: blob missing is operator error (config / build), not transient — no retry will help. // 500 not 503: blob missing is operator error (config / build), not transient — no retry will help.
return StatusCode(500, "card-master payload not available"); return StatusCode(500, "card-master payload not available");
} }
if (!_config.Get<CardMasterConfig>().EnableServing)
{
// 503: explicit operator kill switch — temporarily disabled, distinct from 500 (misconfig).
return StatusCode(503, "card-master serving disabled");
}
return Ok(new CardMasterResponse { CardMaster = _provider.Base64Blob }); return Ok(new CardMasterResponse { CardMaster = _provider.Base64Blob });
} }
} }

View File

@@ -25,13 +25,14 @@ public class GameConfigurationJsonbTests
var rows = await db.GameConfigs.AsNoTracking().ToListAsync(); var rows = await db.GameConfigs.AsNoTracking().ToListAsync();
var byName = rows.ToDictionary(r => r.SectionName); var byName = rows.ToDictionary(r => r.SectionName);
// One row per [ConfigSection]-marked POCO (12 sections today: Player, DefaultGrants, // One row per [ConfigSection]-marked POCO (13 sections today: Player, DefaultGrants,
// DefaultLoadout, Challenge, Rotation, PackRates, MyRotationSchedule, Story, ResourceConfig, // DefaultLoadout, Challenge, Rotation, PackRates, MyRotationSchedule, Story, ResourceConfig,
// Freeplay, ArenaTwoPick, Matching). // Freeplay, ArenaTwoPick, Matching, CardMasterConfig).
Assert.That(byName.Keys, Is.EquivalentTo(new[] Assert.That(byName.Keys, Is.EquivalentTo(new[]
{ {
"Player", "DefaultGrants", "DefaultLoadout", "Challenge", "Rotation", "PackRates", "Player", "DefaultGrants", "DefaultLoadout", "Challenge", "Rotation", "PackRates",
"MyRotationSchedule", "Story", "ResourceConfig", "Freeplay", "ArenaTwoPick", "Matching", "MyRotationSchedule", "Story", "ResourceConfig", "Freeplay", "ArenaTwoPick", "Matching",
"CardMasterConfig",
})); }));
var resources = JsonSerializer.Deserialize<ResourceConfig>(byName["ResourceConfig"].ValueJson)!; var resources = JsonSerializer.Deserialize<ResourceConfig>(byName["ResourceConfig"].ValueJson)!;