Path: redb-identity/tests/redb.Identity.Tests/Routes/MeWebAuthnProcessorTests.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/MeWebAuthnProcessorTests.cs
----
using AwesomeAssertions;
using redb.Identity.Core.Routes.Processors;
using redb.Route.Core;
using Xunit;
namespace redb.Identity.Tests.Routes;
///
/// MFA-3 unit tests for . Mirrors
/// — covers caller-id precondition paths which
/// reject before any DI scope is created, so no MfaService / IFido2 wiring is
/// required. Happy-path register/credentials/rename/delete flows live in the integration
/// suite where a real MfaService + IWebAuthnMfaMethod are wired.
///
public sealed class MeWebAuthnProcessorTests
{
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 MeWebAuthnProcessor(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 MeWebAuthnProcessor(sp: null!);
var ex = BuildExchange(userId: -3, operation: "credentials");
await sut.Process(ex);
ex.Out!.Headers["redbHttp.ResponseCode"].Should().Be(401);
}
}