From 34d394117ca64c4ed4b86692ee0ef0975d81d51b Mon Sep 17 00:00:00 2001 From: gsutton Date: Mon, 13 Jan 2025 16:15:12 -0600 Subject: [PATCH] Add TokenHandler tests --- .../NatsConnectionTest.Auth.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/NATS.Client.Core.Tests/NatsConnectionTest.Auth.cs b/tests/NATS.Client.Core.Tests/NatsConnectionTest.Auth.cs index 11c6ac55..383d696b 100644 --- a/tests/NATS.Client.Core.Tests/NatsConnectionTest.Auth.cs +++ b/tests/NATS.Client.Core.Tests/NatsConnectionTest.Auth.cs @@ -93,6 +93,25 @@ NatsOpts.Default with AuthOpts = NatsAuthOpts.Default with { CredsFile = "resources/configs/auth/user.creds", }, }), }; + + yield return new object[] + { + new Auth( + "TokenHandler", + "resources/configs/auth/token.conf", + NatsOpts.Default with + { + AuthOpts = NatsAuthOpts.Default with { TokenHandler = () => Task.FromResult("s3cr3t"), }, + }), + }; + + yield return new object[] + { + new Auth( + "TokenHandler takes precedence over Token", + "resources/configs/auth/token.conf", + NatsOpts.Default with { AuthOpts = NatsAuthOpts.Default with { Token = "won't be used", TokenHandler = () => Task.FromResult("s3cr3t") }, }), + }; } [Theory]