-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Extensions] Fix ASP.NET Core integration testing (#48426)
* [Extensions] Fix ASP.NET Core integration testing The focus of these changes is to fix an assumption in the logic when creating clients from configuration. Currently, if the configuration section has a non-null value, it is assumed to be a connection string. This is not the case for ASP.NET Core test integration due to a bug in the test host which causes the Value property to return an empty string rather than the null returned by the actual configuration system.
- Loading branch information
Showing
8 changed files
with
124 additions
and
9 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
32 changes: 32 additions & 0 deletions
32
sdk/extensions/Microsoft.Extensions.Azure/tests/aspnet-host/AspNetHost.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,32 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#if NET8_0_OR_GREATER | ||
|
||
using Azure.Security.KeyVault.Secrets; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.Extensions.Azure; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace Azure.Core.Extensions.Tests; | ||
|
||
public class AspNetHost | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
var builder = WebApplication.CreateBuilder(args); | ||
builder.Environment.ContentRootPath = "aspnet-host"; | ||
|
||
builder.Services.AddAzureClients(clientBuilder => | ||
{ | ||
clientBuilder.AddSecretClient(builder.Configuration.GetSection("KeyVault")); | ||
}); | ||
|
||
var app = builder.Build(); | ||
var secretClient = app.Services.GetRequiredService<SecretClient>(); | ||
|
||
app.MapGet("/keyvault", () => secretClient.VaultUri.AbsoluteUri); | ||
app.Run(); | ||
} | ||
} | ||
#endif |
Empty file.
12 changes: 12 additions & 0 deletions
12
sdk/extensions/Microsoft.Extensions.Azure/tests/aspnet-host/appsettings.json
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,12 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
}, | ||
"AllowedHosts": "*", | ||
"KeyVault": { | ||
"VaultUri": "<vault_uri>" | ||
} | ||
} |