test(contracts): scope command-reply fixture invariants past the CLI-40/41 authenticate-user malformed-reply fixtures
The blanket loop asserted HRESULT/Statuses/ReturnValue on every command_replies fixture, but the authenticate-user.* fixtures added for the malformed-reply and credential-redaction contracts deliberately omit them (NRE on ReturnValue.DataType). Keep universal Kind/ProtocolStatus invariants for all; apply the MXAccess-detail block only to fixtures that carry it. Test-only.
This commit is contained in:
@@ -72,18 +72,33 @@ public sealed class ClientBehaviorFixtureTests
|
|||||||
|
|
||||||
foreach (JsonElement fixture in fixtures)
|
foreach (JsonElement fixture in fixtures)
|
||||||
{
|
{
|
||||||
|
string fixtureId = GetFixtureId(fixture);
|
||||||
MxCommandReply reply = ParseFixture<MxCommandReply>(
|
MxCommandReply reply = ParseFixture<MxCommandReply>(
|
||||||
fixture,
|
fixture,
|
||||||
MxCommandReply.Parser);
|
MxCommandReply.Parser);
|
||||||
|
|
||||||
|
// Universal invariants: every command-reply fixture parses to a concrete
|
||||||
|
// command kind and a concrete protocol status, regardless of what MXAccess
|
||||||
|
// reply detail (if any) it carries.
|
||||||
Assert.NotEqual(MxCommandKind.Unspecified, reply.Kind);
|
Assert.NotEqual(MxCommandKind.Unspecified, reply.Kind);
|
||||||
Assert.NotEqual(ProtocolStatusCode.Unspecified, reply.ProtocolStatus.Code);
|
Assert.NotEqual(ProtocolStatusCode.Unspecified, reply.ProtocolStatus.Code);
|
||||||
Assert.True(reply.HasHresult, $"Fixture '{GetFixtureId(fixture)}' must carry an HRESULT.");
|
|
||||||
|
// The malformed-reply and credential-redaction fixtures
|
||||||
|
// (command-reply.authenticate-user.*) deliberately omit hresult, statuses,
|
||||||
|
// and/or return_value to exercise the "absent detail" contract paths — see
|
||||||
|
// docs/ClientBehaviorFixtures.md. The strict MXAccess-reply-detail
|
||||||
|
// invariants below apply only to fixtures that carry that detail.
|
||||||
|
if (fixtureId.StartsWith("command-reply.authenticate-user.", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.True(reply.HasHresult, $"Fixture '{fixtureId}' must carry an HRESULT.");
|
||||||
Assert.NotEmpty(reply.Statuses);
|
Assert.NotEmpty(reply.Statuses);
|
||||||
Assert.NotEqual(MxDataType.Unspecified, reply.ReturnValue.DataType);
|
Assert.NotEqual(MxDataType.Unspecified, reply.ReturnValue.DataType);
|
||||||
Assert.True(
|
Assert.True(
|
||||||
reply.ReturnValue.KindCase != MxValue.KindOneofCase.None || reply.ReturnValue.IsNull,
|
reply.ReturnValue.KindCase != MxValue.KindOneofCase.None || reply.ReturnValue.IsNull,
|
||||||
$"Fixture '{GetFixtureId(fixture)}' must carry a typed value, raw value, or explicit null.");
|
$"Fixture '{fixtureId}' must carry a typed value, raw value, or explicit null.");
|
||||||
}
|
}
|
||||||
|
|
||||||
MxCommandReply failedWrite = ParseFixture<MxCommandReply>(
|
MxCommandReply failedWrite = ParseFixture<MxCommandReply>(
|
||||||
|
|||||||
Reference in New Issue
Block a user