Merge AWSCore automation tests to the development branch (#2011)
* Create AWS Core automation for the interacting with AWS resources via the AWS Core gem. Signed-off-by: junbo <junbo@amazon.com> Co-authored-by: clujames <clujames@amazon.com>
This commit is contained in:
@@ -72,7 +72,7 @@ namespace AWSCore
|
||||
{
|
||||
static constexpr const char AWSScriptBehaviorS3Name[] = "AWSScriptBehaviorS3";
|
||||
static constexpr const char OutputFileIsEmptyErrorMessage[] = "Request validation failed, output file is empty.";
|
||||
static constexpr const char OutputFileMissFullPathErrorMessage[] = "Request validation failed, output file miss full path.";
|
||||
static constexpr const char OutputFileFailedToResolveErrorMessage[] = "Request validation failed, cannot resolve the output file path.";
|
||||
static constexpr const char OutputFileIsDirectoryErrorMessage[] = "Request validation failed, output file is a directory.";
|
||||
static constexpr const char OutputFileDirectoryNotExistErrorMessage[] = "Request validation failed, output file directory doesn't exist.";
|
||||
static constexpr const char OutputFileIsReadOnlyErrorMessage[] = "Request validation failed, output file is read-only.";
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include <AzCore/IO/FileIO.h>
|
||||
#include <AzCore/IO/SystemFile.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzFramework/StringFunc/StringFunc.h>
|
||||
@@ -171,12 +172,16 @@ namespace AWSCore
|
||||
AWSScriptBehaviorS3NotificationBus::Broadcast(notificationFunc, OutputFileIsEmptyErrorMessage);
|
||||
return false;
|
||||
}
|
||||
if (!AzFramework::StringFunc::Path::HasDrive(outFile.c_str()))
|
||||
|
||||
char resolvedPath[AZ_MAX_PATH_LEN] = { 0 };
|
||||
if (!AZ::IO::FileIOBase::GetInstance()->ResolvePath(outFile.c_str(), resolvedPath, AZ_MAX_PATH_LEN))
|
||||
{
|
||||
AZ_Warning(AWSScriptBehaviorS3Name, false, OutputFileMissFullPathErrorMessage);
|
||||
AWSScriptBehaviorS3NotificationBus::Broadcast(notificationFunc, OutputFileMissFullPathErrorMessage);
|
||||
AZ_Warning(AWSScriptBehaviorS3Name, false, OutputFileFailedToResolveErrorMessage);
|
||||
AWSScriptBehaviorS3NotificationBus::Broadcast(notificationFunc, OutputFileFailedToResolveErrorMessage);
|
||||
return false;
|
||||
}
|
||||
outFile = resolvedPath;
|
||||
|
||||
if (AZ::IO::FileIOBase::GetInstance()->IsDirectory(outFile.c_str()))
|
||||
{
|
||||
AZ_Warning(AWSScriptBehaviorS3Name, false, OutputFileIsDirectoryErrorMessage);
|
||||
|
||||
@@ -122,11 +122,11 @@ TEST_F(AWSScriptBehaviorS3Test, GetObjectRaw_CallWithEmptyOutfileName_InvokeOnEr
|
||||
AWSScriptBehaviorS3::GetObjectRaw("dummyBucket", "dummyObject", "dummyRegion", "");
|
||||
}
|
||||
|
||||
TEST_F(AWSScriptBehaviorS3Test, GetObjectRaw_CallWithOutfileNameMissFullPath_InvokeOnError)
|
||||
TEST_F(AWSScriptBehaviorS3Test, GetObjectRaw_CallWithOutfileFailedToResolve_InvokeOnError)
|
||||
{
|
||||
AWSScriptBehaviorS3NotificationBusHandlerMock s3HandlerMock;
|
||||
EXPECT_CALL(s3HandlerMock, OnGetObjectError(::testing::_)).Times(1);
|
||||
AWSScriptBehaviorS3::GetObjectRaw("dummyBucket", "dummyObject", "dummyRegion", "dummyOut.txt");
|
||||
AWSScriptBehaviorS3::GetObjectRaw("dummyBucket", "dummyObject", "dummyRegion", "@dummy@/dummyOut.txt");
|
||||
}
|
||||
|
||||
TEST_F(AWSScriptBehaviorS3Test, GetObjectRaw_CallWithOutfileNameIsDirectory_InvokeOnError)
|
||||
|
||||
@@ -107,31 +107,31 @@ class ExampleResources(core.Stack):
|
||||
self._s3_output = core.CfnOutput(
|
||||
self,
|
||||
id=f'ExampleBucketOutput',
|
||||
description='An example S3 bucket to use with AWSCore ScriptBehaviors',
|
||||
export_name=f"ExampleS3Bucket",
|
||||
value=self._s3_bucket.bucket_arn)
|
||||
description='An example S3 bucket name to use with AWSCore ScriptBehaviors',
|
||||
export_name=f"{self.stack_name}:ExampleS3Bucket",
|
||||
value=self._s3_bucket.bucket_name)
|
||||
|
||||
# Define exports
|
||||
# Export resource group
|
||||
self._lambda_output = core.CfnOutput(
|
||||
self,
|
||||
id=f'ExampleLambdaOutput',
|
||||
description='An example Lambda to use with AWSCore ScriptBehaviors',
|
||||
export_name=f"ExampleLambdaFunction",
|
||||
value=self._lambda.function_arn)
|
||||
description='An example Lambda name to use with AWSCore ScriptBehaviors',
|
||||
export_name=f"{self.stack_name}::ExampleLambdaFunction",
|
||||
value=self._lambda.function_name)
|
||||
|
||||
# Export DynamoDB Table
|
||||
self._table_output = core.CfnOutput(
|
||||
self,
|
||||
id=f'ExampleDynamoTableOutput',
|
||||
description='An example DynamoDB Table to use with AWSCore ScriptBehaviors',
|
||||
export_name=f"ExampleTable",
|
||||
value=self._table.table_arn)
|
||||
description='An example DynamoDB Table name to use with AWSCore ScriptBehaviors',
|
||||
export_name=f"{self.stack_name}:ExampleTable",
|
||||
value=self._table.table_name)
|
||||
|
||||
# Export user policy
|
||||
self._user_policy = core.CfnOutput(
|
||||
self,
|
||||
id=f'ExampleUserPolicyOutput',
|
||||
description='A User policy to invoke example resources',
|
||||
export_name=f"ExampleUserPolicy",
|
||||
export_name=f"{self.stack_name}:ExampleUserPolicy",
|
||||
value=self._policy.managed_policy_arn)
|
||||
|
||||
Reference in New Issue
Block a user