-
Notifications
You must be signed in to change notification settings - Fork 798
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fail AzureKeyVaultHealthCheck if no keys, certificates or secrets con…
…figured
- Loading branch information
Showing
20 changed files
with
100 additions
and
55 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
40 changes: 40 additions & 0 deletions
40
test/HealthChecks.AzureKeyVault.Tests/Functional/AzureKeyVaultHealthCheckTests.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,40 @@ | ||
using System.Net; | ||
using Azure.Identity; | ||
|
||
namespace HealthChecks.AzureKeyVault.Tests.Functional; | ||
|
||
public class AzureKeyVaultHealthCheckTests | ||
{ | ||
// https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/issues/785 | ||
[Fact] | ||
public async Task be_unhealthy_if_keyvalue_is_not_available() | ||
{ | ||
var webHostBuilder = new WebHostBuilder() | ||
.ConfigureServices(services => | ||
{ | ||
services.AddHealthChecks() | ||
.AddAzureKeyVault( | ||
new Uri("https://www.thisisnotarealurl.com"), | ||
new DefaultAzureCredential(), | ||
setup => | ||
{ | ||
//setup | ||
// .UseKeyVaultUrl("https://www.thisisnotarealurl2.com") | ||
// .UseAzureManagedServiceIdentity(); | ||
}); | ||
}) | ||
.Configure(app => | ||
{ | ||
app.UseHealthChecks("/health", new HealthCheckOptions | ||
{ | ||
Predicate = _ => true, | ||
}); | ||
}); | ||
|
||
using var server = new TestServer(webHostBuilder); | ||
|
||
var response = await server.CreateRequest("/health").GetAsync().ConfigureAwait(false); | ||
|
||
response.StatusCode.ShouldBe(HttpStatusCode.ServiceUnavailable); | ||
} | ||
} |
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
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
Oops, something went wrong.