-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: Add Auth configuration tests (#76)
- Loading branch information
1 parent
b52e8f4
commit 7aafd05
Showing
11 changed files
with
215 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
tests/Keycloak.AuthServices.IntegrationTests/ConfigurationTests/AssertionsUtils.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
namespace Keycloak.AuthServices.IntegrationTests.ConfigurationTests; | ||
|
||
using Microsoft.AspNetCore.Authentication.JwtBearer; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Options; | ||
|
||
public static class AssertionsUtils | ||
{ | ||
public static void EnsureConfiguredJwtOptions( | ||
this IServiceProvider serviceProvider, | ||
JwtBearerOptions? expected | ||
) | ||
{ | ||
var bearerOptionsMonitor = serviceProvider.GetService<IOptionsMonitor<JwtBearerOptions>>(); | ||
EnsureMatchingJwtOptions( | ||
bearerOptionsMonitor?.Get(JwtBearerDefaults.AuthenticationScheme), | ||
expected | ||
); | ||
} | ||
|
||
public static void EnsureMatchingJwtOptions( | ||
JwtBearerOptions? source, | ||
JwtBearerOptions? expected | ||
) | ||
{ | ||
source | ||
.Should() | ||
.BeEquivalentTo( | ||
expected, | ||
cfg => | ||
cfg.Including(f => f!.Audience) | ||
.Including(f => f!.Authority) | ||
.Including(f => f!.RequireHttpsMetadata) | ||
.Including(f => f!.TokenValidationParameters.ValidateAudience) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.