diff --git a/src/http/httpClient/ContinuousAccessEvaluation.cs b/src/http/httpClient/ContinuousAccessEvaluation.cs
index 4f84066..0bc0185 100644
--- a/src/http/httpClient/ContinuousAccessEvaluation.cs
+++ b/src/http/httpClient/ContinuousAccessEvaluation.cs
@@ -24,7 +24,7 @@ static internal class ContinuousAccessEvaluation
///
public static string GetClaims(HttpResponseMessage response)
{
- if(response == null) throw new ArgumentNullException(nameof(response));
+ ArgumentNullException.ThrowIfNull(response);
if(response.StatusCode != HttpStatusCode.Unauthorized
|| response.Headers.WwwAuthenticate.Count == 0)
{
diff --git a/src/http/httpClient/HttpClientRequestAdapter.cs b/src/http/httpClient/HttpClientRequestAdapter.cs
index 8e05650..3e6f5de 100644
--- a/src/http/httpClient/HttpClientRequestAdapter.cs
+++ b/src/http/httpClient/HttpClientRequestAdapter.cs
@@ -494,7 +494,6 @@ private async Task ThrowIfFailedResponseAsync(HttpResponseMessage response, Dict
}
private const string ClaimsKey = "claims";
private const string BearerAuthenticationScheme = "Bearer";
- private static Func filterAuthHeader = static x => x.Scheme.Equals(BearerAuthenticationScheme, StringComparison.OrdinalIgnoreCase);
private async Task GetHttpResponseMessageAsync(RequestInformation requestInfo, CancellationToken cancellationToken, Activity? activityForAttributes, string? claims = default, bool isStreamResponse = false)
{
using var span = activitySource?.StartActivity(nameof(GetHttpResponseMessageAsync));
diff --git a/src/http/httpClient/Middleware/AuthorizationHandler.cs b/src/http/httpClient/Middleware/AuthorizationHandler.cs
index 27c9a96..893cec9 100644
--- a/src/http/httpClient/Middleware/AuthorizationHandler.cs
+++ b/src/http/httpClient/Middleware/AuthorizationHandler.cs
@@ -45,7 +45,7 @@ public AuthorizationHandler(BaseBearerTokenAuthenticationProvider authentication
protected override async Task SendAsync(HttpRequestMessage request,
CancellationToken cancellationToken)
{
- if(request == null) throw new ArgumentNullException(nameof(request));
+ ArgumentNullException.ThrowIfNull(request);
Activity? activity = null;
if(request.GetRequestOption() is { } obsOptions)
@@ -85,8 +85,8 @@ protected override async Task SendAsync(HttpRequestMessage
private async Task AuthenticateRequestAsync(HttpRequestMessage request,
Dictionary additionalAuthenticationContext,
- CancellationToken cancellationToken,
- Activity? activityForAttributes)
+ Activity? activityForAttributes,
+ CancellationToken cancellationToken)
{
var accessTokenProvider = authenticationProvider.AccessTokenProvider;
if(request.RequestUri == null || !accessTokenProvider.AllowedHostsValidator.IsUrlHostValid(
diff --git a/tests/http/httpClient/Middleware/AuthorizationHandlerTests.cs b/tests/http/httpClient/Middleware/AuthorizationHandlerTests.cs
index f8947f2..e4c5e8c 100644
--- a/tests/http/httpClient/Middleware/AuthorizationHandlerTests.cs
+++ b/tests/http/httpClient/Middleware/AuthorizationHandlerTests.cs
@@ -78,7 +78,7 @@ public async Task AuthorizationHandlerShouldAddAuthHeaderIfNotPresent()
// Assert
Assert.NotNull(response.RequestMessage);
Assert.True(response.RequestMessage.Headers.Contains("Authorization"));
- Assert.True(response.RequestMessage.Headers.GetValues("Authorization").Count() == 1);
+ Assert.Single(response.RequestMessage.Headers.GetValues("Authorization"));
Assert.Equal($"Bearer {_expectedAccessToken}", response.RequestMessage.Headers.GetValues("Authorization").First());
}
@@ -98,7 +98,7 @@ public async Task AuthorizationHandlerShouldNotAddAuthHeaderIfPresent()
// Assert
Assert.NotNull(response.RequestMessage);
Assert.True(response.RequestMessage.Headers.Contains("Authorization"));
- Assert.True(response.RequestMessage.Headers.GetValues("Authorization").Count() == 1);
+ Assert.Single(response.RequestMessage.Headers.GetValues("Authorization"));
Assert.Equal($"Bearer existing", response.RequestMessage.Headers.GetValues("Authorization").First());
}
@@ -138,7 +138,7 @@ public async Task AuthorizationHandlerShouldAttemptCAEClaimsChallenge()
// Assert
Assert.NotNull(response.RequestMessage);
Assert.True(response.RequestMessage.Headers.Contains("Authorization"));
- Assert.True(response.RequestMessage.Headers.GetValues("Authorization").Count() == 1);
+ Assert.Single(response.RequestMessage.Headers.GetValues("Authorization"));
Assert.Equal($"Bearer {_expectedAccessTokenAfterCAE}", response.RequestMessage.Headers.GetValues("Authorization").First());
Assert.Equal("test", await response.RequestMessage.Content!.ReadAsStringAsync());
}