Move 50 auth/accounts/permissions/JWT/NKey test files from NATS.Server.Tests into a dedicated NATS.Server.Auth.Tests project. Update namespaces, replace private GetFreePort/ReadUntilAsync helpers with TestUtilities calls, replace Task.Delay with TaskCompletionSource in test doubles, and add InternalsVisibleTo. 690 tests pass.
29 lines
704 B
C#
29 lines
704 B
C#
using NATS.Server.Auth;
|
|
using NATS.Server.Protocol;
|
|
|
|
namespace NATS.Server.Auth.Tests;
|
|
|
|
public class ProxyAuthTests
|
|
{
|
|
[Fact]
|
|
public void Proxy_authenticator_maps_prefixed_username_to_identity()
|
|
{
|
|
var authenticator = new ProxyAuthenticator(new ProxyAuthOptions
|
|
{
|
|
Enabled = true,
|
|
UsernamePrefix = "proxy:",
|
|
Account = "A",
|
|
});
|
|
|
|
var result = authenticator.Authenticate(new ClientAuthContext
|
|
{
|
|
Opts = new ClientOptions { Username = "proxy:bob" },
|
|
Nonce = [],
|
|
});
|
|
|
|
result.ShouldNotBeNull();
|
|
result.Identity.ShouldBe("bob");
|
|
result.AccountName.ShouldBe("A");
|
|
}
|
|
}
|