diff --git a/.autover/changes/32ed76f9-11d9-41f0-afbe-6577cc63554e.json b/.autover/changes/32ed76f9-11d9-41f0-afbe-6577cc63554e.json new file mode 100644 index 00000000..54d48402 --- /dev/null +++ b/.autover/changes/32ed76f9-11d9-41f0-afbe-6577cc63554e.json @@ -0,0 +1,11 @@ +{ + "Projects": [ + { + "Name": "AWS.Messaging.Lambda", + "Type": "Patch", + "ChangelogMessages": [ + "Update AWS SDK Dependencies" + ] + } + ] +} \ No newline at end of file diff --git a/.autover/changes/ff1384b4-5921-45cc-9596-0620d31d1375.json b/.autover/changes/ff1384b4-5921-45cc-9596-0620d31d1375.json new file mode 100644 index 00000000..e26c7068 --- /dev/null +++ b/.autover/changes/ff1384b4-5921-45cc-9596-0620d31d1375.json @@ -0,0 +1,11 @@ +{ + "Projects": [ + { + "Name": "AWS.Messaging", + "Type": "Patch", + "ChangelogMessages": [ + "Update AWS SDK Dependencies" + ] + } + ] +} \ No newline at end of file diff --git a/src/AWS.Messaging.Lambda/AWS.Messaging.Lambda.csproj b/src/AWS.Messaging.Lambda/AWS.Messaging.Lambda.csproj index e12b9648..e7045648 100644 --- a/src/AWS.Messaging.Lambda/AWS.Messaging.Lambda.csproj +++ b/src/AWS.Messaging.Lambda/AWS.Messaging.Lambda.csproj @@ -25,7 +25,7 @@ - + diff --git a/src/AWS.Messaging/AWS.Messaging.csproj b/src/AWS.Messaging/AWS.Messaging.csproj index 8694721c..7b223a49 100644 --- a/src/AWS.Messaging/AWS.Messaging.csproj +++ b/src/AWS.Messaging/AWS.Messaging.csproj @@ -27,10 +27,10 @@ - - - - + + + + diff --git a/src/AWS.Messaging/Configuration/AWSClientProvider.cs b/src/AWS.Messaging/Configuration/AWSClientProvider.cs index 372cf784..fbc5e2ef 100644 --- a/src/AWS.Messaging/Configuration/AWSClientProvider.cs +++ b/src/AWS.Messaging/Configuration/AWSClientProvider.cs @@ -11,7 +11,6 @@ namespace AWS.Messaging.Configuration; /// internal class AWSClientProvider : IAWSClientProvider { - private const string _userAgentHeader = "User-Agent"; private static readonly string _userAgentString = $"lib/aws-dotnet-messaging#{TelemetryKeys.AWSMessagingAssemblyVersion}"; private readonly IServiceProvider _serviceProvider; @@ -37,9 +36,10 @@ public T GetServiceClient() where T : IAmazonService internal static void AWSServiceClient_BeforeServiceRequest(object sender, RequestEventArgs e) { - if (e is not WebServiceRequestEventArgs args || !args.Headers.TryGetValue(_userAgentHeader, out var value) || value.Contains(_userAgentString)) - return; - - args.Headers[_userAgentHeader] = value + " " + _userAgentString; + WebServiceRequestEventArgs? args = e as WebServiceRequestEventArgs; + if (args != null && args.Request is Amazon.Runtime.Internal.IAmazonWebServiceRequest internalRequest && !internalRequest.UserAgentDetails.GetCustomUserAgentComponents().Contains(_userAgentString)) + { + internalRequest.UserAgentDetails.AddUserAgentComponent(_userAgentString); + } } } diff --git a/test/AWS.Messaging.IntegrationTests/AWS.Messaging.IntegrationTests.csproj b/test/AWS.Messaging.IntegrationTests/AWS.Messaging.IntegrationTests.csproj index 5319cf3d..56b5cdfb 100644 --- a/test/AWS.Messaging.IntegrationTests/AWS.Messaging.IntegrationTests.csproj +++ b/test/AWS.Messaging.IntegrationTests/AWS.Messaging.IntegrationTests.csproj @@ -9,18 +9,18 @@ - - - - - + + + + + - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -28,7 +28,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + diff --git a/test/AWS.Messaging.IntegrationTests/SubscriberTests.cs b/test/AWS.Messaging.IntegrationTests/SubscriberTests.cs index bf007c00..cce29c3a 100644 --- a/test/AWS.Messaging.IntegrationTests/SubscriberTests.cs +++ b/test/AWS.Messaging.IntegrationTests/SubscriberTests.cs @@ -134,7 +134,7 @@ await publisher.PublishAsync(new ChatMessage var inMemoryLogger = serviceProvider.GetRequiredService(); var tempStorage = serviceProvider.GetRequiredService>(); - Assert.Empty(inMemoryLogger.Logs.Where(x => x.Exception is AmazonSQSException ex && ex.ErrorCode.Equals("AWS.SimpleQueueService.TooManyEntriesInBatchRequest"))); + Assert.DoesNotContain(inMemoryLogger.Logs, (x => x.Exception is AmazonSQSException ex && ex.ErrorCode.Equals("AWS.SimpleQueueService.TooManyEntriesInBatchRequest"))); Assert.Equal(numberOfMessages, tempStorage.Messages.Count); for (int i = 0; i < numberOfMessages; i++) { @@ -216,7 +216,8 @@ await publisher.PublishAsync(new ChatMessage var inMemoryLogger = serviceProvider.GetRequiredService(); - Assert.Empty(inMemoryLogger.Logs.Where(x => x.Exception is AmazonSQSException ex && ex.ErrorCode.Equals("AWS.SimpleQueueService.TooManyEntriesInBatchRequest"))); + Assert.DoesNotContain(inMemoryLogger.Logs, (x => x.Exception is AmazonSQSException ex && ex.ErrorCode.Equals("AWS.SimpleQueueService.TooManyEntriesInBatchRequest"))); + Assert.Equal(5, tempStorage.Messages.Count); for (int i = 0; i < 5; i++) { diff --git a/test/AWS.Messaging.Tests.Common/AWS.Messaging.Tests.Common.csproj b/test/AWS.Messaging.Tests.Common/AWS.Messaging.Tests.Common.csproj index dbf028f0..ce9168c2 100644 --- a/test/AWS.Messaging.Tests.Common/AWS.Messaging.Tests.Common.csproj +++ b/test/AWS.Messaging.Tests.Common/AWS.Messaging.Tests.Common.csproj @@ -9,12 +9,12 @@ - - - - - - + + + + + + diff --git a/test/AWS.Messaging.Tests.LambdaFunctions/AWS.Messaging.Tests.LambdaFunctions.csproj b/test/AWS.Messaging.Tests.LambdaFunctions/AWS.Messaging.Tests.LambdaFunctions.csproj index a1a57fab..99309500 100644 --- a/test/AWS.Messaging.Tests.LambdaFunctions/AWS.Messaging.Tests.LambdaFunctions.csproj +++ b/test/AWS.Messaging.Tests.LambdaFunctions/AWS.Messaging.Tests.LambdaFunctions.csproj @@ -11,7 +11,7 @@ true - + diff --git a/test/AWS.Messaging.UnitTests/AWS.Messaging.UnitTests.csproj b/test/AWS.Messaging.UnitTests/AWS.Messaging.UnitTests.csproj index 8de1f1f5..1a843345 100644 --- a/test/AWS.Messaging.UnitTests/AWS.Messaging.UnitTests.csproj +++ b/test/AWS.Messaging.UnitTests/AWS.Messaging.UnitTests.csproj @@ -21,11 +21,11 @@ - + - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/test/AWS.Messaging.UnitTests/SQSMessagePollerTests.cs b/test/AWS.Messaging.UnitTests/SQSMessagePollerTests.cs index f2dbf624..ede7e99f 100644 --- a/test/AWS.Messaging.UnitTests/SQSMessagePollerTests.cs +++ b/test/AWS.Messaging.UnitTests/SQSMessagePollerTests.cs @@ -236,7 +236,8 @@ public async Task SQSMessagePoller_ExtendMessageVisibility_RequestHasMoreThan10E await messagePoller.ExtendMessageVisibilityTimeoutAsync(messageEnvelopes); Assert.NotNull(_inMemoryLogger); - Assert.Empty(_inMemoryLogger.Logs.Where(x => x.Exception is AmazonSQSException ex && ex.ErrorCode.Equals("AWS.SimpleQueueService.TooManyEntriesInBatchRequest"))); + Assert.DoesNotContain(_inMemoryLogger.Logs, (x => x.Exception is AmazonSQSException ex && ex.ErrorCode.Equals("AWS.SimpleQueueService.TooManyEntriesInBatchRequest"))); + } /// @@ -286,10 +287,9 @@ public async Task SQSMessagePoller_ExtendsAlreadyDeleteMessage_OnlyLogsTrace() Assert.NotNull(_inMemoryLogger); // Don't expect to see message 1 in the error logs, since this is the case where it was deleted before or while extending visibility - Assert.Empty(_inMemoryLogger.Logs.Where(x => x.Message.Contains("batchNum_0_messageId_1"))); - + Assert.DoesNotContain(_inMemoryLogger.Logs, (x => x.Message.Contains("batchNum_0_messageId_1"))); // But we should see an entry for message 2, which failed to extend visibility for a different reason - Assert.Single(_inMemoryLogger.Logs.Where(x => x.Message.Contains("batchNum_0_messageId_2") && x.LogLevel == LogLevel.Error)); + Assert.Single(_inMemoryLogger.Logs, (x => x.Message.Contains("batchNum_0_messageId_2") && x.LogLevel == LogLevel.Error)); } ///