< Summary - Envilder .NET SDK

Information
Class: Envilder.Infrastructure.Aws.ExpiredCredentialsDetector
Assembly: Envilder
File(s): /home/runner/work/envilder/envilder/src/sdks/dotnet/Infrastructure/Aws/ExpiredCredentialsDetector.cs
Tag: 427_29134414720
Line coverage
94%
Covered lines: 16
Uncovered lines: 1
Coverable lines: 17
Total lines: 39
Line coverage: 94.1%
Branch coverage
90%
Covered branches: 9
Total branches: 10
Branch coverage: 90%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%
IsExpiredCredentials(...)90%101087.5%

File(s)

/home/runner/work/envilder/envilder/src/sdks/dotnet/Infrastructure/Aws/ExpiredCredentialsDetector.cs

#LineLine coverage
 1namespace Envilder.Infrastructure.Aws;
 2
 3using Amazon.Runtime;
 4using System;
 5using System.Collections.Generic;
 6
 7internal static class ExpiredCredentialsDetector
 8{
 19  private static readonly HashSet<string> ExpiredErrorCodes = new(StringComparer.OrdinalIgnoreCase)
 110  {
 111    "ExpiredTokenException",
 112    "ExpiredToken",
 113  };
 14
 115  private static readonly HashSet<string> ExpiredExceptionTypeNames = new(StringComparer.OrdinalIgnoreCase)
 116  {
 117    "ExpiredTokenException",
 118  };
 19
 20  public static bool IsExpiredCredentials(Exception? exception)
 21  {
 122    for (var current = exception; current is not null; current = current.InnerException)
 23    {
 124      if (ExpiredExceptionTypeNames.Contains(current.GetType().Name))
 25      {
 026        return true;
 27      }
 28
 129      if (current is AmazonServiceException serviceException
 130        && serviceException.ErrorCode is not null
 131        && ExpiredErrorCodes.Contains(serviceException.ErrorCode))
 32      {
 133        return true;
 34      }
 35    }
 36
 137    return false;
 38  }
 39}