< Summary - Heimdall API

Information
Class: ArturRios.Heimdall.WebApi.Security.GoogleSignInOptions
Assembly: ArturRios.Heimdall.WebApi
File(s): /home/runner/work/heimdall-api/heimdall-api/src/Presentation/ArturRios.Heimdall.WebApi/Security/GoogleSignInOptions.cs
Line coverage
90%
Covered lines: 10
Uncovered lines: 1
Coverable lines: 11
Total lines: 43
Line coverage: 90.9%
Branch coverage
50%
Covered branches: 2
Total branches: 4
Branch coverage: 50%
Method coverage
80%
Covered methods: 4
Fully covered methods: 4
Total methods: 5
Method coverage: 80%
Full method coverage: 80%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_ClientIds()100%11100%
get_TestSigningSecret()100%11100%
get_GoogleConfigured()100%210%
get_TestSigningConfigured()100%11100%
FromEnvironment()50%44100%

File(s)

/home/runner/work/heimdall-api/heimdall-api/src/Presentation/ArturRios.Heimdall.WebApi/Security/GoogleSignInOptions.cs

#LineLine coverage
 1namespace ArturRios.Heimdall.WebApi.Security;
 2
 3/// <summary>
 4///     Settings for UC-25's Google ID token verification. Decides, at start-up, which
 5///     <see cref="ArturRios.Heimdall.Command.Services.IGoogleIdTokenVerifier" /> the API runs
 6///     with — the same arrangement <c>EmailDeliveryOptions</c> uses to choose between real and logged
 7///     email delivery.
 8/// </summary>
 9public class GoogleSignInOptions
 10{
 11    /// <summary>
 12    ///     Comma-separated OAuth client IDs accepted as the ID token's audience (NFR-13). Google
 13    ///     issues one token per client, so a deployment serving several front-ends lists them all.
 14    /// </summary>
 15    public const string ClientIdsVariable = "HEIMDALL_GOOGLE_CLIENT_IDS";
 16
 17    /// <summary>
 18    ///     Signing secret for locally minted ID tokens, used **only** by the functional test suite —
 19    ///     see <see cref="LocalGoogleIdTokenVerifier" /> for why it exists and what stops it reaching
 20    ///     production. Unset everywhere except <c>PostgresFixture</c>.
 21    /// </summary>
 22    public const string TestSigningSecretVariable = "HEIMDALL_GOOGLE_TEST_SIGNING_SECRET";
 23
 24    /// <summary>The accepted audiences. Empty when the deployment has no Google client configured.</summary>
 182425    public IReadOnlyList<string> ClientIds { get; init; } = [];
 26
 27    /// <summary>The test signing secret, or empty — which is the normal case.</summary>
 276528    public string TestSigningSecret { get; init; } = string.Empty;
 29
 30    /// <summary>Whether a real Google client is configured, so tokens can be verified against Google.</summary>
 031    public bool GoogleConfigured => ClientIds.Count > 0;
 32
 33    /// <summary>Whether the locally signed tokens of the functional suite are in play.</summary>
 89934    public bool TestSigningConfigured => !string.IsNullOrWhiteSpace(TestSigningSecret);
 35
 89936    public static GoogleSignInOptions FromEnvironment() => new()
 89937    {
 89938        ClientIds = (Environment.GetEnvironmentVariable(ClientIdsVariable) ?? string.Empty)
 89939            .Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries),
 89940        TestSigningSecret =
 89941            Environment.GetEnvironmentVariable(TestSigningSecretVariable) ?? string.Empty
 89942    };
 43}