From 58f84a48135d68b66ad533978dc5300c9fc21eed Mon Sep 17 00:00:00 2001 From: Norm Johanson Date: Fri, 22 May 2026 15:06:21 -0700 Subject: [PATCH 1/2] Add AWSSDK.Signer package to support 'aws login' credentials for test tool --- .../0eb5580c-be03-4e71-a7b1-c0ae06afea0a.json | 20 ++++++++++ .../Amazon.Lambda.TestTool.csproj | 22 +++++------ .../Amazon.Lambda.TestTool.csproj | 17 +++++---- .../LocalLambdaOptions.cs | 10 ++--- .../Runtime/DlqMonitor.cs | 38 +++++++++---------- .../Services/AWSServiceImpl.cs | 11 +++--- .../RuntimeApiControllerTests.cs | 6 +-- 7 files changed, 73 insertions(+), 51 deletions(-) create mode 100644 .autover/changes/0eb5580c-be03-4e71-a7b1-c0ae06afea0a.json diff --git a/.autover/changes/0eb5580c-be03-4e71-a7b1-c0ae06afea0a.json b/.autover/changes/0eb5580c-be03-4e71-a7b1-c0ae06afea0a.json new file mode 100644 index 000000000..c804c9eb6 --- /dev/null +++ b/.autover/changes/0eb5580c-be03-4e71-a7b1-c0ae06afea0a.json @@ -0,0 +1,20 @@ +{ + "Projects": [ + { + "Name": "Amazon.Lambda.TestTool.BlazorTester", + "Type": "Minor", + "ChangelogMessages": [ + "Add AWSSDK.Signer package to support \u0027aws login\u0027 based credentials", + "Update to V4 of the AWS SDK for .NET" + ] + }, + { + "Name": "Amazon.Lambda.TestTool", + "Type": "Minor", + "ChangelogMessages": [ + "Add AWSSDK.Signer package to support \u0027aws login\u0027 based credentials", + "Update AWS SDK and Amazon Lambda packages to latest versions" + ] + } + ] +} \ No newline at end of file diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Amazon.Lambda.TestTool.csproj b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Amazon.Lambda.TestTool.csproj index beb981862..523ca4c3f 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Amazon.Lambda.TestTool.csproj +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Amazon.Lambda.TestTool.csproj @@ -22,19 +22,19 @@ - - - - - - - - - - + + + + + + + + + + - + diff --git a/Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/Amazon.Lambda.TestTool.csproj b/Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/Amazon.Lambda.TestTool.csproj index 2b1d75130..da45dd762 100644 --- a/Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/Amazon.Lambda.TestTool.csproj +++ b/Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/Amazon.Lambda.TestTool.csproj @@ -10,14 +10,15 @@ - - - - + + + + + - - + + @@ -34,7 +35,7 @@ - + @@ -42,7 +43,7 @@ - + diff --git a/Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/LocalLambdaOptions.cs b/Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/LocalLambdaOptions.cs index 317b846f7..1c20d330f 100644 --- a/Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/LocalLambdaOptions.cs +++ b/Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/LocalLambdaOptions.cs @@ -1,4 +1,4 @@ -using Amazon.Lambda.TestTool.Runtime; +using Amazon.Lambda.TestTool.Runtime; using System; using System.Collections.Generic; using System.IO; @@ -18,7 +18,7 @@ public class LocalLambdaOptions public LambdaFunction LoadLambdaFuntion(string configFile, string functionHandler) { - var fullConfigFilePath = this.LambdaConfigFiles.FirstOrDefault(x => + var fullConfigFilePath = LambdaConfigFiles.FirstOrDefault(x => string.Equals(configFile, x, StringComparison.OrdinalIgnoreCase) || string.Equals(configFile, Path.GetFileName(x), StringComparison.OrdinalIgnoreCase)); if (fullConfigFilePath == null) { @@ -51,7 +51,7 @@ public LambdaFunction LoadLambdaFuntion(LambdaConfigInfo configInfo, string func throw new Exception($"Failed to find function {functionHandler}"); } - var function = this.LambdaRuntime.LoadLambdaFunction(functionInfo); + var function = LambdaRuntime.LoadLambdaFunction(functionInfo); return function; } @@ -60,14 +60,14 @@ public LambdaFunction LoadLambdaFuntion(LambdaConfigInfo configInfo, string func /// public string GetPreferenceDirectory(bool createIfNotExist) { - var currentDirectory = this.LambdaRuntime.LambdaAssemblyDirectory; + var currentDirectory = LambdaRuntime.LambdaAssemblyDirectory; while (currentDirectory != null && !Utils.IsProjectDirectory(currentDirectory)) { currentDirectory = Directory.GetParent(currentDirectory)?.FullName; } if (currentDirectory == null) - currentDirectory = this.LambdaRuntime.LambdaAssemblyDirectory; + currentDirectory = LambdaRuntime.LambdaAssemblyDirectory; var preferenceDirectory = Path.Combine(currentDirectory, ".lambda-test-tool"); if (createIfNotExist && !Directory.Exists(preferenceDirectory)) diff --git a/Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/Runtime/DlqMonitor.cs b/Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/Runtime/DlqMonitor.cs index 11dfd0f2a..25e3e2712 100644 --- a/Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/Runtime/DlqMonitor.cs +++ b/Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/Runtime/DlqMonitor.cs @@ -1,4 +1,4 @@ -using Amazon.SQS.Model; +using Amazon.SQS.Model; using System; using System.Collections.Generic; using System.Text.Json; @@ -25,27 +25,27 @@ public class DlqMonitor public DlqMonitor(ILocalLambdaRuntime runtime, LambdaFunction function, string profile, string region, string queueUrl) { - this._runtime = runtime; - this._function = function; - this._profile = profile; - this._region = region; - this._queueUrl = queueUrl; + _runtime = runtime; + _function = function; + _profile = profile; + _region = region; + _queueUrl = queueUrl; } public void Start() { - this._cancelSource = new CancellationTokenSource(); - _ = Loop(this._cancelSource.Token); + _cancelSource = new CancellationTokenSource(); + _ = Loop(_cancelSource.Token); } public void Stop() { - this._cancelSource.Cancel(); + _cancelSource.Cancel(); } private async Task Loop(CancellationToken token) { - var aws = this._runtime.AWSService; + var aws = _runtime.AWSService; while (!token.IsCancellationRequested) { Message message = null; @@ -53,7 +53,7 @@ private async Task Loop(CancellationToken token) try { // Read a message from the queue using the ExternalCommands console application. - message = await aws.ReadMessageAsync(this._profile, this._region, this._queueUrl); + message = await aws.ReadMessageAsync(_profile, _region, _queueUrl); if (token.IsCancellationRequested) { return; @@ -68,9 +68,9 @@ private async Task Loop(CancellationToken token) // If a message was received execute the Lambda function within the test tool. var request = new ExecutionRequest { - AWSProfile = this._profile, - AWSRegion = this._region, - Function = this._function, + AWSProfile = _profile, + AWSRegion = _region, + Function = _function, Payload = JsonSerializer.Serialize(new { Records = new List @@ -80,7 +80,7 @@ private async Task Loop(CancellationToken token) }) }; - var response = await this._runtime.ExecuteLambdaFunctionAsync(request); + var response = await _runtime.ExecuteLambdaFunctionAsync(request); // Capture the results to send back to the client application. logRecord = new LogRecord @@ -109,7 +109,7 @@ private async Task Loop(CancellationToken token) lock (LOG_LOCK) { - this._records.Add(logRecord); + _records.Add(logRecord); } } } @@ -119,8 +119,8 @@ public IList FetchNewLogs() { lock (LOG_LOCK) { - var logsToSend = this._records; - this._records = new List(); + var logsToSend = _records; + _records = new List(); return logsToSend; } } @@ -135,4 +135,4 @@ public class LogRecord public string ReceiptHandle { get; set; } } } -} \ No newline at end of file +} diff --git a/Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/Services/AWSServiceImpl.cs b/Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/Services/AWSServiceImpl.cs index d0aa6048e..1acf96f9e 100644 --- a/Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/Services/AWSServiceImpl.cs +++ b/Tools/LambdaTestTool/src/Amazon.Lambda.TestTool/Services/AWSServiceImpl.cs @@ -1,5 +1,6 @@ -using Amazon.Runtime; +using Amazon.Runtime; using Amazon.Runtime.CredentialManagement; +using Amazon.Runtime.Credentials; using Amazon.SQS; using Amazon.SQS.Model; using System.Collections.Generic; @@ -35,7 +36,7 @@ public async Task> ListQueuesAsync(string profile, string region) using (var client = new AmazonSQSClient(creds, RegionEndpoint.GetBySystemName(region))) { var response = await client.ListQueuesAsync(new ListQueuesRequest()); - return response.QueueUrls; + return response.QueueUrls ?? new List(); } } @@ -51,11 +52,11 @@ public async Task ReadMessageAsync(string profile, string region, strin WaitTimeSeconds = 20, MaxNumberOfMessages = 1, VisibilityTimeout = 60, - AttributeNames = new List() { "All" }, + MessageSystemAttributeNames = new List() { "All" }, MessageAttributeNames = new List() { "*" } }; var response = await client.ReceiveMessageAsync(request); - if (response.Messages.Count == 0) + if (response.Messages == null ||response.Messages.Count == 0) { return null; } @@ -104,7 +105,7 @@ static AWSCredentials GetCredentials(string profileName) } else { - credentials = FallbackCredentialsFactory.GetCredentials(); + credentials = DefaultAWSCredentialsIdentityResolver.GetCredentials(); } return credentials; } diff --git a/Tools/LambdaTestTool/tests/Amazon.Lambda.TestTool.BlazorTester.Tests/RuntimeApiControllerTests.cs b/Tools/LambdaTestTool/tests/Amazon.Lambda.TestTool.BlazorTester.Tests/RuntimeApiControllerTests.cs index 5404c1a45..508a8625a 100644 --- a/Tools/LambdaTestTool/tests/Amazon.Lambda.TestTool.BlazorTester.Tests/RuntimeApiControllerTests.cs +++ b/Tools/LambdaTestTool/tests/Amazon.Lambda.TestTool.BlazorTester.Tests/RuntimeApiControllerTests.cs @@ -171,9 +171,9 @@ protected virtual void Dispose(bool disposing) { if (disposing) { - this.Client.Dispose(); - this.Source.Cancel(); - this.WebHost.StopAsync().GetAwaiter().GetResult(); + Client.Dispose(); + Source.Cancel(); + WebHost.StopAsync().GetAwaiter().GetResult(); } disposedValue = true; From 9288bc508f8604499728bc2a5a8a544c543fba0b Mon Sep 17 00:00:00 2001 From: Norm Johanson Date: Fri, 22 May 2026 16:58:26 -0700 Subject: [PATCH 2/2] Update test dependencies --- ...on.Lambda.TestTool.IntegrationTests.csproj | 30 +++++++++---------- ...Amazon.Lambda.TestTool.Tests.Common.csproj | 2 +- .../Amazon.Lambda.TestTool.UnitTests.csproj | 18 +++++------ 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.IntegrationTests/Amazon.Lambda.TestTool.IntegrationTests.csproj b/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.IntegrationTests/Amazon.Lambda.TestTool.IntegrationTests.csproj index 7ac170c61..75f5b2526 100644 --- a/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.IntegrationTests/Amazon.Lambda.TestTool.IntegrationTests.csproj +++ b/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.IntegrationTests/Amazon.Lambda.TestTool.IntegrationTests.csproj @@ -11,26 +11,26 @@ - - - - - - - - - - - - + + + + + + + + + + + + - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.Tests.Common/Amazon.Lambda.TestTool.Tests.Common.csproj b/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.Tests.Common/Amazon.Lambda.TestTool.Tests.Common.csproj index 4795daf76..4f13ab9e9 100644 --- a/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.Tests.Common/Amazon.Lambda.TestTool.Tests.Common.csproj +++ b/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.Tests.Common/Amazon.Lambda.TestTool.Tests.Common.csproj @@ -8,7 +8,7 @@ - + diff --git a/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/Amazon.Lambda.TestTool.UnitTests.csproj b/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/Amazon.Lambda.TestTool.UnitTests.csproj index 7a799ca1e..7d2edd6c4 100644 --- a/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/Amazon.Lambda.TestTool.UnitTests.csproj +++ b/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/Amazon.Lambda.TestTool.UnitTests.csproj @@ -12,21 +12,21 @@ - - - - - - - + + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive