feat(managementservice): MgmtDeployArea — Deployer-only, scoped by the area's owning site (fail-closed on an unknown area), long-running like MgmtDeploySite (Gitea #40)

This commit is contained in:
Joseph Doherty
2026-10-22 14:10:53 -04:00
parent eb1c9ea7f9
commit f72c72c52f
7 changed files with 154 additions and 5 deletions
@@ -48,6 +48,25 @@ public class ManagementEndpointsTests
Assert.Equal(expectedForce, command.Force);
}
/// <summary>
/// <c>MgmtDeployArea</c> (Gitea #40) parses with the same safe <c>Force</c>
/// default as the site deploy: absent means skip unchanged instances.
/// </summary>
/// <param name="json">The management request body to parse.</param>
/// <param name="expectedForce">The expected value of the command's <c>Force</c> flag.</param>
[Theory]
[InlineData("""{ "command": "MgmtDeployArea", "payload": { "areaId": 12 } }""", false)]
[InlineData("""{ "command": "MgmtDeployArea", "payload": { "areaId": 12, "force": true } }""", true)]
public void ParseCommand_DeployArea_ForceDefaultsToTheNonDestructiveBehaviour(string json, bool expectedForce)
{
var result = ManagementEndpoints.ParseCommand(json);
Assert.True(result.Success);
var command = Assert.IsType<MgmtDeployAreaCommand>(result.Command);
Assert.Equal(12, command.AreaId);
Assert.Equal(expectedForce, command.Force);
}
/// <summary>Verifies that parsing a request with no payload deserializes a parameterless command.</summary>
[Fact]
public void ParseCommand_WithMissingPayload_DeserializesParameterlessCommand()
@@ -168,4 +187,16 @@ public class ManagementEndpointsTests
var options = new ManagementServiceOptions { LongRunningCommandTimeout = TimeSpan.FromMinutes(2) };
Assert.Equal(TimeSpan.FromMinutes(3), ManagementEndpoints.ResolveAskTimeout(options, typeof(MgmtDeploySiteCommand)));
}
/// <summary>
/// The area-subtree bulk deploy (Gitea #40) is a bulk deploy too: same
/// long-running deadline plus the same cleanup grace as the site deploy.
/// </summary>
[Fact]
public void BulkAsk_AreaDeploy_GetsTheSameGraceAsSiteDeploy()
{
var options = new ManagementServiceOptions { LongRunningCommandTimeout = TimeSpan.FromMinutes(2) };
Assert.Equal(TimeSpan.FromMinutes(3), ManagementEndpoints.ResolveAskTimeout(options, typeof(MgmtDeployAreaCommand)));
Assert.Equal(TimeSpan.FromMinutes(6), ManagementEndpoints.ResolveAskTimeout(null, typeof(MgmtDeployAreaCommand)));
}
}