Update resource mapping schema to make default account ID optional (#5475)

Signed-off-by: Stanko <stankoa@amazon.com>
This commit is contained in:
allisaurus
2021-11-15 14:48:32 -08:00
committed by GitHub
parent 8b7e538dd3
commit e1fb2ad368
5 changed files with 161 additions and 1 deletions
@@ -59,6 +59,34 @@ R"({
"Version": "1.0.0"
})";
static constexpr const char TEST_VALID_EMPTY_ACCOUNTID_RESOURCE_MAPPING_CONFIG_FILE[] =
R"({
"AWSResourceMappings": {
"TestLambda": {
"Type": "AWS::Lambda::Function",
"Name/ID": "MyTestLambda",
"Region": "us-east-1",
"AccountId": "012345678912"
},
"TestS3Bucket": {
"Type": "AWS::S3::Bucket",
"Name/ID": "MyTestS3Bucket"
},
"TestService.RESTApiId": {
"Type": "AWS::ApiGateway::RestApi",
"Name/ID": "1234567890"
},
"TestService.RESTApiStage": {
"Type": "AWS::ApiGateway::Stage",
"Name/ID": "prod",
"Region": "us-east-1"
}
},
"AccountId": "",
"Region": "us-west-2",
"Version": "1.0.0"
})";
static constexpr const char TEST_INVALID_RESOURCE_MAPPING_CONFIG_FILE[] =
R"({
"AWSResourceMappings": {},
@@ -237,6 +265,21 @@ TEST_F(AWSResourceMappingManagerTest, ActivateManager_ParseValidConfigFile_Confi
EXPECT_TRUE(actualEbusCalls == testThreadNumber);
}
TEST_F(AWSResourceMappingManagerTest, ActivateManager_ParseValidConfigFile_GlobalAccountIdEmpty)
{
CreateTestConfigFile(TEST_VALID_EMPTY_ACCOUNTID_RESOURCE_MAPPING_CONFIG_FILE);
m_resourceMappingManager->ActivateManager();
AZStd::string actualAccountId;
AZStd::string actualRegion;
AWSResourceMappingRequestBus::BroadcastResult(actualAccountId, &AWSResourceMappingRequests::GetDefaultAccountId);
AWSResourceMappingRequestBus::BroadcastResult(actualRegion, &AWSResourceMappingRequests::GetDefaultRegion);
EXPECT_EQ(m_reloadConfigurationCounter, 0);
EXPECT_TRUE(actualAccountId.empty());
EXPECT_FALSE(actualRegion.empty());
EXPECT_TRUE(m_resourceMappingManager->GetStatus() == AWSResourceMappingManager::Status::Ready);
}
TEST_F(AWSResourceMappingManagerTest, DeactivateManager_AfterActivatingWithValidConfigFile_ConfigDataGetCleanedUp)
{
CreateTestConfigFile(TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE);