From 8b90fa525a58f18d7bc483df341bf3c1439607cb Mon Sep 17 00:00:00 2001 From: Phil Asmar Date: Tue, 17 Dec 2024 16:42:36 -0500 Subject: [PATCH] chore: add Amazon header to all files --- .editorconfig | 247 ++++++++++++++++++ .gitattribute | 9 + .../Amazon.Lambda.TestTool.sln | 30 +++ ...tTool.slnx => Amazon.Lambda.TestTool.slnx} | 0 .../Amazon.Lambda.TestTool.csproj | 18 +- .../Commands/CancellableAsyncCommand.cs | 7 +- .../Commands/RunCommand.cs | 13 +- .../Commands/Settings/RunCommandSettings.cs | 15 +- .../src/Amazon.Lambda.TestTool/Constants.cs | 3 + .../Extensions/ExceptionExtensions.cs | 13 +- .../Extensions/ServiceCollectionExtensions.cs | 17 +- .../Models/ApiGatewayEmulatorMode.cs | 5 +- .../Models/ApiGatewayRouteConfig.cs | 11 +- .../Models/CommandReturnCodes.cs | 5 +- .../Models/EventContainer.cs | 19 +- .../Models/Exceptions.cs | 13 +- .../Processes/ApiGatewayEmulatorProcess.cs | 15 +- .../Processes/TestToolProcess.cs | 25 +- .../src/Amazon.Lambda.TestTool/Program.cs | 5 +- .../SampleRequests/LambdaRequest.cs | 5 +- .../SampleRequests/SampleRequestManager.cs | 13 +- .../Services/ApiGatewayRouteConfigService.cs | 55 ++-- .../Services/ConfigureStaticFilesOptions.cs | 7 +- .../Services/ConsoleInteractiveService.cs | 21 +- .../Services/IApiGatewayRouteConfigService.cs | 5 +- .../Services/IO/DirectoryManager.cs | 5 +- .../Services/IO/EnvironmentManager.cs | 7 +- .../Services/IO/IDirectoryManager.cs | 5 +- .../Services/IO/IEnvironmentManager.cs | 5 +- .../Services/IToolInteractiveService.cs | 5 +- .../Services/LambdaRuntimeAPI.cs | 7 +- .../Services/RuntimeApiDataStore.cs | 39 +-- .../Services/TypeRegistrar.cs | 17 +- .../Services/TypeResolver.cs | 13 +- .../Amazon.Lambda.TestTool/Utilities/Utils.cs | 13 +- .../Commands/RunCommandTests.cs | 7 +- .../Settings/RunCommandSettingsTests.cs | 7 +- .../Helpers/TestHelpers.cs | 5 +- .../RuntimeApiTests.cs | 5 +- .../ApiGatewayRouteConfigServiceTests.cs | 27 +- 40 files changed, 567 insertions(+), 176 deletions(-) create mode 100644 .editorconfig create mode 100644 .gitattribute create mode 100644 Tools/LambdaTestTool-v2/Amazon.Lambda.TestTool.sln rename Tools/LambdaTestTool-v2/{AWS.Lambda.TestTool.slnx => Amazon.Lambda.TestTool.slnx} (100%) diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..6e89449c1 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,247 @@ +root=true +# top-most EditorConfig file + +# Default settings: +# A newline ending every file +# Use 4 spaces as indentation +[*] +insert_final_newline=true +indent_style=space +indent_size=4 +trim_trailing_whitespace=true +end_of_line=crlf +charset=utf-8 + +[project.json] +indent_size=2 + +# Generated code +[*{_AssemblyInfo.cs,.notsupported.cs}] +generated_code=true + +# Xml project files +[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}] +indent_size=2 + +[*.{csproj,vbproj,proj,nativeproj,locproj}] +charset=utf-8 + +# Xml build files +[*.builds] +indent_size=2 + +# Xml files +[*.{xml,stylecop,resx,ruleset}] +indent_size=2 + +# Xml config files +[*.{props,targets,config,nuspec}] +indent_size=2 + +# YAML config files +[*.{yml,yaml}] +indent_size=2 + +# Shell scripts +[*.sh] +end_of_line=lf +[*.{cmd,bat}] +end_of_line=crlf + +[*.lock] +end_of_line=lf + +# C# files +[*.cs] +max_line_length=140 + +# New line preferences +csharp_new_line_before_open_brace=all +csharp_new_line_before_else=true +csharp_new_line_before_catch=true +csharp_new_line_before_finally=true +csharp_new_line_before_members_in_object_initializers=true +csharp_new_line_before_members_in_anonymous_types=true +csharp_new_line_between_query_expression_clauses=true + +# Indentation preferences +csharp_indent_block_contents=true +csharp_indent_braces=false +csharp_indent_case_contents=true +csharp_indent_case_contents_when_block=true +csharp_indent_switch_labels=true +csharp_indent_labels=one_less_than_current + +# Modifier preferences +csharp_preferred_modifier_order=public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion + +# avoid this. unless absolutely necessary +dotnet_style_qualification_for_field=false:warning +dotnet_style_qualification_for_property=false:error +dotnet_style_qualification_for_method=false:warning +dotnet_style_qualification_for_event=false:warning + +# Types: use keywords instead of BCL types, and prefer var +csharp_style_var_elsewhere=true:suggestion +csharp_style_var_for_built_in_types=true:suggestion +csharp_style_var_when_type_is_apparent=true:suggestion +dotnet_style_predefined_type_for_locals_parameters_members=true:suggestion +dotnet_style_predefined_type_for_member_access=true:suggestion + +# name all constant fields using ALL_UPPER +dotnet_naming_rule.constant_fields_should_be_all_upper.severity=suggestion +dotnet_naming_rule.constant_fields_should_be_all_upper.symbols=constant_fields +dotnet_naming_rule.constant_fields_should_be_all_upper.style=consts_style +dotnet_naming_symbols.constant_fields.applicable_kinds=field +dotnet_naming_symbols.constant_fields.required_modifiers=const +dotnet_naming_symbols.constant_fields.applicable_accessibilities=private, internal, private_protected +dotnet_naming_style.consts_style.capitalization=all_upper +dotnet_naming_style.consts_style.word_separator=_ + +# static fields should have s_ prefix +dotnet_naming_rule.static_fields_should_have_prefix.severity=suggestion +dotnet_naming_rule.static_fields_should_have_prefix.symbols=static_fields +dotnet_naming_rule.static_fields_should_have_prefix.style=static_prefix_style +dotnet_naming_symbols.static_fields.applicable_kinds=field +dotnet_naming_symbols.static_fields.required_modifiers=static +dotnet_naming_symbols.static_fields.applicable_accessibilities=private, internal, private_protected +dotnet_naming_style.static_prefix_style.required_prefix=s_ +dotnet_naming_style.static_prefix_style.capitalization=camel_case + +# internal and private fields should be _camelCase +dotnet_naming_rule.camel_case_for_private_internal_fields.severity=suggestion +dotnet_naming_rule.camel_case_for_private_internal_fields.symbols=private_internal_fields +dotnet_naming_rule.camel_case_for_private_internal_fields.style=camel_case_underscore_style +dotnet_naming_symbols.private_internal_fields.applicable_kinds=field +dotnet_naming_symbols.private_internal_fields.applicable_accessibilities=private, internal +dotnet_naming_style.camel_case_underscore_style.required_prefix=_ +dotnet_naming_style.camel_case_underscore_style.capitalization=camel_case + +# Code style defaults +csharp_using_directive_placement=outside_namespace:suggestion +dotnet_sort_system_directives_first=true +csharp_prefer_braces=true:silent +csharp_preserve_single_line_blocks=true:none +csharp_preserve_single_line_statements=false:none +csharp_prefer_static_local_function=true:suggestion +csharp_prefer_simple_using_statement=false:none +csharp_style_prefer_switch_expression=true:suggestion + +# Code quality +dotnet_style_readonly_field=true:warning +dotnet_code_quality_unused_parameters=non_public:warning + +# Expression-level preferences +dotnet_style_object_initializer=true:suggestion +dotnet_style_collection_initializer=true:suggestion +dotnet_style_explicit_tuple_names=true:suggestion +dotnet_style_coalesce_expression=true:suggestion +dotnet_style_null_propagation=true:suggestion +dotnet_style_prefer_is_null_check_over_reference_equality_method=true:suggestion +dotnet_style_prefer_inferred_tuple_names=true:suggestion +dotnet_style_prefer_inferred_anonymous_type_member_names=true:suggestion +dotnet_style_prefer_auto_properties=true:suggestion +dotnet_style_prefer_conditional_expression_over_assignment=true:silent +dotnet_style_prefer_conditional_expression_over_return=true:silent +csharp_prefer_simple_default_expression=true:suggestion + +# Expression-bodied members +csharp_style_expression_bodied_methods=true:silent +csharp_style_expression_bodied_constructors=true:silent +csharp_style_expression_bodied_operators=true:silent +csharp_style_expression_bodied_properties=true:silent +csharp_style_expression_bodied_indexers=true:silent +csharp_style_expression_bodied_accessors=true:silent +csharp_style_expression_bodied_lambdas=true:silent +csharp_style_expression_bodied_local_functions=true:silent + +# Pattern matching +csharp_style_pattern_matching_over_is_with_cast_check=true:suggestion +csharp_style_pattern_matching_over_as_with_null_check=true:suggestion +csharp_style_inlined_variable_declaration=true:suggestion + +# Null checking preferences +csharp_style_throw_expression=true:suggestion +csharp_style_conditional_delegate_call=true:suggestion + +# Other features +csharp_style_prefer_index_operator=false:none +csharp_style_prefer_range_operator=false:none +csharp_style_pattern_local_over_anonymous_function=false:none + +# Space preferences +csharp_space_after_cast=false +csharp_space_after_colon_in_inheritance_clause=true +csharp_space_after_comma=true +csharp_space_after_dot=false +csharp_space_after_keywords_in_control_flow_statements=true +csharp_space_after_semicolon_in_for_statement=true +csharp_space_around_binary_operators=before_and_after +csharp_space_around_declaration_statements=do_not_ignore +csharp_space_before_colon_in_inheritance_clause=true +csharp_space_before_comma=false +csharp_space_before_dot=false +csharp_space_before_open_square_brackets=false +csharp_space_before_semicolon_in_for_statement=false +csharp_space_between_empty_square_brackets=false +csharp_space_between_method_call_empty_parameter_list_parentheses=false +csharp_space_between_method_call_name_and_opening_parenthesis=false +csharp_space_between_method_call_parameter_list_parentheses=false +csharp_space_between_method_declaration_empty_parameter_list_parentheses=false +csharp_space_between_method_declaration_name_and_open_parenthesis=false +csharp_space_between_method_declaration_parameter_list_parentheses=false +csharp_space_between_parentheses=false +csharp_space_between_square_brackets=false + +# Analyzers +dotnet_code_quality.ca1802.api_surface=private, internal +dotnet_code_quality.ca1822.api_surface=private, internal +dotnet_code_quality.ca2208.api_surface=public + +# CA1822: Mark members as static +dotnet_diagnostic.ca1822.severity=none + +# License header +file_header_template= Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\r\nSPDX-License-Identifier: Apache-2.0 + +# ReSharper properties +resharper_braces_for_for=required +resharper_braces_for_foreach=required +resharper_braces_for_ifelse=required_for_multiline +resharper_braces_for_while=required +resharper_braces_redundant=false +resharper_csharp_wrap_arguments_style=chop_if_long +resharper_csharp_wrap_lines=false +resharper_csharp_wrap_parameters_style=chop_if_long +resharper_enforce_line_ending_style=true +resharper_max_initializer_elements_on_line=1 +resharper_space_before_foreach_parentheses=true +resharper_space_before_if_parentheses=true +resharper_space_within_single_line_array_initializer_braces=true +resharper_use_indent_from_vs=false +resharper_wrap_after_declaration_lpar=true +resharper_wrap_object_and_collection_initializer_style=chop_always + + +# ReSharper inspection severities +# https://www.jetbrains.com/help/resharper/EditorConfig_Index.html +resharper_arrange_redundant_parentheses_highlighting=hint +resharper_arrange_this_qualifier_highlighting=error +resharper_arrange_type_member_modifiers_highlighting=hint +resharper_arrange_type_modifiers_highlighting=hint +resharper_built_in_type_reference_style_for_member_access_highlighting=hint +resharper_built_in_type_reference_style_highlighting=hint +resharper_ca1031_highlighting=suggestion +resharper_ca1308_highlighting=none +resharper_ca2007_highlighting=none +resharper_convert_closure_to_method_group_highlighting=hint +resharper_convert_to_static_class_highlighting=none +resharper_member_can_be_made_static_global_highlighting=none +resharper_member_can_be_made_static_local_highlighting=none +resharper_redundant_base_qualifier_highlighting=warning +resharper_suggest_var_or_type_built_in_types_highlighting=hint +resharper_suggest_var_or_type_elsewhere_highlighting=hint +resharper_suggest_var_or_type_simple_types_highlighting=hint +resharper_web_config_module_not_resolved_highlighting=warning +resharper_web_config_type_not_resolved_highlighting=warning +resharper_web_config_wrong_module_highlighting=warning \ No newline at end of file diff --git a/.gitattribute b/.gitattribute new file mode 100644 index 000000000..2d72dacca --- /dev/null +++ b/.gitattribute @@ -0,0 +1,9 @@ +# Set the default behavior, in case people don't have core.autocrlf set. +* text=auto + +# Declare files that will always have CRLF line endings on checkout. +*.sln text eol=crlf + +# Denote all files that are truly binary and should not be modified. +*.png binary +*.jpg binary \ No newline at end of file diff --git a/Tools/LambdaTestTool-v2/Amazon.Lambda.TestTool.sln b/Tools/LambdaTestTool-v2/Amazon.Lambda.TestTool.sln new file mode 100644 index 000000000..9a6282320 --- /dev/null +++ b/Tools/LambdaTestTool-v2/Amazon.Lambda.TestTool.sln @@ -0,0 +1,30 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{827E0CD3-B72D-47B6-A68D-7590B98EB39B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Amazon.Lambda.TestTool", "src\Amazon.Lambda.TestTool\Amazon.Lambda.TestTool.csproj", "{97EE2E8A-D1F4-CB11-B664-B99B036E9F7B}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{0AB3BF05-4346-4AA6-1389-037BE0695223}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Amazon.Lambda.TestTool.UnitTests", "tests\Amazon.Lambda.TestTool.UnitTests\Amazon.Lambda.TestTool.UnitTests.csproj", "{80A4F809-28B7-61EC-6539-DF3C7A0733FD}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {97EE2E8A-D1F4-CB11-B664-B99B036E9F7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {97EE2E8A-D1F4-CB11-B664-B99B036E9F7B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {97EE2E8A-D1F4-CB11-B664-B99B036E9F7B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {97EE2E8A-D1F4-CB11-B664-B99B036E9F7B}.Release|Any CPU.Build.0 = Release|Any CPU + {80A4F809-28B7-61EC-6539-DF3C7A0733FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {80A4F809-28B7-61EC-6539-DF3C7A0733FD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {80A4F809-28B7-61EC-6539-DF3C7A0733FD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {80A4F809-28B7-61EC-6539-DF3C7A0733FD}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {97EE2E8A-D1F4-CB11-B664-B99B036E9F7B} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B} + {80A4F809-28B7-61EC-6539-DF3C7A0733FD} = {0AB3BF05-4346-4AA6-1389-037BE0695223} + EndGlobalSection +EndGlobal diff --git a/Tools/LambdaTestTool-v2/AWS.Lambda.TestTool.slnx b/Tools/LambdaTestTool-v2/Amazon.Lambda.TestTool.slnx similarity index 100% rename from Tools/LambdaTestTool-v2/AWS.Lambda.TestTool.slnx rename to Tools/LambdaTestTool-v2/Amazon.Lambda.TestTool.slnx 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 7afdd2e7a..4b26ad9fd 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 @@ -1,29 +1,29 @@  - A tool to help debug and test your .NET AWS Lambda functions locally. + A tool to help debug and test your .NET AWS Lambda functions locally. net8.0 enable enable AWS .NET Lambda Test Tool Apache 2 - AWS;Amazon;Lambda - true + AWS;Amazon;Lambda + true true true - Amazon.Lambda.TestTool + Amazon.Lambda.TestTool - + - - - + + + - + diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Commands/CancellableAsyncCommand.cs b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Commands/CancellableAsyncCommand.cs index c18813859..977891ac9 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Commands/CancellableAsyncCommand.cs +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Commands/CancellableAsyncCommand.cs @@ -1,4 +1,7 @@ -using System.Runtime.InteropServices; +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +using System.Runtime.InteropServices; namespace Spectre.Console.Cli; @@ -33,4 +36,4 @@ void onSignal(PosixSignalContext context) cancellationSource.Cancel(); } } -} \ No newline at end of file +} diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Commands/RunCommand.cs b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Commands/RunCommand.cs index 1334331b5..83482d0db 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Commands/RunCommand.cs +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Commands/RunCommand.cs @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + using System.Diagnostics; using Amazon.Lambda.TestTool.Commands.Settings; using Amazon.Lambda.TestTool.Extensions; @@ -8,14 +11,14 @@ namespace Amazon.Lambda.TestTool.Commands; -/// -/// The default command of the application which is responsible for launching the Lambda Runtime API and the API Gateway Emulator. +/// +/// The default command of the application which is responsible for launching the Lambda Runtime API and the API Gateway Emulator. /// public sealed class RunCommand( IToolInteractiveService toolInteractiveService) : CancellableAsyncCommand { - /// - /// The method responsible for executing the . + /// + /// The method responsible for executing the . /// public override async Task ExecuteAsync(CommandContext context, RunCommandSettings settings, CancellationTokenSource cancellationTokenSource) { @@ -77,4 +80,4 @@ public override async Task ExecuteAsync(CommandContext context, RunCommandS await cancellationTokenSource.CancelAsync(); } } -} \ No newline at end of file +} diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Commands/Settings/RunCommandSettings.cs b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Commands/Settings/RunCommandSettings.cs index bb7e72995..c6c742ff8 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Commands/Settings/RunCommandSettings.cs +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Commands/Settings/RunCommandSettings.cs @@ -1,4 +1,7 @@ -using Amazon.Lambda.TestTool.Models; +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +using Amazon.Lambda.TestTool.Models; using Spectre.Console.Cli; using System.ComponentModel; @@ -10,7 +13,7 @@ namespace Amazon.Lambda.TestTool.Commands.Settings; public sealed class RunCommandSettings : CommandSettings { /// - /// The hostname or IP address used for the test tool's web interface. + /// The hostname or IP address used for the test tool's web interface. /// Any host other than an explicit IP address or localhost (e.g. '*', '+' or 'example.com') binds to all public IPv4 and IPv6 addresses. /// [CommandOption("--host ")] @@ -35,8 +38,8 @@ public sealed class RunCommandSettings : CommandSettings public bool NoLaunchWindow { get; set; } /// - /// If set to true the test tool will pause waiting for a key input before exiting. - /// The is useful when executing from an IDE so you can avoid having the output window immediately disappear after executing the Lambda code. + /// If set to true the test tool will pause waiting for a key input before exiting. + /// The is useful when executing from an IDE so you can avoid having the output window immediately disappear after executing the Lambda code. /// The default value is true. /// [CommandOption("--pause-exit")] @@ -51,7 +54,7 @@ public sealed class RunCommandSettings : CommandSettings public bool DisableLogs { get; set; } /// - /// The API Gateway Emulator Mode specifies the format of the event that API Gateway sends to a Lambda integration, + /// The API Gateway Emulator Mode specifies the format of the event that API Gateway sends to a Lambda integration, /// and how API Gateway interprets the response from Lambda. /// The available modes are: Rest, HttpV1, HttpV2. /// @@ -68,4 +71,4 @@ public sealed class RunCommandSettings : CommandSettings [Description("The port number used for the test tool's API Gateway emulator.")] [DefaultValue(Constants.DefaultApiGatewayEmulatorPort)] public int? ApiGatewayEmulatorPort { get; set; } = Constants.DefaultApiGatewayEmulatorPort; -} \ No newline at end of file +} diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Constants.cs b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Constants.cs index b93e15b47..a3651d0b9 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Constants.cs +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Constants.cs @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + using Amazon.Lambda.TestTool.Models; namespace Amazon.Lambda.TestTool; diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Extensions/ExceptionExtensions.cs b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Extensions/ExceptionExtensions.cs index 7aa9e6b38..efc935a40 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Extensions/ExceptionExtensions.cs +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Extensions/ExceptionExtensions.cs @@ -1,9 +1,12 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + using Amazon.Lambda.TestTool.Models; namespace Amazon.Lambda.TestTool.Extensions; -/// -/// A class that contains extension methods for the class. +/// +/// A class that contains extension methods for the class. /// public static class ExceptionExtensions { @@ -14,8 +17,8 @@ public static class ExceptionExtensions public static bool IsExpectedException(this Exception e) => e is TestToolException; - /// - /// Prints an exception in a user-friendly way. + /// + /// Prints an exception in a user-friendly way. /// public static string PrettyPrint(this Exception? e) { @@ -26,4 +29,4 @@ public static string PrettyPrint(this Exception? e) $"{Environment.NewLine}{e.StackTrace}" + $"{PrettyPrint(e.InnerException)}"; } -} \ No newline at end of file +} diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Extensions/ServiceCollectionExtensions.cs b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Extensions/ServiceCollectionExtensions.cs index 09c3ad19e..871844975 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Extensions/ServiceCollectionExtensions.cs +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Extensions/ServiceCollectionExtensions.cs @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + using Amazon.Lambda.TestTool.Services; using Amazon.Lambda.TestTool.Services.IO; using Microsoft.Extensions.DependencyInjection.Extensions; @@ -9,18 +12,18 @@ namespace Amazon.Lambda.TestTool.Extensions; /// public static class ServiceCollectionExtensions { - /// - /// Adds a set of services for the .NET CLI portion of this application. + /// + /// Adds a set of services for the .NET CLI portion of this application. /// public static void AddCustomServices(this IServiceCollection serviceCollection, ServiceLifetime lifetime = ServiceLifetime.Singleton) { serviceCollection.TryAdd(new ServiceDescriptor(typeof(IToolInteractiveService), typeof(ConsoleInteractiveService), lifetime)); serviceCollection.TryAdd(new ServiceDescriptor(typeof(IDirectoryManager), typeof(DirectoryManager), lifetime)); - } - - /// - /// Adds a set of services for the API Gateway emulator portion of this application. + } + + /// + /// Adds a set of services for the API Gateway emulator portion of this application. /// public static void AddApiGatewayEmulatorServices(this IServiceCollection serviceCollection, ServiceLifetime lifetime = ServiceLifetime.Singleton) @@ -28,4 +31,4 @@ public static void AddApiGatewayEmulatorServices(this IServiceCollection service serviceCollection.TryAdd(new ServiceDescriptor(typeof(IApiGatewayRouteConfigService), typeof(ApiGatewayRouteConfigService), lifetime)); serviceCollection.TryAdd(new ServiceDescriptor(typeof(IEnvironmentManager), typeof(EnvironmentManager), lifetime)); } -} \ No newline at end of file +} diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Models/ApiGatewayEmulatorMode.cs b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Models/ApiGatewayEmulatorMode.cs index f91a6719f..a06d30400 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Models/ApiGatewayEmulatorMode.cs +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Models/ApiGatewayEmulatorMode.cs @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + namespace Amazon.Lambda.TestTool.Models; /// @@ -19,4 +22,4 @@ public enum ApiGatewayEmulatorMode /// Represents the HTTP API v2 Gateway mode. /// HttpV2 -} \ No newline at end of file +} diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Models/ApiGatewayRouteConfig.cs b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Models/ApiGatewayRouteConfig.cs index 243a1d147..eb6a54070 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Models/ApiGatewayRouteConfig.cs +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Models/ApiGatewayRouteConfig.cs @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + namespace Amazon.Lambda.TestTool.Models; /// @@ -9,19 +12,19 @@ public class ApiGatewayRouteConfig /// The name of the Lambda function /// public required string LambdaResourceName { get; set; } - + /// /// The endpoint of the local Lambda Runtime API /// public string? Endpoint { get; set; } - + /// /// The HTTP Method for the API Gateway endpoint /// public required string HttpMethod { get; set; } - + /// /// The API Gateway HTTP Path of the Lambda function /// public required string Path { get; set; } -} \ No newline at end of file +} diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Models/CommandReturnCodes.cs b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Models/CommandReturnCodes.cs index 08b30ca5f..582aa7d98 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Models/CommandReturnCodes.cs +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Models/CommandReturnCodes.cs @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + namespace Amazon.Lambda.TestTool.Models; /// @@ -27,4 +30,4 @@ public abstract class CommandReturnCodes /// inherits from /// public const int UserError = 1; -} \ No newline at end of file +} diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Models/EventContainer.cs b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Models/EventContainer.cs index 6771c8250..bf7da1603 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Models/EventContainer.cs +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Models/EventContainer.cs @@ -1,4 +1,7 @@ -using Amazon.Lambda.TestTool.Services; +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +using Amazon.Lambda.TestTool.Services; namespace Amazon.Lambda.TestTool.Models; @@ -29,7 +32,7 @@ public Status EventStatus } private readonly RuntimeApiDataStore _dataStore; - + public EventContainer(RuntimeApiDataStore dataStore, int eventCount, string eventJson) { LastUpdated = DateTime.Now; @@ -46,17 +49,17 @@ public string FunctionArn public void ReportSuccessResponse(string response) { LastUpdated = DateTime.Now; - this.Response = response; - this.EventStatus = Status.Success; + Response = response; + EventStatus = Status.Success; _dataStore.RaiseStateChanged(); } public void ReportErrorResponse(string errorType, string errorBody) { LastUpdated = DateTime.Now; - this.ErrorType = errorType; - this.ErrorResponse = errorBody; - this.EventStatus = Status.Failure; + ErrorType = errorType; + ErrorResponse = errorBody; + EventStatus = Status.Failure; _dataStore.RaiseStateChanged(); } -} \ No newline at end of file +} diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Models/Exceptions.cs b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Models/Exceptions.cs index f9ea62b18..4ad1b75f2 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Models/Exceptions.cs +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Models/Exceptions.cs @@ -1,9 +1,12 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + namespace Amazon.Lambda.TestTool.Models; -/// -/// Represents a base exception that is thrown by the test tool. -/// -/// +/// +/// Represents a base exception that is thrown by the test tool. +/// +/// /// public abstract class TestToolException(string message, Exception? innerException = null) - : Exception(message, innerException); \ No newline at end of file + : Exception(message, innerException); diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Processes/ApiGatewayEmulatorProcess.cs b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Processes/ApiGatewayEmulatorProcess.cs index 02cf4ce48..3fa3eeef8 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Processes/ApiGatewayEmulatorProcess.cs +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Processes/ApiGatewayEmulatorProcess.cs @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + using Amazon.Lambda.TestTool.Commands.Settings; using Amazon.Lambda.TestTool.Extensions; using Amazon.Lambda.TestTool.Models; @@ -33,7 +36,7 @@ public static ApiGatewayEmulatorProcess Startup(RunCommandSettings settings, Can var builder = WebApplication.CreateBuilder(); builder.Services.AddApiGatewayEmulatorServices(); - + var serviceUrl = $"http://{settings.Host}:{settings.ApiGatewayEmulatorPort}"; builder.WebHost.UseUrls(serviceUrl); builder.WebHost.SuppressStatusMessages(true); @@ -45,7 +48,7 @@ public static ApiGatewayEmulatorProcess Startup(RunCommandSettings settings, Can app.UseHttpsRedirection(); app.MapHealthChecks("/__lambda_test_tool_apigateway_health__"); - + app.Lifetime.ApplicationStarted.Register(() => { app.Logger.LogInformation("The API Gateway Emulator is available at: {ServiceUrl}", serviceUrl); @@ -56,13 +59,13 @@ public static ApiGatewayEmulatorProcess Startup(RunCommandSettings settings, Can var routeConfig = routeConfigService.GetRouteConfig(context.Request.Method, context.Request.Path); if (routeConfig == null) { - app.Logger.LogInformation("Unable to find a configured Lambda route for the specified method and path: {Method} {Path}", + app.Logger.LogInformation("Unable to find a configured Lambda route for the specified method and path: {Method} {Path}", context.Request.Method, context.Request.Path); context.Response.StatusCode = StatusCodes.Status403Forbidden; context.Response.Headers.Append("x-amzn-errortype", "MissingAuthenticationTokenException"); return Results.Json(new { message = "Missing Authentication Token" }); } - + if (settings.ApiGatewayEmulatorMode.Equals(ApiGatewayEmulatorMode.HttpV2)) { // TODO: Translate to APIGatewayHttpApiV2ProxyRequest @@ -76,7 +79,7 @@ public static ApiGatewayEmulatorProcess Startup(RunCommandSettings settings, Can }); var runTask = app.RunAsync(cancellationToken); - + return new ApiGatewayEmulatorProcess { Services = app.Services, @@ -84,4 +87,4 @@ public static ApiGatewayEmulatorProcess Startup(RunCommandSettings settings, Can ServiceUrl = serviceUrl }; } -} \ No newline at end of file +} diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Processes/TestToolProcess.cs b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Processes/TestToolProcess.cs index 4e9c7a8af..2fd66beaf 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Processes/TestToolProcess.cs +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Processes/TestToolProcess.cs @@ -1,4 +1,7 @@ -using Amazon.Lambda.TestTool.Commands.Settings; +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +using Amazon.Lambda.TestTool.Commands.Settings; using Amazon.Lambda.TestTool.Components; using Amazon.Lambda.TestTool.Services; using Amazon.Lambda.TestTool.Services.IO; @@ -7,28 +10,28 @@ namespace Amazon.Lambda.TestTool.Processes; -/// -/// A process that runs the local Lambda Runtime API and its web interface. +/// +/// A process that runs the local Lambda Runtime API and its web interface. /// public class TestToolProcess { - /// - /// The service provider that will contain all the registered services. + /// + /// The service provider that will contain all the registered services. /// public required IServiceProvider Services { get; init; } - /// - /// The Lambda Runtime API task that was started. + /// + /// The Lambda Runtime API task that was started. /// public required Task RunningTask { get; init; } - /// - /// The endpoint of the Lambda Runtime API. + /// + /// The endpoint of the Lambda Runtime API. /// public required string ServiceUrl { get; init; } - /// - /// Creates the Web Application and runs it in the background. + /// + /// Creates the Web Application and runs it in the background. /// public static TestToolProcess Startup(RunCommandSettings settings, CancellationToken cancellationToken = default) { diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Program.cs b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Program.cs index df65b6f10..3cbfd6b5e 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Program.cs +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Program.cs @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + using Amazon.Lambda.TestTool; using Amazon.Lambda.TestTool.Commands; using Amazon.Lambda.TestTool.Extensions; @@ -16,4 +19,4 @@ config.SetApplicationName(Constants.ToolName); }); -return await app.RunAsync(args); \ No newline at end of file +return await app.RunAsync(args); diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/SampleRequests/LambdaRequest.cs b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/SampleRequests/LambdaRequest.cs index 40cc00d72..5db6c1bb7 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/SampleRequests/LambdaRequest.cs +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/SampleRequests/LambdaRequest.cs @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + namespace Amazon.Lambda.TestTool.SampleRequests; public class LambdaRequest @@ -5,4 +8,4 @@ public class LambdaRequest public required string Name { get; init; } public required string Group { get; init; } public required string Filename { get; init; } -} \ No newline at end of file +} diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/SampleRequests/SampleRequestManager.cs b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/SampleRequests/SampleRequestManager.cs index 30cab4e43..996a58f16 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/SampleRequests/SampleRequestManager.cs +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/SampleRequests/SampleRequestManager.cs @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + using System.Xml.Linq; namespace Amazon.Lambda.TestTool.SampleRequests; @@ -27,9 +30,9 @@ public IDictionary> GetSampleRequests() { Group = item.Attribute("category")?.Value ?? string.Empty, Name = item.Element("name")?.Value ?? string.Empty, - Filename = item.Element("filename")?.Value ?? string.Empty, + Filename = item.Element("filename")?.Value ?? string.Empty, }; - + var hash = new Dictionary>(); foreach (var request in requests) @@ -40,7 +43,7 @@ public IDictionary> GetSampleRequests() r = new List(); hash[request.Group] = r; } - + r.Add(request); } @@ -92,7 +95,7 @@ public string GetRequest(string name) if(name.StartsWith(SavedRequestDirectory + "@")) { name = name.Substring(name.IndexOf("@") + 1); - var path = Path.Combine(this.GetSavedRequestDirectory(), name); + var path = Path.Combine(GetSavedRequestDirectory(), name); return File.ReadAllText(path); } return GetEmbeddedResource(name); @@ -135,4 +138,4 @@ public string GetSavedRequestDirectory() var path = Path.Combine(preferenceDirectory, SavedRequestDirectory); return path; } -} \ No newline at end of file +} diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/ApiGatewayRouteConfigService.cs b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/ApiGatewayRouteConfigService.cs index 4ad3d2886..66f8df4bd 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/ApiGatewayRouteConfigService.cs +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/ApiGatewayRouteConfigService.cs @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + using System.Collections; using System.Text.Json; using Amazon.Lambda.TestTool.Models; @@ -42,7 +45,7 @@ private void LoadLambdaConfigurationFromEnvironmentVariables() if (key is null) continue; _logger.LogDebug("Environment variables: {VariableName}", key); - if (!(key.Equals(Constants.LambdaConfigEnvironmentVariablePrefix) || + if (!(key.Equals(Constants.LambdaConfigEnvironmentVariablePrefix) || key.StartsWith($"{Constants.LambdaConfigEnvironmentVariablePrefix}_"))) { _logger.LogDebug("Skipping environment variable: {VariableName}", key); @@ -138,41 +141,41 @@ private bool IsRouteConfigValid(ApiGatewayRouteConfig routeConfig) routeConfig.LambdaResourceName); return false; } - + var occurrences = routeConfig.Path.Split("{proxy+}").Length - 1; if (occurrences > 1) { - _logger.LogError("The route config {Method} {Path} cannot have multiple greedy variables {{proxy+}}.", + _logger.LogError("The route config {Method} {Path} cannot have multiple greedy variables {{proxy+}}.", routeConfig.HttpMethod, routeConfig.Path); return false; } if (occurrences == 1 && !routeConfig.Path.EndsWith("/{proxy+}")) { - _logger.LogError("The route config {Method} {Path} uses a greedy variable {{proxy+}} but does not end with it.", + _logger.LogError("The route config {Method} {Path} uses a greedy variable {{proxy+}} but does not end with it.", routeConfig.HttpMethod, routeConfig.Path); return false; } - + return true; } - + /// /// A method to match an HTTP Method and HTTP Path with an existing . /// Given that route templates could contain variables as well as greedy path variables. /// API Gateway matches incoming routes in a certain order. - /// + /// /// API Gateway selects the route with the most-specific match, using the following priorities: /// 1. Full match for a route and method. /// 2. Match for a route and method with path variable. /// 3. Match for a route and method with a greedy path variable ({proxy+}). - /// + /// /// For example, this is the order for the following example routes: /// 1. GET /pets/dog/1 /// 2. GET /pets/dog/{id} /// 3. GET /pets/{proxy+} /// 4. ANY /{proxy+} - /// + /// /// For more info: https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-routes.html /// /// An HTTP Method @@ -193,7 +196,7 @@ private bool IsRouteConfigValid(ApiGatewayRouteConfig routeConfig) { _logger.LogDebug("{RequestMethod} {RequestPath}: Checking if matches with {TemplateMethod} {TemplatePath}.", httpMethod, path, route.HttpMethod, route.Path); - + // Must match HTTP method or be ANY if (!route.HttpMethod.Equals("ANY", StringComparison.InvariantCultureIgnoreCase) && !route.HttpMethod.Equals(httpMethod, StringComparison.InvariantCultureIgnoreCase)) @@ -202,7 +205,7 @@ private bool IsRouteConfigValid(ApiGatewayRouteConfig routeConfig) httpMethod, path); continue; } - + _logger.LogDebug("{RequestMethod} {RequestPath}: The HTTP method matches. Checking the route {TemplatePath}.", httpMethod, path, route.Path); @@ -229,10 +232,10 @@ private bool IsRouteConfigValid(ApiGatewayRouteConfig routeConfig) httpMethod, path); return null; } - + _logger.LogDebug("{RequestMethod} {RequestPath}: The following routes matched: {Routes}.", httpMethod, path, string.Join(", ", candidates.Select(x => x.Route.Path))); - + var best = candidates .OrderByDescending(c => c.LiteralMatches) .ThenByDescending(c => c.MatchedSegmentsBeforeGreedy) @@ -243,10 +246,10 @@ private bool IsRouteConfigValid(ApiGatewayRouteConfig routeConfig) _logger.LogDebug("{RequestMethod} {RequestPath}: Matched with the following route: {Routes}.", httpMethod, path, best.Route.Path); - + return best.Route; } - + /// /// Attempts to match a given request path against a route template. /// @@ -278,14 +281,14 @@ private bool IsRouteConfigValid(ApiGatewayRouteConfig routeConfig) /// /// private ( - bool Matched, - int LiteralMatches, - int VariableCount, - int GreedyCount, + bool Matched, + int LiteralMatches, + int VariableCount, + int GreedyCount, int MatchedSegmentsBeforeGreedy) MatchRoute(string[] routeSegments, string[] requestSegments) { - // Example scenario: + // Example scenario: // Route template: "/resource/{id}/subsegment/{proxy+}" // Request path: "/resource/123/subsegment/foo/bar" // Here, routeSegments are ["resource", "{id}", "subsegment", "{proxy+}"] @@ -303,8 +306,8 @@ private bool IsRouteConfigValid(ApiGatewayRouteConfig routeConfig) // First, we try to match segments one-by-one until we run out of one or both arrays while ( - matched && - routeTemplateIndex < routeSegments.Length && + matched && + routeTemplateIndex < routeSegments.Length && requestPathIndex < requestSegments.Length) { var routeTemplateSegment = routeSegments[routeTemplateIndex]; @@ -333,7 +336,7 @@ private bool IsRouteConfigValid(ApiGatewayRouteConfig routeConfig) encounteredGreedy = true; routeTemplateIndex++; // Consume all remaining request segments at once - requestPathIndex = requestSegments.Length; + requestPathIndex = requestSegments.Length; } } else @@ -370,7 +373,7 @@ private bool IsRouteConfigValid(ApiGatewayRouteConfig routeConfig) // If we exhaust the request before the route template (or vice versa), we must handle leftovers. // This happens, for example, if the route template still has segments to match but the request is shorter. - // Example scenario: + // Example scenario: // Route template: "/resource/{id}/{proxy+}" // Request path: "/resource/123" if (matched && routeTemplateIndex < routeSegments.Length) @@ -390,7 +393,7 @@ private bool IsRouteConfigValid(ApiGatewayRouteConfig routeConfig) return (matched, literalMatches, variableCount, greedyCount, matchedSegmentsBeforeGreedy); } - + /// /// Determines if a given segment represents a variable segment. /// @@ -449,4 +452,4 @@ private class MatchResult /// public int MatchedSegmentsBeforeGreedy { get; set; } } -} \ No newline at end of file +} diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/ConfigureStaticFilesOptions.cs b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/ConfigureStaticFilesOptions.cs index 7fc75af6e..cb7394ed9 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/ConfigureStaticFilesOptions.cs +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/ConfigureStaticFilesOptions.cs @@ -1,10 +1,13 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.Options; namespace Amazon.Lambda.TestTool.Services; /// -/// Configures static file options for the application by setting up a composite file provider +/// Configures static file options for the application by setting up a composite file provider /// that includes embedded resources from the assembly and the existing web root file provider. /// internal class ConfigureStaticFilesOptions(IWebHostEnvironment environment) @@ -29,4 +32,4 @@ public void PostConfigure(string? name, StaticFileOptions options) var fileProvider = new ManifestEmbeddedFileProvider(typeof(Program).Assembly, "wwwroot"); environment.WebRootFileProvider = new CompositeFileProvider(fileProvider, environment.WebRootFileProvider); } -} \ No newline at end of file +} diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/ConsoleInteractiveService.cs b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/ConsoleInteractiveService.cs index 0193b3fdd..52cccf3db 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/ConsoleInteractiveService.cs +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/ConsoleInteractiveService.cs @@ -1,24 +1,27 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + namespace Amazon.Lambda.TestTool.Services; -/// -/// Provides an implementation of that interacts with the console. +/// +/// Provides an implementation of that interacts with the console. /// public class ConsoleInteractiveService : IToolInteractiveService { - /// - /// Initializes a new instance of the class. + /// + /// Initializes a new instance of the class. /// public ConsoleInteractiveService() { Console.Title = Constants.ProductName; - } - + } + /// public void WriteLine(string? message) { Console.WriteLine(message); - } - + } + /// public void WriteErrorLine(string? message) { @@ -34,4 +37,4 @@ public void WriteErrorLine(string? message) Console.ForegroundColor = color; } } -} \ No newline at end of file +} diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/IApiGatewayRouteConfigService.cs b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/IApiGatewayRouteConfigService.cs index 17f7c72c2..002972df9 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/IApiGatewayRouteConfigService.cs +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/IApiGatewayRouteConfigService.cs @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + using Amazon.Lambda.TestTool.Models; namespace Amazon.Lambda.TestTool.Services; @@ -15,4 +18,4 @@ public interface IApiGatewayRouteConfigService /// An HTTP Path /// An corresponding to Lambda function with an API Gateway HTTP Method and Path. ApiGatewayRouteConfig? GetRouteConfig(string httpMethod, string path); -} \ No newline at end of file +} diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/IO/DirectoryManager.cs b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/IO/DirectoryManager.cs index c555ff342..51e5c66b7 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/IO/DirectoryManager.cs +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/IO/DirectoryManager.cs @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + namespace Amazon.Lambda.TestTool.Services.IO; /// @@ -5,4 +8,4 @@ public class DirectoryManager : IDirectoryManager { /// public string GetCurrentDirectory() => Directory.GetCurrentDirectory(); -} \ No newline at end of file +} diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/IO/EnvironmentManager.cs b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/IO/EnvironmentManager.cs index 1d04c496e..4261b9330 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/IO/EnvironmentManager.cs +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/IO/EnvironmentManager.cs @@ -1,10 +1,13 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + using System.Collections; namespace Amazon.Lambda.TestTool.Services.IO; /// public class EnvironmentManager : IEnvironmentManager -{ +{ /// public IDictionary GetEnvironmentVariables() => Environment.GetEnvironmentVariables(); -} \ No newline at end of file +} diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/IO/IDirectoryManager.cs b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/IO/IDirectoryManager.cs index 0957a7770..ced587114 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/IO/IDirectoryManager.cs +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/IO/IDirectoryManager.cs @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + namespace Amazon.Lambda.TestTool.Services.IO; /// @@ -10,4 +13,4 @@ public interface IDirectoryManager /// /// The full path of the current working directory. string GetCurrentDirectory(); -} \ No newline at end of file +} diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/IO/IEnvironmentManager.cs b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/IO/IEnvironmentManager.cs index 3c4332f1a..76de79981 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/IO/IEnvironmentManager.cs +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/IO/IEnvironmentManager.cs @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + using System.Collections; namespace Amazon.Lambda.TestTool.Services.IO; @@ -11,4 +14,4 @@ public interface IEnvironmentManager /// Retrieves all environment variables for the current process. /// IDictionary GetEnvironmentVariables(); -} \ No newline at end of file +} diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/IToolInteractiveService.cs b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/IToolInteractiveService.cs index c2166565f..085afb808 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/IToolInteractiveService.cs +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/IToolInteractiveService.cs @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + namespace Amazon.Lambda.TestTool.Services; /// @@ -16,4 +19,4 @@ public interface IToolInteractiveService /// /// The error message to write. If null, a blank line is written to the error output. void WriteErrorLine(string? message); -} \ No newline at end of file +} diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/LambdaRuntimeAPI.cs b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/LambdaRuntimeAPI.cs index 77bf0e557..3fc0ccfcc 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/LambdaRuntimeAPI.cs +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/LambdaRuntimeAPI.cs @@ -1,4 +1,7 @@ -using System.Text; +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +using System.Text; using Amazon.Lambda.TestTool.Models; using Microsoft.AspNetCore.Mvc; @@ -141,4 +144,4 @@ internal class StatusResponse { [System.Text.Json.Serialization.JsonPropertyName("status")] public required string Status { get; init; } -} \ No newline at end of file +} diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/RuntimeApiDataStore.cs b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/RuntimeApiDataStore.cs index d8688d0d0..7b2172b30 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/RuntimeApiDataStore.cs +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/RuntimeApiDataStore.cs @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + using Amazon.Lambda.TestTool.Models; using System.Collections.ObjectModel; @@ -6,9 +9,9 @@ namespace Amazon.Lambda.TestTool.Services; public interface IRuntimeApiDataStore { EventContainer QueueEvent(string eventBody); - + IReadOnlyList QueuedEvents { get; } - + IReadOnlyList ExecutedEvents { get; } void ClearQueued(); @@ -34,9 +37,9 @@ public class RuntimeApiDataStore : IRuntimeApiDataStore private IList _executedEvents = new List(); private int _eventCounter = 1; private object _lock = new object(); - + public event EventHandler? StateChange; - + public EventContainer QueueEvent(string eventBody) { var evnt = new EventContainer(this, _eventCounter++, eventBody); @@ -44,7 +47,7 @@ public EventContainer QueueEvent(string eventBody) { _queuedEvents.Add(evnt); } - + RaiseStateChanged(); return evnt; } @@ -77,7 +80,7 @@ public bool TryActivateEvent(out EventContainer? activeEvent) return true; } } - + public EventContainer? ActiveEvent { get; private set; } public IReadOnlyList QueuedEvents @@ -86,7 +89,7 @@ public IReadOnlyList QueuedEvents { lock(_lock) { - return new ReadOnlyCollection(_queuedEvents.ToArray()); + return new ReadOnlyCollection(_queuedEvents.ToArray()); } } } @@ -111,7 +114,7 @@ public void ReportSuccess(string awsRequestId, string response) { return; } - + evnt.ReportSuccessResponse(response); } RaiseStateChanged(); @@ -126,7 +129,7 @@ public void ReportError(string awsRequestId, string errorType, string errorBody) { return; } - + evnt.ReportErrorResponse(errorType, errorBody); } RaiseStateChanged(); @@ -136,7 +139,7 @@ public void ClearQueued() { lock(_lock) { - this._queuedEvents.Clear(); + _queuedEvents.Clear(); } RaiseStateChanged(); } @@ -145,7 +148,7 @@ public void ClearExecuted() { lock(_lock) { - this._executedEvents.Clear(); + _executedEvents.Clear(); } RaiseStateChanged(); } @@ -154,17 +157,17 @@ public void DeleteEvent(string awsRequestId) { lock(_lock) { - var executedEvent = this._executedEvents.FirstOrDefault(x => string.Equals(x.AwsRequestId, awsRequestId)); + var executedEvent = _executedEvents.FirstOrDefault(x => string.Equals(x.AwsRequestId, awsRequestId)); if (executedEvent != null) { - this._executedEvents.Remove(executedEvent); + _executedEvents.Remove(executedEvent); } else { - executedEvent = this._queuedEvents.FirstOrDefault(x => string.Equals(x.AwsRequestId, awsRequestId)); + executedEvent = _queuedEvents.FirstOrDefault(x => string.Equals(x.AwsRequestId, awsRequestId)); if (executedEvent != null) { - this._queuedEvents.Remove(executedEvent); + _queuedEvents.Remove(executedEvent); } } } @@ -173,9 +176,9 @@ public void DeleteEvent(string awsRequestId) private EventContainer? FindEventContainer(string awsRequestId) { - if (string.Equals(this.ActiveEvent?.AwsRequestId, awsRequestId)) + if (string.Equals(ActiveEvent?.AwsRequestId, awsRequestId)) { - return this.ActiveEvent; + return ActiveEvent; } var evnt = _executedEvents.FirstOrDefault(x => string.Equals(x.AwsRequestId, awsRequestId)); @@ -194,4 +197,4 @@ internal void RaiseStateChanged() var handler = StateChange; handler?.Invoke(this, EventArgs.Empty); } -} \ No newline at end of file +} diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/TypeRegistrar.cs b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/TypeRegistrar.cs index f0dcf6dbd..00953e13a 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/TypeRegistrar.cs +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/TypeRegistrar.cs @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + using Spectre.Console.Cli; namespace Amazon.Lambda.TestTool.Services; @@ -11,20 +14,20 @@ public sealed class TypeRegistrar(IServiceCollection builder) : ITypeRegistrar public ITypeResolver Build() { return new TypeResolver(builder.BuildServiceProvider()); - } - + } + /// public void Register(Type service, Type implementation) { builder.AddSingleton(service, implementation); - } - + } + /// public void RegisterInstance(Type service, object implementation) { builder.AddSingleton(service, implementation); - } - + } + /// public void RegisterLazy(Type service, Func func) { @@ -35,4 +38,4 @@ public void RegisterLazy(Type service, Func func) builder.AddSingleton(service, (provider) => func()); } -} \ No newline at end of file +} diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/TypeResolver.cs b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/TypeResolver.cs index 5c3159c7d..2d6ab7a2e 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/TypeResolver.cs +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Services/TypeResolver.cs @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + using Spectre.Console.Cli; namespace Amazon.Lambda.TestTool.Services; @@ -7,8 +10,8 @@ namespace Amazon.Lambda.TestTool.Services; /// public sealed class TypeResolver(IServiceProvider provider) : ITypeResolver, IDisposable { - private readonly IServiceProvider _provider = provider ?? throw new ArgumentNullException(nameof(provider)); - + private readonly IServiceProvider _provider = provider ?? throw new ArgumentNullException(nameof(provider)); + /// public object? Resolve(Type? type) { @@ -18,8 +21,8 @@ public sealed class TypeResolver(IServiceProvider provider) : ITypeResolver, IDi } return _provider.GetService(type); - } - + } + /// public void Dispose() { @@ -28,4 +31,4 @@ public void Dispose() disposable.Dispose(); } } -} \ No newline at end of file +} diff --git a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Utilities/Utils.cs b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Utilities/Utils.cs index 2f9cd6ab7..700588009 100644 --- a/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Utilities/Utils.cs +++ b/Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Utilities/Utils.cs @@ -1,15 +1,18 @@ -using System.Reflection; +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +using System.Reflection; using System.Text.Json; namespace Amazon.Lambda.TestTool.Utilities; -/// -/// A utility class that encapsulates common functionlity. +/// +/// A utility class that encapsulates common functionlity. /// public static class Utils { - /// - /// Determines the version of the tool. + /// + /// Determines the version of the tool. /// public static string DetermineToolVersion() { diff --git a/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/Commands/RunCommandTests.cs b/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/Commands/RunCommandTests.cs index 2d262b667..000709236 100644 --- a/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/Commands/RunCommandTests.cs +++ b/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/Commands/RunCommandTests.cs @@ -1,4 +1,7 @@ -using Amazon.Lambda.TestTool.Commands.Settings; +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +using Amazon.Lambda.TestTool.Commands.Settings; using Amazon.Lambda.TestTool.Commands; using Amazon.Lambda.TestTool.Models; using Amazon.Lambda.TestTool.Services; @@ -56,4 +59,4 @@ public async Task ExecuteAsync_ApiGatewayEmulator_SuccessfulLaunch() Assert.Equal(CommandReturnCodes.Success, result); Assert.True(isApiRunning); } -} \ No newline at end of file +} diff --git a/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/Commands/Settings/RunCommandSettingsTests.cs b/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/Commands/Settings/RunCommandSettingsTests.cs index dd82f4ed9..f4502ae5e 100644 --- a/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/Commands/Settings/RunCommandSettingsTests.cs +++ b/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/Commands/Settings/RunCommandSettingsTests.cs @@ -1,4 +1,7 @@ -using Amazon.Lambda.TestTool.Commands.Settings; +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +using Amazon.Lambda.TestTool.Commands.Settings; namespace Amazon.Lambda.TestTool.UnitTests.Commands.Settings; @@ -73,4 +76,4 @@ public void ApiGatewayEmulatorMode_DefaultsToNull() // Assert Assert.Null(settings.ApiGatewayEmulatorMode); } -} \ No newline at end of file +} diff --git a/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/Helpers/TestHelpers.cs b/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/Helpers/TestHelpers.cs index fd46e9bf7..578379453 100644 --- a/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/Helpers/TestHelpers.cs +++ b/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/Helpers/TestHelpers.cs @@ -1,4 +1,7 @@ -namespace Amazon.Lambda.TestTool.UnitTests.Helpers; +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +namespace Amazon.Lambda.TestTool.UnitTests.Helpers; internal static class TestHelpers { diff --git a/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/RuntimeApiTests.cs b/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/RuntimeApiTests.cs index 68bed10d7..d9346e0c2 100644 --- a/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/RuntimeApiTests.cs +++ b/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/RuntimeApiTests.cs @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + using Amazon.Runtime; using Amazon.Lambda.Model; using Amazon.Lambda.TestTool.Services; @@ -71,4 +74,4 @@ private IAmazonLambda ConstructLambdaServiceClient(string url) var credentials = new BasicAWSCredentials("accessKeyId", "secretKey"); return new AmazonLambdaClient(credentials, config); } -} \ No newline at end of file +} diff --git a/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/Services/ApiGatewayRouteConfigServiceTests.cs b/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/Services/ApiGatewayRouteConfigServiceTests.cs index 2a838646a..633b04b28 100644 --- a/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/Services/ApiGatewayRouteConfigServiceTests.cs +++ b/Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.UnitTests/Services/ApiGatewayRouteConfigServiceTests.cs @@ -1,3 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + using System.Text.Json; using Amazon.Lambda.TestTool.Models; using Amazon.Lambda.TestTool.Services; @@ -169,7 +172,7 @@ public void CatchAllRouteConfig() Path = "/{proxy+}" } }; - + _mockEnvironmentManager .Setup(m => m.GetEnvironmentVariables()) .Returns(new Dictionary @@ -178,7 +181,7 @@ public void CatchAllRouteConfig() }); var service = new ApiGatewayRouteConfigService(_mockEnvironmentManager.Object, _mockLogger.Object); - + // Act var result1 = service.GetRouteConfig("GET", "/a"); var result2 = service.GetRouteConfig("POST", "/b"); @@ -188,7 +191,7 @@ public void CatchAllRouteConfig() var result6 = service.GetRouteConfig("DELETE", "/c/1/d"); var result7 = service.GetRouteConfig("GET", "/a/a/a/a/a/a/a/a/a/a"); var result8 = service.GetRouteConfig("GET", "/"); - + // Assert Assert.Equal("F1", result1?.LambdaResourceName); Assert.Equal("F1", result2?.LambdaResourceName); @@ -213,7 +216,7 @@ public void RouteConfigTemplateLongerThanRequest() Path = "/resource/{id}/{proxy+}" } }; - + _mockEnvironmentManager .Setup(m => m.GetEnvironmentVariables()) .Returns(new Dictionary @@ -222,10 +225,10 @@ public void RouteConfigTemplateLongerThanRequest() }); var service = new ApiGatewayRouteConfigService(_mockEnvironmentManager.Object, _mockLogger.Object); - + // Act var result1 = service.GetRouteConfig("GET", "/resource/123"); - + // Assert Assert.Null(result1); } @@ -243,7 +246,7 @@ public void RouteConfigRequestLongerThanTemplate() Path = "/resource/{id}" } }; - + _mockEnvironmentManager .Setup(m => m.GetEnvironmentVariables()) .Returns(new Dictionary @@ -252,10 +255,10 @@ public void RouteConfigRequestLongerThanTemplate() }); var service = new ApiGatewayRouteConfigService(_mockEnvironmentManager.Object, _mockLogger.Object); - + // Act var result1 = service.GetRouteConfig("GET", "/resource/123/foo"); - + // Assert Assert.Null(result1); } @@ -333,7 +336,7 @@ public void ProperlyMatchRouteConfigs() Path = "/resource/1/subsegment/3/{proxy+}" } }; - + _mockEnvironmentManager .Setup(m => m.GetEnvironmentVariables()) .Returns(new Dictionary @@ -365,7 +368,7 @@ public void ProperlyMatchRouteConfigs() var result19 = service.GetRouteConfig("GET", "/pe"); var result20 = service.GetRouteConfig("GET", "/"); var result21 = service.GetRouteConfig("GET", ""); - + // Assert Assert.Equal("F8", result1?.LambdaResourceName); Assert.Equal("F7", result2?.LambdaResourceName); @@ -389,4 +392,4 @@ public void ProperlyMatchRouteConfigs() Assert.Equal("F1", result20?.LambdaResourceName); Assert.Equal("F1", result21?.LambdaResourceName); } -} \ No newline at end of file +}