Path: redb-identity/tests/redb.Identity.Tests/Routes/MeMfaProcessorTests.cs
Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity
Page: https://redbase.app/src/dev-2026-12-06/redb-identity/tests/redb.Identity.Tests/Routes/MeMfaProcessorTests.cs
----
using AwesomeAssertions;
using redb.Identity.Core.Routes.Processors;
using redb.Route.Core;
using Xunit;
namespace redb.Identity.Tests.Routes;
///
/// H3 (v1.0 DoD ยง6) unit tests for . Covers the
/// caller-id precondition paths which reject before the
/// scope is created, so no DI wiring is required.
/// Happy-path setup/confirm/disable/regenerate flows live in the integration suite
/// where a real is wired.
///
public sealed class MeMfaProcessorTests
{
private static Exchange BuildExchange(long? userId, string operation)
{
var ex = new Exchange(new Message { Body = new Dictionary() });
ex.In.Headers["operation"] = operation;
if (userId is not null)
ex.Properties["identity:management-user-id"] = userId.Value;
return ex;
}
[Fact]
public async Task MissingSubject_Returns401()
{
var sut = new MeMfaProcessor(sp: null!);
var ex = BuildExchange(userId: null, operation: "status");
await sut.Process(ex);
ex.HasOut.Should().BeTrue();
ex.Out!.Headers["redbHttp.ResponseCode"].Should().Be(401);
ex.IsStopped.Should().BeTrue();
var body = (Dictionary)ex.Out.Body!;
body["error"].Should().Be("invalid_token");
}
[Fact]
public async Task NonPositiveSubject_Returns401()
{
var sut = new MeMfaProcessor(sp: null!);
var ex = BuildExchange(userId: 0, operation: "setup");
await sut.Process(ex);
ex.Out!.Headers["redbHttp.ResponseCode"].Should().Be(401);
}
}