Skip to content

Commit b4cd801

Browse files
committed
First set of PR comments
1 parent 8cfbc0a commit b4cd801

17 files changed

+866
-707
lines changed

Tools/LambdaTestTool-v2/Amazon.Lambda.TestTool.sln

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35527.113
5+
MinimumVisualStudioVersion = 10.0.40219.1
36
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{827E0CD3-B72D-47B6-A68D-7590B98EB39B}"
47
EndProject
58
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Amazon.Lambda.TestTool", "src\Amazon.Lambda.TestTool\Amazon.Lambda.TestTool.csproj", "{97EE2E8A-D1F4-CB11-B664-B99B036E9F7B}"
@@ -8,6 +11,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{0AB3BF05
811
EndProject
912
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}"
1013
EndProject
14+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Amazon.Lambda.TestTool.IntegrationTests", "tests\Amazon.Lambda.TestTool.IntegrationTests\Amazon.Lambda.TestTool.IntegrationTests.csproj", "{5C1B3E1C-DFEA-425B-8ED2-BB43BAECC3CB}"
15+
EndProject
1116
Global
1217
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1318
Debug|Any CPU = Debug|Any CPU
@@ -22,6 +27,13 @@ Global
2227
{80A4F809-28B7-61EC-6539-DF3C7A0733FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
2328
{80A4F809-28B7-61EC-6539-DF3C7A0733FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
2429
{80A4F809-28B7-61EC-6539-DF3C7A0733FD}.Release|Any CPU.Build.0 = Release|Any CPU
30+
{5C1B3E1C-DFEA-425B-8ED2-BB43BAECC3CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31+
{5C1B3E1C-DFEA-425B-8ED2-BB43BAECC3CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
32+
{5C1B3E1C-DFEA-425B-8ED2-BB43BAECC3CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
33+
{5C1B3E1C-DFEA-425B-8ED2-BB43BAECC3CB}.Release|Any CPU.Build.0 = Release|Any CPU
34+
EndGlobalSection
35+
GlobalSection(SolutionProperties) = preSolution
36+
HideSolutionNode = FALSE
2537
EndGlobalSection
2638
GlobalSection(NestedProjects) = preSolution
2739
{97EE2E8A-D1F4-CB11-B664-B99B036E9F7B} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}

Tools/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Extensions/ApiGatewayResponseExtensions.cs

Lines changed: 57 additions & 110 deletions
Large diffs are not rendered by default.

Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.IntegrationTests/Amazon.Lambda.TestTool.IntegrationTests.csproj

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>net8.0</TargetFramework>
@@ -12,7 +12,8 @@
1212
<ItemGroup>
1313
<PackageReference Include="Amazon.Lambda.APIGatewayEvents" Version="2.7.1" />
1414
<PackageReference Include="AWSSDK.APIGateway" Version="3.7.401.7" />
15-
<PackageReference Include="AWSSDK.IdentityManagement" Version="3.7.401.7" />
15+
<PackageReference Include="AWSSDK.CloudFormation" Version="3.7.401.11" />
16+
<PackageReference Include="AWSSDK.IdentityManagement" Version="3.7.402" />
1617
<PackageReference Include="AWSSDK.ApiGatewayV2" Version="3.7.400.63" />
1718
<PackageReference Include="AWSSDK.Lambda" Version="3.7.408.1" />
1819
<PackageReference Include="coverlet.collector" Version="6.0.0" />
@@ -27,8 +28,13 @@
2728
<ProjectReference Include="..\..\src\Amazon.Lambda.TestTool\Amazon.Lambda.TestTool.csproj" />
2829
<ProjectReference Include="..\Amazon.Lambda.TestTool.UnitTests\Amazon.Lambda.TestTool.UnitTests.csproj" />
2930
</ItemGroup>
30-
31-
<ItemGroup>
31+
32+
<ItemGroup>
33+
<EmbeddedResource Include="cloudformation-template-apigateway.yaml" />
34+
</ItemGroup>
35+
36+
37+
<ItemGroup>
3238
<Using Include="Xunit" />
3339
</ItemGroup>
3440

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.5.002.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Amazon.Lambda.TestTool.IntegrationTests", "Amazon.Lambda.TestTool.IntegrationTests.csproj", "{94C7903E-A21A-43EC-BB04-C9DA404F1C02}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{94C7903E-A21A-43EC-BB04-C9DA404F1C02}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{94C7903E-A21A-43EC-BB04-C9DA404F1C02}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{94C7903E-A21A-43EC-BB04-C9DA404F1C02}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{94C7903E-A21A-43EC-BB04-C9DA404F1C02}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {429CE21F-1692-4C50-A9E6-299AB413D027}
24+
EndGlobalSection
25+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
namespace Amazon.Lambda.TestTool.IntegrationTests
5+
{
6+
[CollectionDefinition("ApiGateway Integration Tests")]
7+
public class ApiGatewayIntegrationTestCollection : ICollectionFixture<ApiGatewayIntegrationTestFixture>
8+
{
9+
10+
}
11+
}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
using Amazon.CloudFormation;
5+
using Amazon.APIGateway;
6+
using Amazon.ApiGatewayV2;
7+
using Amazon.Lambda.TestTool.IntegrationTests.Helpers;
8+
using System.Reflection;
9+
10+
namespace Amazon.Lambda.TestTool.IntegrationTests
11+
{
12+
public class ApiGatewayIntegrationTestFixture : IAsyncLifetime
13+
{
14+
public CloudFormationHelper CloudFormationHelper { get; private set; }
15+
public ApiGatewayHelper ApiGatewayHelper { get; private set; }
16+
public ApiGatewayTestHelper ApiGatewayTestHelper { get; private set; }
17+
18+
public string StackName { get; private set; }
19+
public string RestApiId { get; private set; }
20+
public string HttpApiV1Id { get; private set; }
21+
public string HttpApiV2Id { get; private set; }
22+
public string ReturnRawRequestBodyV2Id { get; private set; }
23+
public string RestApiUrl { get; private set; }
24+
public string HttpApiV1Url { get; private set; }
25+
public string HttpApiV2Url { get; private set; }
26+
public string ReturnRawRequestBodyHttpApiV2Url { get; private set; }
27+
28+
public ApiGatewayIntegrationTestFixture()
29+
{
30+
var regionEndpoint = RegionEndpoint.USWest2;
31+
CloudFormationHelper = new CloudFormationHelper(new AmazonCloudFormationClient(regionEndpoint));
32+
ApiGatewayHelper = new ApiGatewayHelper(
33+
new AmazonAPIGatewayClient(regionEndpoint),
34+
new AmazonApiGatewayV2Client(regionEndpoint)
35+
);
36+
ApiGatewayTestHelper = new ApiGatewayTestHelper();
37+
StackName = string.Empty;
38+
RestApiId = string.Empty;
39+
HttpApiV1Id = string.Empty;
40+
HttpApiV2Id = string.Empty;
41+
ReturnRawRequestBodyV2Id = string.Empty;
42+
RestApiUrl = string.Empty;
43+
HttpApiV1Url = string.Empty;
44+
HttpApiV2Url = string.Empty;
45+
ReturnRawRequestBodyHttpApiV2Url = string.Empty;
46+
}
47+
48+
public async Task InitializeAsync()
49+
{
50+
StackName = $"Test-{Guid.NewGuid().ToString("N").Substring(0, 5)}";
51+
52+
string templateBody = ReadCloudFormationTemplate("cloudformation-template-apigateway.yaml");
53+
await CloudFormationHelper.CreateStackAsync(StackName, templateBody);
54+
55+
await WaitForStackCreationComplete();
56+
await RetrieveStackOutputs();
57+
await WaitForApisAvailability();
58+
}
59+
60+
private string ReadCloudFormationTemplate(string fileName)
61+
{
62+
var assembly = Assembly.GetExecutingAssembly();
63+
var resourceName = $"{assembly.GetName().Name}.{fileName}";
64+
using (var stream = assembly.GetManifestResourceStream(resourceName))
65+
{
66+
if (stream == null)
67+
{
68+
throw new FileNotFoundException($"CloudFormation template file '{fileName}' not found in assembly resources.");
69+
}
70+
71+
using (StreamReader reader = new StreamReader(stream))
72+
{
73+
return reader.ReadToEnd();
74+
}
75+
}
76+
}
77+
78+
private async Task WaitForStackCreationComplete()
79+
{
80+
while (true)
81+
{
82+
var status = await CloudFormationHelper.GetStackStatusAsync(StackName);
83+
if (status == StackStatus.CREATE_COMPLETE)
84+
{
85+
break;
86+
}
87+
if (status.ToString().EndsWith("FAILED") || status == StackStatus.DELETE_COMPLETE)
88+
{
89+
throw new Exception($"Stack creation failed. Status: {status}");
90+
}
91+
await Task.Delay(10000);
92+
}
93+
}
94+
95+
private async Task RetrieveStackOutputs()
96+
{
97+
RestApiId = await CloudFormationHelper.GetOutputValueAsync(StackName, "RestApiId");
98+
RestApiUrl = await CloudFormationHelper.GetOutputValueAsync(StackName, "RestApiUrl");
99+
100+
HttpApiV1Id = await CloudFormationHelper.GetOutputValueAsync(StackName, "HttpApiV1Id");
101+
HttpApiV1Url = await CloudFormationHelper.GetOutputValueAsync(StackName, "HttpApiV1Url");
102+
103+
HttpApiV2Id = await CloudFormationHelper.GetOutputValueAsync(StackName, "HttpApiV2Id");
104+
HttpApiV2Url = await CloudFormationHelper.GetOutputValueAsync(StackName, "HttpApiV2Url");
105+
106+
ReturnRawRequestBodyV2Id = await CloudFormationHelper.GetOutputValueAsync(StackName, "ReturnRawRequestBodyHttpApiId");
107+
ReturnRawRequestBodyHttpApiV2Url = await CloudFormationHelper.GetOutputValueAsync(StackName, "ReturnRawRequestBodyHttpApiUrl");
108+
}
109+
110+
private async Task WaitForApisAvailability()
111+
{
112+
await ApiGatewayHelper.WaitForApiAvailability(RestApiId, RestApiUrl, false);
113+
await ApiGatewayHelper.WaitForApiAvailability(HttpApiV1Id, HttpApiV1Url, true);
114+
await ApiGatewayHelper.WaitForApiAvailability(HttpApiV2Id, HttpApiV2Url, true);
115+
await ApiGatewayHelper.WaitForApiAvailability(ReturnRawRequestBodyV2Id, ReturnRawRequestBodyHttpApiV2Url, true);
116+
}
117+
118+
public async Task DisposeAsync()
119+
{
120+
await CloudFormationHelper.DeleteStackAsync(StackName);
121+
}
122+
}
123+
}

Tools/LambdaTestTool-v2/tests/Amazon.Lambda.TestTool.IntegrationTests/ApiGatewayResponseExtensionsJsonInference.cs

Lines changed: 0 additions & 115 deletions
This file was deleted.

0 commit comments

Comments
 (0)