< Summary

Information
Class: Chronicis.Api.Services.Auth0HealthCheckService
Assembly: Chronicis.Api
File(s): /home/runner/work/chronicis/chronicis/src/Chronicis.Api/Services/Auth0HealthCheckService.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 15
Coverable lines: 15
Total lines: 48
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
PerformHealthCheckAsync()0%2040%

File(s)

/home/runner/work/chronicis/chronicis/src/Chronicis.Api/Services/Auth0HealthCheckService.cs

#LineLine coverage
 1using Chronicis.Shared.DTOs;
 2
 3namespace Chronicis.Api.Services;
 4
 5public class Auth0HealthCheckService : HealthCheckServiceBase
 6{
 7    private readonly HttpClient _httpClient;
 8    private readonly IConfiguration _configuration;
 9
 10    public Auth0HealthCheckService(
 11        HttpClient httpClient,
 12        IConfiguration configuration,
 13        ILogger<Auth0HealthCheckService> logger)
 014        : base(logger)
 15    {
 016        _httpClient = httpClient;
 017        _configuration = configuration;
 018    }
 19
 20    protected override async Task<(string Status, string? Message)> PerformHealthCheckAsync()
 21    {
 022        var domain = _configuration["Auth0:Domain"];
 23
 024        if (string.IsNullOrEmpty(domain))
 25        {
 026            return (HealthStatus.Unhealthy, "Auth0 domain not configured");
 27        }
 28
 29        try
 30        {
 031            var wellKnownUrl = $"https://{domain}/.well-known/openid-configuration";
 032            var response = await _httpClient.GetAsync(wellKnownUrl);
 33
 034            if (response.IsSuccessStatusCode)
 35            {
 036                return (HealthStatus.Healthy, "Auth0 well-known endpoint accessible");
 37            }
 38            else
 39            {
 040                return (HealthStatus.Degraded, $"Auth0 returned {response.StatusCode}");
 41            }
 42        }
 043        catch (Exception ex)
 44        {
 045            return (HealthStatus.Unhealthy, $"Auth0 connectivity error: {ex.Message}");
 46        }
 047    }
 48}