Merge branch 'main' into route_table_supplier

main
William BEUIL 2021-07-06 10:57:12 +02:00 committed by GitHub
commit 0e6c6caf08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -58,6 +58,11 @@ func (s *s3Repository) GetBucketPolicy(bucketName, region string) (*string, erro
&s3.GetBucketPolicyInput{Bucket: &bucketName},
)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
if awsErr.Code() == "NoSuchBucketPolicy" {
return nil, nil
}
}
return nil, errors.Wrapf(
err,
"Error listing bucket policy %s",

View File

@ -297,6 +297,20 @@ func Test_s3Repository_GetBucketPolicy(t *testing.T) {
},
want: awssdk.String("foobar"),
},
{
name: "get bucket location on 404",
bucketName: "test-bucket",
region: "us-east-1",
mocks: func(client *awstest.MockFakeS3) {
client.On("GetBucketPolicy", &s3.GetBucketPolicyInput{
Bucket: aws.String("test-bucket"),
}).Return(
nil,
awserr.New("NoSuchBucketPolicy", "", nil),
).Once()
},
want: nil,
},
{
name: "get bucket location when error",
bucketName: "test-bucket",