feat(cloudfront): add new check cloudfront_distributions_s3_origin_non_existing_bucket (#4996)

Co-authored-by: Sergio <sergio@prowler.com>
This commit is contained in:
Hugo Pereira Brito
2024-09-23 18:43:03 +02:00
committed by GitHub
parent 14ed19e3a8
commit cca17b9378
19 changed files with 299 additions and 35 deletions
@@ -2,6 +2,7 @@ import json
from unittest.mock import patch
import botocore
import botocore.exceptions
from boto3 import client
from moto import mock_aws
@@ -478,6 +479,32 @@ class Test_S3_Service:
assert s3.buckets[bucket_arn].lifecycle[0].id == "test"
assert s3.buckets[bucket_arn].lifecycle[0].status == "Enabled"
# Test S3 Head Bucket
@mock_aws
@patch("botocore.client.BaseClient._make_api_call", new=mock_make_api_call)
def test_head_bucket(self):
# Generate S3 Client
s3_client = client("s3")
# Create S3 Bucket
bucket_name = "test-bucket"
bucket_arn = f"arn:aws:s3:::{bucket_name}"
s3_client.create_bucket(
Bucket=bucket_name,
ObjectOwnership="BucketOwnerEnforced",
ObjectLockEnabledForBucket=True,
)
# S3 client for this test class
aws_provider = set_mocked_aws_provider([AWS_REGION_US_EAST_1])
s3 = S3(aws_provider)
assert len(s3.buckets) == 1
assert s3.buckets[bucket_arn].name == bucket_name
assert s3._head_bucket(
bucket_name=bucket_name,
)
assert s3.buckets[bucket_arn].region == AWS_REGION_US_EAST_1
# Test S3 List Access Points
@patch("botocore.client.BaseClient._make_api_call", new=mock_make_api_call)
@mock_aws