31 lines
748 B
C#
31 lines
748 B
C#
using NATS.Server.Auth;
|
|
using NATS.Server.Protocol;
|
|
|
|
namespace NATS.Server.Tests;
|
|
|
|
public class AuthExtensionParityTests
|
|
{
|
|
[Fact]
|
|
public void Auth_service_uses_proxy_auth_extension_when_enabled()
|
|
{
|
|
var service = AuthService.Build(new NatsOptions
|
|
{
|
|
ProxyAuth = new ProxyAuthOptions
|
|
{
|
|
Enabled = true,
|
|
UsernamePrefix = "proxy:",
|
|
},
|
|
});
|
|
|
|
service.IsAuthRequired.ShouldBeTrue();
|
|
var result = service.Authenticate(new ClientAuthContext
|
|
{
|
|
Opts = new ClientOptions { Username = "proxy:alice" },
|
|
Nonce = [],
|
|
});
|
|
|
|
result.ShouldNotBeNull();
|
|
result.Identity.ShouldBe("alice");
|
|
}
|
|
}
|