-
Notifications
You must be signed in to change notification settings - Fork 481
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8cfbc0a
commit b4cd801
Showing
17 changed files
with
866 additions
and
707 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
167 changes: 57 additions & 110 deletions
167
...s/LambdaTestTool-v2/src/Amazon.Lambda.TestTool/Extensions/ApiGatewayResponseExtensions.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...tests/Amazon.Lambda.TestTool.IntegrationTests/Amazon.Lambda.TestTool.IntegrationTests.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.5.002.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Amazon.Lambda.TestTool.IntegrationTests", "Amazon.Lambda.TestTool.IntegrationTests.csproj", "{94C7903E-A21A-43EC-BB04-C9DA404F1C02}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{94C7903E-A21A-43EC-BB04-C9DA404F1C02}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{94C7903E-A21A-43EC-BB04-C9DA404F1C02}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{94C7903E-A21A-43EC-BB04-C9DA404F1C02}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{94C7903E-A21A-43EC-BB04-C9DA404F1C02}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {429CE21F-1692-4C50-A9E6-299AB413D027} | ||
EndGlobalSection | ||
EndGlobal |
11 changes: 11 additions & 0 deletions
11
...l-v2/tests/Amazon.Lambda.TestTool.IntegrationTests/ApiGatewayIntegrationTestCollection.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
namespace Amazon.Lambda.TestTool.IntegrationTests | ||
{ | ||
[CollectionDefinition("ApiGateway Integration Tests")] | ||
public class ApiGatewayIntegrationTestCollection : ICollectionFixture<ApiGatewayIntegrationTestFixture> | ||
{ | ||
|
||
} | ||
} |
123 changes: 123 additions & 0 deletions
123
...Tool-v2/tests/Amazon.Lambda.TestTool.IntegrationTests/ApiGatewayIntegrationTestFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
using Amazon.CloudFormation; | ||
using Amazon.APIGateway; | ||
using Amazon.ApiGatewayV2; | ||
using Amazon.Lambda.TestTool.IntegrationTests.Helpers; | ||
using System.Reflection; | ||
|
||
namespace Amazon.Lambda.TestTool.IntegrationTests | ||
{ | ||
public class ApiGatewayIntegrationTestFixture : IAsyncLifetime | ||
{ | ||
public CloudFormationHelper CloudFormationHelper { get; private set; } | ||
public ApiGatewayHelper ApiGatewayHelper { get; private set; } | ||
public ApiGatewayTestHelper ApiGatewayTestHelper { get; private set; } | ||
|
||
public string StackName { get; private set; } | ||
public string RestApiId { get; private set; } | ||
public string HttpApiV1Id { get; private set; } | ||
public string HttpApiV2Id { get; private set; } | ||
public string ReturnRawRequestBodyV2Id { get; private set; } | ||
public string RestApiUrl { get; private set; } | ||
public string HttpApiV1Url { get; private set; } | ||
public string HttpApiV2Url { get; private set; } | ||
public string ReturnRawRequestBodyHttpApiV2Url { get; private set; } | ||
|
||
public ApiGatewayIntegrationTestFixture() | ||
{ | ||
var regionEndpoint = RegionEndpoint.USWest2; | ||
CloudFormationHelper = new CloudFormationHelper(new AmazonCloudFormationClient(regionEndpoint)); | ||
ApiGatewayHelper = new ApiGatewayHelper( | ||
new AmazonAPIGatewayClient(regionEndpoint), | ||
new AmazonApiGatewayV2Client(regionEndpoint) | ||
); | ||
ApiGatewayTestHelper = new ApiGatewayTestHelper(); | ||
StackName = string.Empty; | ||
RestApiId = string.Empty; | ||
HttpApiV1Id = string.Empty; | ||
HttpApiV2Id = string.Empty; | ||
ReturnRawRequestBodyV2Id = string.Empty; | ||
RestApiUrl = string.Empty; | ||
HttpApiV1Url = string.Empty; | ||
HttpApiV2Url = string.Empty; | ||
ReturnRawRequestBodyHttpApiV2Url = string.Empty; | ||
} | ||
|
||
public async Task InitializeAsync() | ||
{ | ||
StackName = $"Test-{Guid.NewGuid().ToString("N").Substring(0, 5)}"; | ||
|
||
string templateBody = ReadCloudFormationTemplate("cloudformation-template-apigateway.yaml"); | ||
await CloudFormationHelper.CreateStackAsync(StackName, templateBody); | ||
|
||
await WaitForStackCreationComplete(); | ||
await RetrieveStackOutputs(); | ||
await WaitForApisAvailability(); | ||
} | ||
|
||
private string ReadCloudFormationTemplate(string fileName) | ||
{ | ||
var assembly = Assembly.GetExecutingAssembly(); | ||
var resourceName = $"{assembly.GetName().Name}.{fileName}"; | ||
using (var stream = assembly.GetManifestResourceStream(resourceName)) | ||
{ | ||
if (stream == null) | ||
{ | ||
throw new FileNotFoundException($"CloudFormation template file '{fileName}' not found in assembly resources."); | ||
} | ||
|
||
using (StreamReader reader = new StreamReader(stream)) | ||
{ | ||
return reader.ReadToEnd(); | ||
} | ||
} | ||
} | ||
|
||
private async Task WaitForStackCreationComplete() | ||
{ | ||
while (true) | ||
{ | ||
var status = await CloudFormationHelper.GetStackStatusAsync(StackName); | ||
if (status == StackStatus.CREATE_COMPLETE) | ||
{ | ||
break; | ||
} | ||
if (status.ToString().EndsWith("FAILED") || status == StackStatus.DELETE_COMPLETE) | ||
{ | ||
throw new Exception($"Stack creation failed. Status: {status}"); | ||
} | ||
await Task.Delay(10000); | ||
} | ||
} | ||
|
||
private async Task RetrieveStackOutputs() | ||
{ | ||
RestApiId = await CloudFormationHelper.GetOutputValueAsync(StackName, "RestApiId"); | ||
RestApiUrl = await CloudFormationHelper.GetOutputValueAsync(StackName, "RestApiUrl"); | ||
|
||
HttpApiV1Id = await CloudFormationHelper.GetOutputValueAsync(StackName, "HttpApiV1Id"); | ||
HttpApiV1Url = await CloudFormationHelper.GetOutputValueAsync(StackName, "HttpApiV1Url"); | ||
|
||
HttpApiV2Id = await CloudFormationHelper.GetOutputValueAsync(StackName, "HttpApiV2Id"); | ||
HttpApiV2Url = await CloudFormationHelper.GetOutputValueAsync(StackName, "HttpApiV2Url"); | ||
|
||
ReturnRawRequestBodyV2Id = await CloudFormationHelper.GetOutputValueAsync(StackName, "ReturnRawRequestBodyHttpApiId"); | ||
ReturnRawRequestBodyHttpApiV2Url = await CloudFormationHelper.GetOutputValueAsync(StackName, "ReturnRawRequestBodyHttpApiUrl"); | ||
} | ||
|
||
private async Task WaitForApisAvailability() | ||
{ | ||
await ApiGatewayHelper.WaitForApiAvailability(RestApiId, RestApiUrl, false); | ||
await ApiGatewayHelper.WaitForApiAvailability(HttpApiV1Id, HttpApiV1Url, true); | ||
await ApiGatewayHelper.WaitForApiAvailability(HttpApiV2Id, HttpApiV2Url, true); | ||
await ApiGatewayHelper.WaitForApiAvailability(ReturnRawRequestBodyV2Id, ReturnRawRequestBodyHttpApiV2Url, true); | ||
} | ||
|
||
public async Task DisposeAsync() | ||
{ | ||
await CloudFormationHelper.DeleteStackAsync(StackName); | ||
} | ||
} | ||
} |
115 changes: 0 additions & 115 deletions
115
...ests/Amazon.Lambda.TestTool.IntegrationTests/ApiGatewayResponseExtensionsJsonInference.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.