Class HealthCheckTests
- Namespace
- ProjectTemplate.Web.Tests
- Assembly
- ProjectTemplate.Web.Tests.dll
Provides integration tests for baseline health check endpoints.
public sealed class HealthCheckTests
- Inheritance
-
HealthCheckTests
- Inherited Members
Methods
HealthAuditEndpoint_AppliesOnlyExcludedPathSecurityHeaders()
Verifies that the audit health endpoint falls under the /health security header exclusion, which keeps
only X-Content-Type-Options.
[Fact("/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/tests/ProjectTemplate.Web.Tests/HealthCheckTests.cs", 131)]
public Task HealthAuditEndpoint_AppliesOnlyExcludedPathSecurityHeaders()
Returns
- Task
A task that represents the asynchronous test operation.
HealthAuditEndpoint_WithoutAuditChecks_ReturnsHealthy()
Verifies that the audit health endpoint is mapped and reports healthy when no audit checks are registered.
[Fact("/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/tests/ProjectTemplate.Web.Tests/HealthCheckTests.cs", 111)]
public Task HealthAuditEndpoint_WithoutAuditChecks_ReturnsHealthy()
Returns
- Task
A task that represents the asynchronous test operation.
HealthEndpoint_ReturnsHealthy()
Verifies that the baseline health endpoint returns a healthy response.
[Fact("/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/tests/ProjectTemplate.Web.Tests/HealthCheckTests.cs", 20)]
public Task HealthEndpoint_ReturnsHealthy()
Returns
- Task
A task that represents the asynchronous test operation.
HealthEndpoints_ApplyOnlyNoSniffSecurityHeader(string)
Verifies that health endpoints receive only the X-Content-Type-Options security header.
[Theory("/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/tests/ProjectTemplate.Web.Tests/HealthCheckTests.cs", 79)]
[InlineData(new object?[] { "/health" })]
[InlineData(new object?[] { "/health/ready" })]
[InlineData(new object?[] { "/health/live" })]
public Task HealthEndpoints_ApplyOnlyNoSniffSecurityHeader(string path)
Parameters
pathstringThe health check path to test.
Returns
- Task
A task that represents the asynchronous test operation.
HealthLiveEndpoint_ReturnsHealthy()
Verifies that the liveness health endpoint returns a healthy response.
[Fact("/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/tests/ProjectTemplate.Web.Tests/HealthCheckTests.cs", 59)]
public Task HealthLiveEndpoint_ReturnsHealthy()
Returns
- Task
A task that represents the asynchronous test operation.
HealthReadyEndpoint_ReturnsHealthy()
Verifies that the readiness health endpoint returns a healthy response.
[Fact("/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/tests/ProjectTemplate.Web.Tests/HealthCheckTests.cs", 40)]
public Task HealthReadyEndpoint_ReturnsHealthy()
Returns
- Task
A task that represents the asynchronous test operation.
TaggedHealthEndpoints_RunOnlyChecksWithTheirTag(string, HttpStatusCode, HttpStatusCode)
Verifies that each tagged endpoint runs only checks carrying its tag, so an unhealthy check affects only the endpoint that selects it.
[Theory("/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/tests/ProjectTemplate.Web.Tests/HealthCheckTests.cs", 154)]
[InlineData(new object?[] { "ready", HttpStatusCode.ServiceUnavailable, HttpStatusCode.OK })]
[InlineData(new object?[] { "audit", HttpStatusCode.OK, HttpStatusCode.ServiceUnavailable })]
public Task TaggedHealthEndpoints_RunOnlyChecksWithTheirTag(string unhealthyCheckTag, HttpStatusCode readyStatusCode, HttpStatusCode auditIntegrityStatusCode)
Parameters
unhealthyCheckTagstringThe tag applied to a check that always reports unhealthy.
readyStatusCodeHttpStatusCodeThe expected
/health/readystatus code.auditIntegrityStatusCodeHttpStatusCodeThe expected
/health/audit-integritystatus code.
Returns
- Task
A task that represents the asynchronous test operation.