Skip to content

Commit

Permalink
Add Handler tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gsutton authored and garrett-sutton committed Jan 14, 2025
1 parent 1f90be9 commit 0bdb854
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tests/NATS.Client.Core.Tests/NatsConnectionTest.Auth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>("UALQSMXRSAA7ZXIGDDJBJ2JOYJVQIWM3LQVDM5KYIPG4EP3FAGJ47BOJ"),
NKey = "invalid nkey",
SeedHandler = () => new ValueTask<string>("SUAAVWRZG6M5FA5VRRGWSCIHKTOJC7EWNIT4JV3FTOIPO4OBFR5WA7X5TE"),
Seed = "invalid seed",
},
}),
};

yield return new object[]
{
new Auth(
Expand Down Expand Up @@ -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<string>(
"eyJ0eXAiOiJKV1QiLCJhbGciOiJlZDI1NTE5LW5rZXkifQ.eyJqdGkiOiJOVDJTRkVIN0pNSUpUTzZIQ09GNUpYRFNDUU1WRlFNV0MyWjI1TFk3QVNPTklYTjZFVlhBIiwiaWF0IjoxNjc5MTQ0MDkwLCJpc3MiOiJBREpOSlpZNUNXQlI0M0NOSzJBMjJBMkxPSkVBSzJSS1RaTk9aVE1HUEVCRk9QVE5FVFBZTUlLNSIsIm5hbWUiOiJteS11c2VyIiwic3ViIjoiVUJPWjVMUVJPTEpRRFBBQUNYSk1VRkJaS0Q0R0JaSERUTFo3TjVQS1dSWFc1S1dKM0VBMlc0UloiLCJuYXRzIjp7InB1YiI6e30sInN1YiI6e30sInN1YnMiOi0xLCJkYXRhIjotMSwicGF5bG9hZCI6LTEsInR5cGUiOiJ1c2VyIiwidmVyc2lvbiI6Mn19.ElYEknDixe9pZdl55S9PjduQhhqR1OQLglI1JO7YK7ECYb1mLUjGd8ntcR7ISS04-_yhygSDzX8OS8buBIxMDA"),
SeedHandler = () => new ValueTask<string>(
"SUAJR32IC6D45J3URHJ5AOQZWBBO6QTID27NZQKXE3GC5U3SPFEYDJK6RQ"),
Jwt = "not a valid jwt",
Seed = "invalid nkey seed",
},
}),
};

yield return new object[]
{
new Auth(
Expand All @@ -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<string>("s3cr3t"), },
}),
};
}

[Theory]
Expand Down

0 comments on commit 0bdb854

Please sign in to comment.