Table of Contents

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

path string

The 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

unhealthyCheckTag string

The tag applied to a check that always reports unhealthy.

readyStatusCode HttpStatusCode

The expected /health/ready status code.

auditIntegrityStatusCode HttpStatusCode

The expected /health/audit-integrity status code.

Returns

Task

A task that represents the asynchronous test operation.