diff --git a/tests/NATS.Client.Core.Tests/NatsConnectionTest.Auth.cs b/tests/NATS.Client.Core.Tests/NatsConnectionTest.Auth.cs index 11c6ac559..c0999db82 100644 --- a/tests/NATS.Client.Core.Tests/NatsConnectionTest.Auth.cs +++ b/tests/NATS.Client.Core.Tests/NatsConnectionTest.Auth.cs @@ -56,6 +56,23 @@ NatsOpts.Default with }), }; + yield return new object[] + { + new Auth( + "NKEY (NkeyHandler & SeedHandler takes precedence over NKey & Seed)", + "resources/configs/auth/nkey.conf", + NatsOpts.Default with + { + AuthOpts = NatsAuthOpts.Default with + { + NKeyHandler = () => new ValueTask("UALQSMXRSAA7ZXIGDDJBJ2JOYJVQIWM3LQVDM5KYIPG4EP3FAGJ47BOJ"), + NKey = "invalid nkey", + SeedHandler = () => new ValueTask("SUAAVWRZG6M5FA5VRRGWSCIHKTOJC7EWNIT4JV3FTOIPO4OBFR5WA7X5TE"), + Seed = "invalid seed", + }, + }), + }; + yield return new object[] { new Auth( @@ -83,6 +100,25 @@ NatsOpts.Default with }), }; + yield return new object[] + { + new Auth( + "USER-CREDS (JwtHandler & SeedHandler takes precedence over Jwt & Seed)", + "resources/configs/auth/operator.conf", + NatsOpts.Default with + { + AuthOpts = NatsAuthOpts.Default with + { + JwtHandler = () => new ValueTask( + "eyJ0eXAiOiJKV1QiLCJhbGciOiJlZDI1NTE5LW5rZXkifQ.eyJqdGkiOiJOVDJTRkVIN0pNSUpUTzZIQ09GNUpYRFNDUU1WRlFNV0MyWjI1TFk3QVNPTklYTjZFVlhBIiwiaWF0IjoxNjc5MTQ0MDkwLCJpc3MiOiJBREpOSlpZNUNXQlI0M0NOSzJBMjJBMkxPSkVBSzJSS1RaTk9aVE1HUEVCRk9QVE5FVFBZTUlLNSIsIm5hbWUiOiJteS11c2VyIiwic3ViIjoiVUJPWjVMUVJPTEpRRFBBQUNYSk1VRkJaS0Q0R0JaSERUTFo3TjVQS1dSWFc1S1dKM0VBMlc0UloiLCJuYXRzIjp7InB1YiI6e30sInN1YiI6e30sInN1YnMiOi0xLCJkYXRhIjotMSwicGF5bG9hZCI6LTEsInR5cGUiOiJ1c2VyIiwidmVyc2lvbiI6Mn19.ElYEknDixe9pZdl55S9PjduQhhqR1OQLglI1JO7YK7ECYb1mLUjGd8ntcR7ISS04-_yhygSDzX8OS8buBIxMDA"), + SeedHandler = () => new ValueTask( + "SUAJR32IC6D45J3URHJ5AOQZWBBO6QTID27NZQKXE3GC5U3SPFEYDJK6RQ"), + Jwt = "not a valid jwt", + Seed = "invalid nkey seed", + }, + }), + }; + yield return new object[] { new Auth( @@ -93,6 +129,17 @@ NatsOpts.Default with AuthOpts = NatsAuthOpts.Default with { CredsFile = "resources/configs/auth/user.creds", }, }), }; + + 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 = () => new ValueTask("s3cr3t"), }, + }), + }; } [Theory]