fix(card-master): wire EnableServing kill switch in controller + add to config-section test
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
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.Responses.ImmutableData;
|
||||
using SVSim.EmulatedEntrypoint.Services;
|
||||
@@ -13,10 +15,12 @@ namespace SVSim.EmulatedEntrypoint.Controllers;
|
||||
public class ImmutableDataController : SVSimController
|
||||
{
|
||||
private readonly ICardMasterPayloadProvider _provider;
|
||||
private readonly IGameConfigService _config;
|
||||
|
||||
public ImmutableDataController(ICardMasterPayloadProvider provider)
|
||||
public ImmutableDataController(ICardMasterPayloadProvider provider, IGameConfigService config)
|
||||
{
|
||||
_provider = provider;
|
||||
_config = config;
|
||||
}
|
||||
|
||||
/// <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.
|
||||
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 });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,13 +25,14 @@ public class GameConfigurationJsonbTests
|
||||
var rows = await db.GameConfigs.AsNoTracking().ToListAsync();
|
||||
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,
|
||||
// Freeplay, ArenaTwoPick, Matching).
|
||||
// Freeplay, ArenaTwoPick, Matching, CardMasterConfig).
|
||||
Assert.That(byName.Keys, Is.EquivalentTo(new[]
|
||||
{
|
||||
"Player", "DefaultGrants", "DefaultLoadout", "Challenge", "Rotation", "PackRates",
|
||||
"MyRotationSchedule", "Story", "ResourceConfig", "Freeplay", "ArenaTwoPick", "Matching",
|
||||
"CardMasterConfig",
|
||||
}));
|
||||
|
||||
var resources = JsonSerializer.Deserialize<ResourceConfig>(byName["ResourceConfig"].ValueJson)!;
|
||||
|
||||
Reference in New Issue
Block a user